How to Integrate Argo CD and Spanner Safely

Published
Length
3 min read

Luis Felipe Dias

All posts

Integrating argo cd and spanner lets teams deploy app code and database changes together. Argo CD reads Git files and runs Kubernetes jobs that update your Spanner schema. This workflow keeps your app pods and database tables in sync during every release. Teams do not need to run manual database scripts from their own laptops anymore. How argo cd and spanner share permissions and data Argo CD runs inside your Kubernetes cluster and watches a Git repo for changes. When a developer merges code

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.

Integrating argo cd and spanner lets teams deploy app code and database changes together. Argo CD reads Git files and runs Kubernetes jobs that update your Spanner schema.

This workflow keeps your app pods and database tables in sync during every release. Teams do not need to run manual database scripts from their own laptops anymore.

How argo cd and spanner share permissions and data

Argo CD runs inside your Kubernetes cluster and watches a Git repo for changes. When a developer merges code, Argo CD starts a sync phase for the app.

During this sync phase, Argo CD launches a short Kubernetes job for database updates. That job needs a cloud role to talk to your Spanner database instance.

In Google Cloud, Workload Identity links a Kubernetes service account to an IAM role. The migration pod uses this link to log in without a static key file.

Once logged in, the job sends schema update statements over the cloud network. Spanner applies those table changes while the cluster rolls out the new app pods.

App pods also use their own service account to read and write table rows. Keeping migration roles separate from app runtime roles limits damage if a pod breaks.

Common failure modes in database sync workflows

Many teams make the mistake of sharing one broad cloud account across all jobs. If every pod uses the same admin role, any app bug can drop tables.

Another common risk comes from storing long-lived JSON keys inside Kubernetes secrets. Static keys can leak in cluster backups or sit unrotated for many months.

Shared service accounts also ruin your audit logs during a security review or outage. Cloud logs will show the shared bot name instead of the person who approved it.

CI/CD Credential Management + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged queries create blind spots when a deployment fails or corrupts production customer data. You cannot tell which sync job ran a bad query without clear query logs.

When human engineers debug a broken sync, they often use broad database roles too. A raw query might return sensitive customer emails, phone numbers, or card numbers.

Scoping roles and network paths between systems

Start by creating two distinct cloud roles for each service in your cluster. Give the migration job permission to alter schemas only during the deployment step.

Give the running app role permission to read and write data in specific tables. Never let the daily app role drop tables or change database settings.

Bind each cloud role to a single Kubernetes namespace and service account name. This rule stops a pod in a test namespace from touching production Spanner data.

Restrict network paths so only approved cluster nodes can reach the database endpoint. Private cloud paths keep database traffic off the public internet at all times.

When engineers inspect production tables after a sync, apply data masking to query results. Masking rewrites matched fields like emails, phone numbers, and national IDs in results.

Also require peer approvals before a sync job can run destructive schema changes. Clear controls keep both automated pipelines and human checks safe in production.

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

How should Argo CD run Spanner schema migrations?

Use an Argo CD sync hook to run a Kubernetes job before app pods start. This job logs in with a scoped cloud role and applies the schema changes.

Can we connect Argo CD to Spanner without static keys?

Yes, you can link your Kubernetes service account to a Google Cloud IAM role. The migration pod gets a short token from the cloud platform at runtime.

How do we stop app pods from changing Spanner schemas?

Create separate service accounts for the migration job and the running app pods. Grant schema edit rights only to the migration role, and give data rights to pods.

The query runs. The emails stay hidden.