The Simplest Way to Make Cloud Run and Fluxcd Work Like They Should
You pair cloud run and fluxcd by running a small control cluster with cloud controllers. Flux reads your Git repo and tells Google Cloud to update your serverless apps. This setup brings GitOps rules to your serverless workloads. Your team writes plain text files to set up new services. You push those files to your main Git branch. The cluster controller reads the change and updates your live app right away. You do not need to run manual scripts from a laptop. How cloud run and fluxcd share i
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.
You pair cloud run and fluxcd by running a small control cluster with cloud controllers. Flux reads your Git repo and tells Google Cloud to update your serverless apps.
This setup brings GitOps rules to your serverless workloads. Your team writes plain text files to set up new services. You push those files to your main Git branch. The cluster controller reads the change and updates your live app right away. You do not need to run manual scripts from a laptop.
How cloud run and fluxcd share identities and data
Flux runs inside a Kubernetes cluster, while Cloud Run is a managed serverless platform. To bridge them, you add a cloud resource controller to your cluster. This controller translates Kubernetes objects into Google Cloud API calls.
First, you commit your service spec to a Git repo. Flux watches this repo on a set timer. When Flux sees a new commit, it pulls the files into the cluster. It then applies those files as custom resources.
Next, the cloud controller reads those custom resources. It uses workload identity to log in to Google Cloud. It checks the current state of your serverless app. If the live app does not match the Git file, the controller sends an update.
Data flows in one clear direction from Git to the cloud API. The cluster holds the state and logs every change. Your serverless app runs traffic without needing to know about Flux at all. When traffic spikes, Google Cloud scales the containers up or down on its own.
Common failure modes and how to scope roles
Many teams make mistakes when they first link these two systems. A common failure is using one shared service account with broad project owner rights. If an attacker gets into the cluster, they gain full control over your cloud account.
Another common bug is a drift loop between the two tools. Cloud Run changes traffic splits and instance counts on the fly. If Flux tries to overwrite those fields every minute, the two systems fight. Your deployment logs will fill up with conflict errors, and you might hit API quotas.
Teams also run into trouble with static keys stored in Git. Long-lived keys are easy to leak and hard to rotate. If someone leaves the team, you have to hunt down every place that key lives.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix these issues, scope your roles down to the bare minimum. Give the cluster controller a single role that can only update serverless services. Map each namespace in your cluster to its own cloud service account. This prevents one team from changing another team's live app.
Lock down the network path between the control cluster and the cloud API. Use private Google access so API calls never cross the public internet. Tell Flux to ignore fields that the cloud platform changes on its own. Finally, send all controller logs to a central log sink so you can track every change.
Day two operations and secret handling
Once your pipeline works, you must plan for day two tasks. Every serverless app needs secrets like API keys or database passwords to run. Never put plain text secrets into your Git repo.
Instead, store your secrets in a managed cloud secret store. In your Git files, only write the name and version of the secret. When the controller updates the serverless app, it links that secret name to the container.
When the container starts up, it reads the secret straight from the cloud store. The control cluster never reads or holds the actual secret value. This keeps your cluster clean and cuts down your risk if a node gets breached.
You should also set up alerts for failed sync loops. If a bad commit breaks a deployment, the controller will stop and report an error. Link Flux events to your team chat so engineers know right away when a push fails. To roll back a bad release, you just revert the commit in Git.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Do I still need a Kubernetes cluster to use Flux with Cloud Run?
Yes, Flux is a set of controllers that must run inside a Kubernetes cluster. Many teams use a small autopilot cluster just to run Flux and cloud controllers. This small cluster manages all their serverless apps across many projects.
How do I stop Flux from overwriting auto-scaling settings?
You must tell the controller to ignore dynamic fields or omit them from your Git files. Leave out instance counts and active revision names when they change outside of Git. This lets the cloud platform scale your app while Flux manages the base image.
How should Flux authenticate to Google Cloud?
Use workload identity federation instead of static JSON keys. This binds a Kubernetes service account to a Google Cloud service account. Google Cloud then gives the controller short-lived tokens that rotate on their own.
Related guides
In this post