// Why this matters
If you want to deploy Concourse CI on GKE with Terraform, the cluster is the easy part. The value comes from the supporting pieces: a secrets manager the pipelines can actually use, messaging wired in as code, and an ingress layer that exposes the web UIs once. Together they form an internal delivery platform that a small team can reproduce from a repository instead of a wiki page.
Concourse is a good fit for teams that want pipelines as declarative resources with containerised tasks and no plugin sprawl. Vault is the natural pairing because Concourse can read credentials from it at build time, so no secret ever lands in pipeline YAML. Pub/Sub is the event backbone that connects pipelines to the outside world, for example triggering a run when an image is published.
The reason to write all of it as Terraform and Helm values is repeatability: the same code produces a dev platform for experimenting and a staging platform for proving changes, differing only in variable files. That is also what makes it reviewable.
// The problem
The request was an internal CI/CD and secrets platform on Kubernetes with messaging managed as code per environment. The usual shortcuts each cause pain later. Installing Vault with a single replica and manual unseal means a node restart produces an outage until someone types unseal keys. Hand-created Pub/Sub topics drift between environments. Hand-edited Helm values live in one engineer shell history.
Several requirements pull in different directions: Vault must survive node preemption without a human, the platform had to be cheap enough to run continuously, and the same stack had to deploy into more than one environment without copy-pasted Terraform.
Bootstrapping order is also a trap. Vault needs the KMS key before it can auto-unseal, Concourse wants Vault reachable before its credential-manager config makes sense, and the Kubernetes auth method needs a service account that exists only once the cluster does. Get the order wrong and you debug chicken-and-egg errors.
// The solution
We split infrastructure into two Terraform stacks with separate state. The platform stack (GKE, node service account, KMS key ring and key, storage bucket) changes rarely. The messaging stack (Pub/Sub topics and subscriptions) changes often and is driven by a variable map that is loaded per environment from a JSON variables file, so topic creation is a pull request on data, not code.
Kubernetes software is installed with Helm, with all non-default settings in version-controlled values files. Vault runs HA with three replicas and integrated Raft storage, so no external database is needed. It auto-unseals using a Cloud KMS key, so pod restarts and preemptions recover on their own. A dedicated service account with the auth-delegator role is the token reviewer that lets Vault validate Kubernetes service account tokens.
Concourse is installed from its chart behind the same ingress as everything else. In this design the web UI and Vault UI are exposed through a single gateway so there is one place to add TLS and access policy. Preemptible nodes cut the compute cost sharply and are acceptable here because Vault auto-unseals and Concourse workers are stateless by design; for production you would move Vault to a regular node pool and pin it there.
We rejected a few alternatives: a managed secrets service (viable, but the requirement was a Vault-compatible workflow that pipelines already knew), Consul as Vault storage (extra moving parts when Raft is built in), and Terraform-managed Helm releases for everything (convenient, but it couples chart upgrades to infrastructure applies and makes Helm values harder to diff).
- Terraform GKEcluster, preemptible nodes, service account, Istio add-on
- Vault storage and KMSbucket, key ring and key for auto-unseal
- Pub/Sub moduletopics and subscriptions from per-environment variables
- Vault HelmHA with Raft, Kubernetes auth reviewer
- Concourse Helmvalues-driven install behind ingress
- Test appFlask push receiver as a custom chart
- MonitoringPrometheus manifests
// Before you start
- A cloud project with billing enabled and the Kubernetes Engine, Cloud KMS, Pub/Sub and Storage APIs turned on.
- Terraform 1.5+, gcloud, kubectl, Helm 3 and the Vault CLI installed locally.
- Permission to create clusters, service accounts, KMS key rings and IAM bindings in the project.
- A DNS name or a plan for reaching the ingress (port-forward is fine for a first run).
- Basic familiarity with Kubernetes RBAC, StatefulSets and persistent volumes.
// Step-by-step implementation
01 Provision the GKE cluster with Terraform
Create a dedicated node service account instead of using the default compute identity; grant it only what the nodes need and give the workloads their own identities. Use preemptible (or Spot) nodes for the cheap tier and a longer create timeout, because cluster creation regularly exceeds the 20 minute default.
The managed Istio add-on used to be the quickest route to a gateway, but it has been retired on current GKE versions. Install a gateway controller yourself (Istio, or the Gateway API implementation) as a Helm release, or use the cluster ingress. The Terraform below leaves the add-on out for that reason.
02 Create the KMS key ring and storage for Vault auto-unseal
Auto-unseal needs a key Vault can use to wrap its master key. Create a key ring and a symmetric key with rotation, and grant the identity Vault runs as the encrypter/decrypter role on that key only. Key rings and keys cannot be deleted in Cloud KMS, so choose names you are happy to keep. The bucket is useful for backups and snapshots.
03 Install Vault HA with Raft and KMS auto-unseal
Three replicas with integrated storage form the Raft cluster. The seal stanza tells Vault to use Cloud KMS; the project, region, key ring and key are all placeholders here. Enable the injector if you want pods to receive secrets via annotations, and keep the UI on for the first run.
After install, only the first pod needs initialising. With auto-unseal, the others join and unseal themselves, and so does every restarted pod from then on.
04 Initialise Vault and enable Kubernetes auth with a token reviewer
Initialise once, with recovery keys (auto-unseal changes unseal keys into recovery keys). Store the root token and recovery keys in your offline process and revoke the root token once your admin auth is configured.
Then create a reviewer service account bound to the system:auth-delegator cluster role. Vault uses its token to call TokenReview on behalf of every login. Configure the auth method with the cluster API address and CA, and create a role mapping a namespace and service account to a policy.
05 Install Concourse with Vault as the credential manager
Concourse web nodes can read pipeline parameters from Vault at runtime, so nothing sensitive is stored in pipeline files or in the Concourse database. Set the path prefix and the auth backend in values; with the Kubernetes backend, the web pod authenticates to Vault using its service account and the role created above.
Concourse needs a PostgreSQL database; the chart bundles one for non-production use. For anything lasting use a managed instance.
06 Manage Pub/Sub topics and subscriptions as data
The messaging stack is a small module that accepts a map of topics. Each topic lists its subscriptions with acknowledge deadline, retry policy and push endpoint when applicable. A per-environment JSON variables file supplies the map, so dev and staging differ in data rather than code.
07 Deploy the push-subscriber app as a custom chart
A push subscription POSTs a JSON envelope to your endpoint, with the message base64-encoded under message.data. The receiver must return a 2xx quickly to acknowledge, so keep processing short or hand it to a queue. Package the app as a minimal chart so image, replicas and environment live in values.
In production, verify the push request: configure the subscription with an OIDC token and validate the audience and issuer in the handler instead of trusting any POST.
08 Expose Vault and Concourse through one gateway
One gateway with host-based routing means a single TLS certificate and a single place for access control. Route the CI hostname to the Concourse web service and the secrets hostname to the Vault UI. Restrict the Vault route to your admin network or put it behind identity-aware access, because it is the most sensitive endpoint on the platform.
// How to verify it works
kubectl -n vault exec vault-0 -- vault statusshows Initialized true, Sealed false and HA Enabled true;vault operator raft list-peerslists three voters.- Delete a Vault pod: it restarts and returns to unsealed by itself with no manual step, proving KMS auto-unseal works.
- From a pod running as the bound service account, a login against auth/kubernetes returns a token with the ci-read policy.
fly -t main loginthen set a test pipeline using a ((variable)) stored at secret/ci/...; the build resolves it without the value appearing in the pipeline file.- Publish a test message with
gcloud pubsub topics publish image-published --message hello; the receiver logs it and the subscription backlog returns to zero.
// Design decisions and trade-offs
- Workspace per environment, with data in tfvars.
- KMS-backed Vault seal; preemptible nodes to cut cost.
- Istio gateway as the single ingress layer; separate GKE and Pub/Sub stacks.
// Pitfalls and lessons learned
- Initialising Vault before the KMS IAM binding exists leaves it unable to seal; apply the key and bindings first.
- Cloud KMS key rings and keys cannot be deleted. Use prevent_destroy and deliberate names.
- Preemptible nodes will evict a Vault pod; with Raft and auto-unseal that is fine, but only with three replicas and anti-affinity so two never share a node.
- Chart values for the cluster API address must be reachable from inside the cluster; a public address behind a firewall causes token review failures that look like permission denied.
- Reusing one state file across environments eventually deletes the wrong topic. Separate state and variable files.
- Push endpoints that take more than the acknowledge deadline get the same message redelivered. Acknowledge fast, process asynchronously, and make handlers idempotent.
- Root tokens left in a shell history are the usual way Vault gets compromised. Revoke after bootstrap.
// Frequently asked questions
How do I deploy Concourse CI on GKE with Terraform?
Terraform creates the cluster, node pool and supporting resources; Helm installs the Concourse chart with a values file. This article covers each step including Vault as the credential manager.
Why use KMS auto-unseal for Vault?
Without it every restart needs humans with unseal keys. With a KMS seal, pods recover from preemption and upgrades on their own.
Is Raft storage production ready?
Yes, it is the recommended storage for new Vault clusters. Run three or five voters across failure domains and snapshot regularly.
Can Concourse read secrets from Vault natively?
Yes. Configure the web node with the Vault URL, a path prefix and an auth backend, and pipelines resolve variables at runtime.
How do I give teams isolated Vault paths?
Use per-team prefixes and policies, as covered in Vault as the Control Plane: A Five-Tier Key Model with Locking and Vault Access via Directory Groups, Requested by an Agent, Approved by a Human.
// The outcome
A self-contained delivery platform reproducible from code.
// Where to take it next
- Add TLS end to end and move Vault to a dedicated, non-preemptible node pool.
- Wire Prometheus scraping for Vault and Concourse and alert on seal status and failed builds.
- Automate Vault configuration itself as code; see Vault as the Control Plane: A Five-Tier Key Model with Locking.
- Compare with a CI-on-EKS build in CloudFormation EKS Platform with Per-Service CI/CD and a private variant in Private GKE Cluster with Self-Hosted Chat on Operators.