Google Cloud: Set up private connectivity

Private connectivity lets you reach your KiviDB instance from your own Google Cloud network without traffic crossing the public internet. It uses Private…

Private connectivity lets you reach your KiviDB instance from your own Google Cloud network without traffic crossing the public internet. It uses Private Service Connect: KiviDB publishes a service attachment, and you create a PSC endpoint in your own VPC that connects to it.

Because the connection is made from inside your VPC, you do not need to allow-list any IP addresses. You can also turn off public access entirely once it is working.

What it costs

$25 per instance per month, plus $0.01 per GB of data through the endpoint.

Two things to know about the charge:

  • It is prorated hourly. Enabling it for a few hours costs a few cents, not $25.
  • It continues while the instance is stopped. The network resources stay allocated to you whether the database is running or not, so stopping an instance does not pause this charge. Turning private connectivity off does.

Before you start

You need:

  • A paid instance. Free-tier instances run on shared infrastructure and cannot use private connectivity.
  • A Google Cloud project of your own, with a VPC in the same region as your instance.
  • Permission to create PSC endpoints (forwarding rules) in that VPC.

Step 1 — Enable it on your instance

  1. Open your instance, go to Configuration → Network.
  2. Turn on Private connectivity.

The service takes two to three minutes to build: a health check, an internal load balancer in front of your node, and a service attachment in front of that. You will see a notification while it works, and the service attachment URI appears when it is ready. You can leave the page; the notification will tell you when it is done.

Until the service exists there is nothing to allow-list against, so the field for projects stays hidden. It appears once the URI does.

If your region has not had private connectivity set up yet, enabling it tells you so by name rather than failing vaguely. Private Service Connect needs a dedicated address range that cannot be created on demand, so a region can have everything else and not this. Ask and it will be added.

Step 2 — Allow your project

Once the URI appears, add the project that will connect. Find its ID:

gcloud config get-value project

Back in Configuration → Network → Private connectivity, add that project ID. It looks like:

my-project-123

The project number works too, if that is what you have to hand.

Google Cloud authorises projects, not individual identities — there is no equivalent of an IAM principal here, and no equivalent of Azure's separate visibility and approval lists. One list does both jobs: a project on it is accepted automatically, and a project that is not on it cannot connect at all. Anyone who can create a PSC endpoint in an allowed project can connect, so allow the projects you actually control.

Removing a project revokes its access.

Step 3 — Create the PSC endpoint

A PSC endpoint is a forwarding rule in your VPC that targets the service attachment. Reserve an internal address for it first, then point it at the URI KiviDB gave you.

# An internal address in the subnet your application runs in.
gcloud compute addresses create kividb-psc \
  --region=us-central1 \
  --subnet=YOUR_SUBNET \
  --addresses=10.128.0.50 \
  --purpose=GCE_ENDPOINT

# The endpoint itself. The target is the URI from your instance's
# Configuration -> Network page.
gcloud compute forwarding-rules create kividb-psc \
  --region=us-central1 \
  --network=YOUR_VPC \
  --address=kividb-psc \
  --target-service-attachment=projects/.../serviceAttachments/...

You can do the same from the console under Network services → Private Service Connect → Connect endpoint.

The connection should show as accepted within a few seconds, because your project is on the allow-list. If it sits in pending, the project you connected from is not the one you allowed — check which project the gcloud command actually used.

Step 4 — Get the address and connect

The endpoint's address is the one you reserved. Connect to it on the usual port:

redis-cli -h 10.128.0.50 -p 6379 -a "$KIVIDB_PASSWORD"

Nothing about your credentials changes. The private path is a different route to the same database, not a different database.

If you use TLS, connect by hostname rather than by address: the certificate is issued against your instance's hostname and will not verify against an IP. Create a Cloud DNS private zone for cloud.kividb.io in your VPC with an A record for your instance's name pointing at the endpoint address, and your clients can keep using the hostname they already have.

Step 5 — Ports

The endpoint forwards every port your instance listens on, so 6379 and — when TLS is enabled — 6380 both work through it without any extra configuration.

This is deliberate rather than incidental: a fixed port list would have to be rebuilt whenever you toggled TLS, and an endpoint built before you did would silently not carry 6380.

Step 6 — Optionally block public access

Once the private path works, you can withdraw the public one entirely.

Configuration → Network → Block public access. Your allow-list is kept and simply stops being published, so turning the option off restores it exactly.

Test the private path thoroughly first. Blocking public access while something still connects over the internet breaks it immediately.

The Explorer and health monitoring keep working — KiviDB keeps its own management connection to your instance regardless, which is what those features run on.

Turning it off

Configuration → Network → Private connectivity → off. This removes the service attachment, the load balancer and the health check, and the $25 charge stops at the next hour boundary.

Delete your own PSC endpoint too. It is in your project, so KiviDB cannot remove it, and a forwarding rule pointing at a service attachment that no longer exists keeps billing in your account.

You cannot turn private connectivity off while public access is blocked — that would leave the instance unreachable. Re-enable public access first.

Troubleshooting

The connection stays pending. The project you connected from is not on the allow-list. gcloud config get-value project tells you which project the command used, which is often not the one you meant.

Timeouts from a machine in a different VPC. A PSC endpoint is reachable from its own VPC. Another VPC needs peering, and peering does not propagate PSC endpoint routes by default — check the export and import settings on the peering.

Timeouts from the right VPC. Check the region. The endpoint and the service attachment must be in the same region as your instance; a cross-region endpoint is refused at creation, but a cross-region client reaching a correctly placed endpoint is a routing problem on your side.

Certificate errors. You are connecting by IP. See the DNS note in step 4.

It worked and then stopped after a failover. It should not — the attachment follows the promoted node automatically. If it does not, tell support, because that is a fault rather than a configuration issue.