The Simplest Way to Make GCP Secret Manager and Kustomize Work Like They Should
Using gcp secret manager and kustomize together keeps plain text keys out of git repos. This setup pairs cloud secret storage with template-free Kubernetes manifest patches during each build. Teams store sensitive app data in Google Cloud. Then they use Kustomize overlays to shape manifests for dev, staging, and prod clusters. This workflow separates public app settings from private passwords and API keys. Engineers can update cluster YAML files in git while keeping raw secrets inside the cloud
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Using gcp secret manager and kustomize together keeps plain text keys out of git repos. This setup pairs cloud secret storage with template-free Kubernetes manifest patches during each build.
Teams store sensitive app data in Google Cloud. Then they use Kustomize overlays to shape manifests for dev, staging, and prod clusters. This workflow separates public app settings from private passwords and API keys. Engineers can update cluster YAML files in git while keeping raw secrets inside the cloud vault.
How gcp secret manager and kustomize move data
Kustomize reads base YAML files and applies environment patches to build final cluster manifests. It has a native secret generator, but that tool expects local files or plain text values. Storing those files in git breaks security rules for any production team.
To fix this, teams link Google Cloud IAM roles to their build runners or cluster workloads. In a build pipeline, the runner logs in to Google Cloud with a scoped service account. It fetches the secret payload by name and version, then feeds it into the Kustomize build step.
Many teams prefer to keep secret values out of the build runner altogether. In that model, Kustomize only patches the secret reference name and version into the deployment YAML. An in-cluster sync tool or workload identity role then reads the secret from Google Cloud at runtime. The pod gets its key when it starts, and the build system only handles manifest text.
Common failure modes and how to scope roles
The biggest risk in this workflow is a shared service account with broad secret read rights. If one build runner or cluster sync tool can read every secret in a project, isolation breaks. A dev overlay patch could point to a prod database password and pull it into a test cluster.
To prevent cross-stage leaks, assign a unique Google Cloud service account to each environment. Grant secret read permissions at the individual secret level, not across the entire cloud project. The staging identity should only have permission to read staging keys.
GCP Secret Manager + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Unlogged secret reads and rendered artifacts create another blind spot for security teams. When a pipeline runs a Kustomize build with real keys, the output YAML holds raw credentials. If the runner saves that build output as a job artifact, anyone with pipeline read rights can take it.
Always turn on Google Cloud Data Access audit logs for secret read events. These logs show which identity read which secret and when the request happened. Also, pin exact secret version numbers in your Kustomize patches instead of using the latest tag. Version pinning stops a bad secret update from breaking pods during the next cluster sync.
Keeping local builds and runtime operations safe
Local testing often pushes engineers to download cloud keys onto their laptops. An engineer might run a local Kustomize build to check how an overlay renders a secret patch. If they use personal cloud credentials with broad project roles, those local pulls create untracked secret copies.
Set up local Kustomize overlays to use dummy values or local mock files instead of cloud calls. Reserve real Google Cloud secret reads for automated pipelines and locked-down cluster workloads. When an engineer or tool needs live access to target services, enforce strict identity checks and field masking. For example, data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Should Kustomize fetch cloud secrets during the build step or at runtime?
Runtime fetching is safer because it keeps raw secret values out of CI build logs and saved artifacts. Have Kustomize patch the cloud secret reference name, and let a scoped cluster identity read the value when the pod starts.
How do we handle secret rotation with Kustomize overlays?
Store a new secret version in Google Cloud and update the version number in your Kustomize overlay patch. When you commit the change and deploy, the cluster updates the pod spec and pulls the new key.
How can we stop a dev Kustomize overlay from reading prod secrets?
Bind separate Google Cloud service accounts to your dev and prod workloads or runners. Grant IAM secret read roles on specific secret resources so the dev account gets denied if it requests a prod key.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Related guides
In this post