Skip to content

Run Terraform yourself

The lowtide module installs everything in one terraform apply: network, a regional GKE cluster, Cloud SQL for PostgreSQL, the segment bucket, least-privilege IAM, a TLS endpoint on an internal load balancer, and the Helm release with the agent. lowtide holds no access to your project. You apply it with your own credentials.

Clusters → Create cluster → Run Terraform yourself. Enter the project, region, zones, environment, expected peak rate, Pub/Sub projects and, optionally, the endpoint host. The console then shows a one-time join token and, on the Terraform tab, a complete main.tf.

The main.tf contains the provider configuration, the module block with your choices, and the licence verification keys. The core of it looks like this:

module "lowtide" {
source = "MODULE_SOURCE?ref=vVERSION" # filled in by the console
project_id = "acme-lowtide-prod"
region = "europe-west1"
zones = ["europe-west1-b", "europe-west1-c"]
cluster_name = "orders-prod"
environment = "production"
size = "medium"
gcp_iam_projects = ["acme-orders"]
endpoint_host = "pubsub.prod.acme.internal"
join_token = var.lowtide_join_token
}

Every input is described in the Terraform module reference.

Save the file as main.tf in an empty directory and run, with your own credentials (Cloud Shell, Infrastructure Manager or your CI):

Terminal window
export TF_VAR_lowtide_join_token='<token from the console>'
terraform init
terraform apply

The apply takes about 25 minutes. Cloud SQL and the GKE cluster are the slow parts. The join token works once and expires after 24 hours. If it expires before the agent registers, select Create a new token in the console and apply again with it.

The cluster shows Healthy in the console once the agent has registered.

Use a protected backend, for example a GCS bucket with narrow access. The state holds the join token, the internal pod-to-pod token, the database admin password and the TLS private keys. The rendered main.tf has a commented backend "gcs" block to fill in.

The module has no provider blocks, so it works with count, for_each and depends_on. The rendered main.tf configures the kubernetes and helm providers from the module’s kubernetes_endpoint and kubernetes_ca_certificate outputs and a google_client_config access token. That token is valid for one hour. For longer runs, use the gke-gcloud-auth-plugin exec form instead.

If your workstation or CI can’t reach the cluster’s control plane, set fleet_project (usually the same project). The module then registers the cluster in the fleet, and the connect_gateway_host output gives an address for the providers and kubectl through the Connect gateway.

Project Owner works. For least privilege, the account that runs Terraform needs, in project_id:

Role For
roles/serviceusage.serviceUsageAdmin Enabling APIs. Not needed with enable_apis = false.
roles/compute.networkAdmin VPC, subnet, router, NAT, addresses
roles/servicenetworking.networksAdmin Private Service Access for Cloud SQL
roles/container.admin The cluster, node pools and Kubernetes objects
roles/cloudsql.admin The Cloud SQL instance, database and users
roles/storage.admin The bucket and its IAM
roles/iam.serviceAccountAdmin The gateway, agent and node service accounts, Workload Identity and Token Creator bindings
roles/iam.serviceAccountUser on the node service account Creating node pools that run as it
roles/resourcemanager.projectIamAdmin Project-level grants for the node account and the Cloud SQL roles
roles/dns.admin Only with dns_managed_zone
roles/cloudkms.admin, or IAM admin on the key Only with kms_key

In each gcp_iam_projects project: roles/iam.roleAdmin (to create the shadow role), roles/resourcemanager.projectIamAdmin (to bind it) and roles/serviceusage.serviceUsageAdmin (to enable Pub/Sub). With gcp_iam_shadow_role set to a role you made, only the binding right is needed.

In each pubsub_mirror_projects or pubsub_migration_projects project: roles/resourcemanager.projectIamAdmin, plus roles/iam.roleAdmin for the migration role.

