The Simplest Way to Make Kustomize and Spanner Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use kustomize and spanner together to manage database settings across Kubernetes stages. Kustomize patches app files per stage while Spanner stores the live data. This workflow keeps base manifests clean and free of hardcoded database details. Each cluster stage gets its own project name, instance ID, and role bindings. How kustomize and spanner handle roles and data flow Kustomize starts with a shared base folder that holds common Kubernetes manifests. Overlays then patch those manife

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.

Teams use kustomize and spanner together to manage database settings across Kubernetes stages. Kustomize patches app files per stage while Spanner stores the live data.

This workflow keeps base manifests clean and free of hardcoded database details. Each cluster stage gets its own project name, instance ID, and role bindings.

How kustomize and spanner handle roles and data flow

Kustomize starts with a shared base folder that holds common Kubernetes manifests. Overlays then patch those manifests with stage details for test, staging, or live clusters.

Each overlay sets the exact Spanner project, instance, and database name for that stage. It also patches the Kubernetes service account attached to the app pods.

Workload identity links that Kubernetes service account to a cloud service account. When a pod runs, it uses this link to log in to Spanner.

No one has to put static key files inside the git repo. The pod gets short tokens from the cloud metadata server during its run.

Spanner checks the cloud role before it allows any read or write request. Data then flows over secure cloud networks between the pod and the database.

Kustomize also sets resource limits and replica counts alongside those database settings. A small test overlay points to a small instance with low pod counts.

The live overlay points to a multi-region instance and runs more pods. Both stages share the exact same base app template without copy and paste.

Common failure modes and how to scope access

Many teams make the mistake of sharing one service account across all overlays. If a test pod gets breached, the attacker can reach the live database.

Fix this by giving each Kustomize overlay its own dedicated service account. Bind the test account only to the test Spanner database role.

End-to-End Encryption + Kustomize Security Overlays: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Overbroad database roles cause another major risk for engineering teams. A pod that only reads rows should never hold admin or drop permissions.

Split your app components into separate Kustomize bases or overlays by task. Give read-only pods a reader role and write pods a narrow writer role.

Schema change jobs need higher rights, so run them as separate Kubernetes jobs. Use a dedicated overlay that runs once and then exits right away.

Unlogged human queries during incidents also create blind spots in your audit trail. Engineers often port-forward or exec into pods using the shared app role.

When they run manual queries this way, all actions look like app traffic. You cannot tell which team member ran a specific query or changed data.

Human database sessions should use individual identities instead of the pod role. Masking rules can also rewrite emails, phone numbers, card numbers, and national IDs in results.

Finally, lock down the network paths between your clusters and the cloud database. Use private network paths and strict firewall rules for each separate cluster stage.

Keeping manifests clean across team stages

Drift happens when engineers edit cluster objects by hand outside of git. Always apply your Kustomize overlays through an automated git pipeline on every change.

Keep database instance names in stage config maps rather than inside app containers. That way, the same container image promotes cleanly from test to live clusters.

Review your overlay patches often to make sure roles stay tight and minimal. Clean overlays make audits fast and keep database settings easy to read.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Should we store Spanner credentials in Kustomize secret generators?

No, avoid storing static database keys in git or secret generators. Patch the Kubernetes service account in each overlay and use cloud workload identity instead.

How do we point different Kustomize overlays to different Spanner instances?

Put the instance ID and database name in a base config map. Then use an overlay patch in each stage to replace those values.

How should we run Spanner schema changes with Kustomize?

Create a separate Kubernetes job manifest for schema migrations in your repo. Give that job its own overlay and a role scoped only to schema updates.

The query runs. The emails stay hidden.