The Simplest Way to Make Buildkite and Fluxcd Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use buildkite and fluxcd to separate code builds from cluster updates. Buildkite tests code and pushes images, while Fluxcd syncs those changes into Kubernetes. This split keeps cluster keys out of your build runners. Your build jobs only write to the image store and the state repo. The cluster agent then pulls the new state on its own schedule. This pattern limits what a bad build script can touch in production. How buildkite and fluxcd pass work and keys The workflow between buildkit

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 buildkite and fluxcd to separate code builds from cluster updates. Buildkite tests code and pushes images, while Fluxcd syncs those changes into Kubernetes.

This split keeps cluster keys out of your build runners. Your build jobs only write to the image store and the state repo. The cluster agent then pulls the new state on its own schedule. This pattern limits what a bad build script can touch in production.

How buildkite and fluxcd pass work and keys

The workflow between buildkite and fluxcd relies on a shared Git repo. A developer pushes app code to the main code repo first. Buildkite sees this push and starts a new test and build run. The build agent compiles the app and creates a new container image. Next, the build agent sends that image to your container registry. The build job now needs to tell the cluster about the new version.

Instead of calling the cluster API, the build agent updates the state repo. It writes the new image tag into a manifest file and commits it. Or, you can let the cluster agent watch the image registry directly. In both setups, the cluster agent reads the desired state from Git. It checks the live cluster state against the state in the repo. When it spots a new tag, it pulls the image and updates the pods.

Identity and keys stay separate across the two tools at all times. Buildkite agents hold write keys for the image registry and state repo. Fluxcd holds read keys for the state repo and write roles inside Kubernetes. Neither tool needs to share its secret keys with the other tool.

Common failure modes and how to scope roles

Many teams make mistakes when they set up keys for these two tools. A common error is using one shared bot account for all repos. If a build runner uses a broad Git token, it can edit anything. An attacker who steals that token can change code across your whole org. Another failure mode happens when teams let build runners talk to Kubernetes directly. They run cluster commands inside the build step right beside git commits. This mixes two different control loops and breaks the GitOps model.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Race conditions also cause pain when two build jobs finish at once. Both jobs try to push a commit to the same state branch. One push fails, and the build turns red even though the image built fine. You can fix this by using a queue step for state repo writes. Only one job in that queue can run at any given moment. You can also let the cluster agent scan the image registry itself. Then the cluster agent writes the new tag back to the state repo.

To scope roles well, give each pipeline its own deploy key. Scope that deploy key to write to only one folder or repo. Never give build agents admin roles inside your production Kubernetes clusters. Inside the cluster, bind each sync controller to a strict Kubernetes role. Put each app in its own namespace with its own service account. Turn on commit signing so the cluster agent checks every commit before syncing. Log every Git push and every sync event in your central log store.

Keeping human cluster checks safe during sync failures

Even with good automation, a bad manifest or crashed pod will block a sync. Engineers then need to check live logs or fix a stuck resource. If you hand out static cluster admin files, you lose your safety gains. Teams should apply the same tight rules to human fixes and debug sessions. Every live check should tie back to a real user identity. Every action should leave a clear log and respect strict data rules. For example, masking can rewrite emails or card numbers in query output.

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 Buildkite push image tags to Git, or should Fluxcd scan the registry?

Both patterns work well in production. Having Buildkite commit the tag gives you a clear step in build logs. Letting Fluxcd scan the registry avoids Git push race conditions on busy branches.

Does Buildkite need network paths to the Kubernetes API server?

No, Buildkite does not need network paths to the cluster API in GitOps. Buildkite only needs to reach your Git host and your container registry. The cluster agent pulls changes from inside the cluster network.

How do we roll back a bad release in this setup?

You roll back by reverting the bad commit in the state Git repo. Once you push the revert commit, the cluster agent detects the change. It then restores the old image tag in the cluster.

The query runs. The emails stay hidden.