Area Resources
APIs Compute, GKE, Cloud SQL Admin, Service Networking, Cloud Storage, IAM, IAM Credentials, Resource Manager, and DNS, Cloud KMS and Pub/Sub when used. Never disabled on destroy.
Network A VPC lowtide-<name>, a subnet with secondary ranges for pods and Services and Private Google Access, Cloud Router and NAT. Skipped when you bring a network or cluster.
Private Service Access A /20 range and the peering for Cloud SQL’s private IP. Only for a VPC the module creates, unless you set create_private_service_access.
GKE A regional Standard cluster in your two zones: Workload Identity, private nodes, Dataplane V2 (NetworkPolicy), Managed Prometheus, shielded nodes, deletion protection. A system node pool.
Gateway node pool Sized by size, in both zones, tainted so only gateway pods run there, autoscaling from N to 2N nodes per zone for zone failover and upgrades. One gateway pod per node.
Cloud SQL PostgreSQL 16, private IP only, connections through the Cloud SQL Auth Proxy only, IAM database authentication, daily backups kept 14 days, point-in-time recovery for 7 days, deletion protection. Highly available in production.
Bucket Regional, uniform access, public access prevention, soft delete off, a lifecycle rule that deletes segments after max_retention_days + retention_margin_days (38 days by default) as a backstop.
IAM The gateway’s service account, bound to its Kubernetes service account only, with object admin on the bucket, Cloud SQL client and instance user on the instance only, Token Creator on push service accounts, the shadow role in each Pub/Sub project, and Pub/Sub Publisher where mirroring is on. The agent’s own service account. No keys.
TLS A private CA (ECDSA P-256, 10 years) and a server certificate (2 years) for the endpoint host, the in-cluster Service names and the load balancer IP. Or your own Secret.
Kubernetes The namespace (Pod Security baseline enforced), Secrets, a one-off database bootstrap Job, and an internal load balancer on a reserved IP, port 443 only.
Helm The lowtide release: agent on, TLS on, Cloud IAM authorization when Pub/Sub projects are given, the Cloud SQL Auth Proxy as a sidecar, NetworkPolicy, PodMonitoring.

Labelled resources carry app=lowtide and lowtide-cluster=<cluster_name>, plus your labels.

An existing GKE cluster (existing_gke_cluster) must be a Standard cluster with nodes in both zones, Workload Identity on, Kubernetes 1.31 or later, the Compute Engine persistent disk CSI driver, and a VPC with Private Service Access (or set create_private_service_access = true). The module adds its tainted gateway node pool (or set create_node_pool = false and size the nodes yourself). NetworkPolicy works only if the cluster enforces it.

An existing network (network and subnetwork, for a new cluster): Private Service Access must exist. With private nodes, the VPC needs Cloud NAT, or set private_nodes = false. Name the subnet’s secondary ranges with pods_range_name and services_range_name, or GKE creates them. GKE can’t create them in a Shared VPC service project.

  • Clients in the VPC use the endpoint output: the internal load balancer, port 443 only. Clients in the cluster use lowtide.<namespace>.svc:443, which routes to a pod in their own zone. The plaintext port is never exposed outside the cluster.
  • The module’s private CA signs the server certificate. Clients trust the tls_ca_certificate output (Endpoints and TLS). The first terraform apply in the certificate’s last 90 days issues a new one, and the gateway loads it without a restart. Apply at least once a year, or bring your own certificate.
  • Your own certificate: create a kubernetes.io/tls Secret in the namespace, for example from a cert-manager Certificate whose names include endpoint_host and lowtide.<namespace>.svc, and set tls_secret_name. To have the Secret in place before the first apply, create the namespace yourself and set create_namespace = false.
  • Never change cluster_name, zones or namespace of a running installation. Pod names are tied to their WAL disks and writer streams.
  • size changes node type and count, pod resources, the pending-upload cap and the Cloud SQL tier in place. A new machine type builds the new node pool before draining the old one. A new Cloud SQL tier restarts the instance, which is a short metadata outage (a failover in production).
  • WAL disk size stays what it was at install, because Kubernetes can’t change a StatefulSet’s volume templates. To grow the disks, follow WAL disk full, then set wal_disk_size_gb and apply.
  • Going down a size or lowering gateways_per_zone removes pods. Scaling down is not drain-aware (Upgrades and scaling).
  • kms_key set after the install recreates the Cloud SQL instance and the cluster. Set customer-managed encryption at install.

To delete the installation, see Pause and delete.