The Simplest Way to Make Cloud Run and Kustomize Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using cloud run and kustomize together lets teams manage serverless container rules without duplicate files. Kustomize builds stage-specific manifest files, and Google Cloud deploys those files to run your app. This workflow keeps your base settings in one clean place. Teams apply small patches for dev, staging, and prod stages. You avoid copy-paste errors across your cloud projects. How cloud run and kustomize pass data and permissions Cloud Run accepts declarative YAML files that follow th

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 cloud run and kustomize together lets teams manage serverless container rules without duplicate files. Kustomize builds stage-specific manifest files, and Google Cloud deploys those files to run your app.

This workflow keeps your base settings in one clean place. Teams apply small patches for dev, staging, and prod stages. You avoid copy-paste errors across your cloud projects.

How cloud run and kustomize pass data and permissions

Cloud Run accepts declarative YAML files that follow the Knative service spec. Kustomize reads a base service file and merges stage overlays on top of it. This step happens inside your build pipeline before any cloud call runs.

First, the build runner runs Kustomize to create the final manifest. The overlay sets the container image tag, memory limits, and scaling bounds. It also sets the specific service account email for that stage.

Next, the pipeline logs in to Google Cloud using workload identity federation. This step exchanges a short token from your Git runner for a cloud token. You do not store long-lived JSON keys in your build tool.

Then, the cloud client sends the rendered YAML to the Cloud Run API. Google Cloud checks the caller role to confirm it can update the service. It also checks that the caller can attach the runtime service account.

Once the check passes, the platform pulls the container image and starts new instances. Traffic shifts to the new revision based on the rules in your manifest.

Common failure modes and how to scope roles

Teams often hit errors when base files and overlays mix up schema rules. Standard Kubernetes fields do not always work in a serverless service file. If Kustomize injects an unsupported field, the cloud API rejects the whole deploy.

Shared service accounts cause a much bigger risk in production. Many teams use the default compute account for both builds and running apps. If one app gets compromised, the attacker gains broad rights across the project.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad deploy tokens also create blind spots in your audit logs. When every pipeline uses one shared admin key, you cannot trace who changed a rule. Unlogged manual changes from laptops make this drift even worse.

To fix this, give each stage and app its own runtime service account. Use Kustomize overlays to swap the account email for dev, staging, and prod. Grant each runtime account only the exact data roles it needs.

Scope your deploy pipeline roles down to the minimum required actions. The build runner only needs rights to update the service and pass the runtime account. Block developers from running manual deploys from local machines with broad user roles.

Keeping secrets and stage settings clean in overlays

Never put raw API keys or database passwords inside your Kustomize patches. Git stores every commit, so plain text secrets in overlays leak fast. Instead, store secret values in a dedicated cloud secret manager.

Use your Kustomize overlay to map secret names and versions to the container. The overlay only holds the path to the secret, not the secret value. At startup, the platform reads the secret and mounts it for the app.

Keep network paths strict between your stages as well. Use overlays to attach the right VPC connector for each stage. Dev services should only talk to dev data stores, never to production networks.

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

Can Kustomize deploy directly to Google Cloud Run?

No, Kustomize only builds and prints the final YAML text. You pipe that output into the Google Cloud CLI or a GitOps tool to deploy.

How do I handle different container tags per stage?

Each stage folder has its own overlay file that sets the image tag. Your build pipeline updates that tag with the latest commit hash before rendering.

Why does Cloud Run reject my rendered Kustomize YAML?

The platform uses a strict subset of the Knative service spec. Check that your patches do not add standard cluster fields that serverless containers ignore.

The query runs. The emails stay hidden.