The Simplest Way to Make Bitbucket and Cilium Work Like They Should
Teams use bitbucket and cilium to push code and lock down cluster traffic. Bitbucket runs your build pipelines, while Cilium enforces network rules between your pods. This pair lets developers ship network policy updates right from version control. Every git push can update both your app code and your cluster security rules. Without good controls, a bad push can break pod traffic or expose cluster keys. You need a clear plan to link your build jobs with your cluster network. How bitbucket and
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 bitbucket and cilium to push code and lock down cluster traffic. Bitbucket runs your build pipelines, while Cilium enforces network rules between your pods.
This pair lets developers ship network policy updates right from version control. Every git push can update both your app code and your cluster security rules. Without good controls, a bad push can break pod traffic or expose cluster keys. You need a clear plan to link your build jobs with your cluster network.
How bitbucket and cilium share keys and data
Bitbucket stores your app code, cluster manifests, and network rule files in git repos. When a developer merges code, a Bitbucket pipeline starts a new runner job. This runner needs to talk to your Kubernetes API to apply the new rules.
First, the runner logs in to the cluster using a service key or token. Good setups use OpenID Connect so the runner gets a short-lived token per build. The cluster checks this token and assigns a specific role to the runner job.
Next, the runner sends the updated manifests to the cluster API server. Cilium watches the API server for any changes to network policy objects. When Cilium sees a new rule, it compiles a program for the Linux kernel. It loads this program into the kernel to filter packets at the pod level. Data flows from the git repo to the cluster API, and then to Cilium.
You can also run policy checks inside the pipeline before the cluster step. The build job reads the policy files and checks the syntax for mistakes. This stops broken rules before they ever reach the live cluster nodes.
Common failure modes and how to scope roles
Many teams fail by giving the Bitbucket runner a full cluster admin role. If an attacker steals that token, they can read secrets or delete every pod. Shared service accounts also make it hard to see who changed a network rule. Cluster logs will only show the shared runner name instead of the real developer.
End-to-End Encryption + Cilium Network Policies: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Broad network paths create another big risk for your build runners. Cloud runners often use wide IP ranges that change on every single job. If you open your cluster API to the whole internet, attackers will probe it. If you lock it down too much, the Bitbucket job fails to reach it.
To fix permissions, give each repo its own role inside the cluster. Scope that role so the runner can only write network rules in one namespace. Never let a standard app pipeline edit global cluster rules or system namespaces. Keep cluster-wide network rules in a separate repo managed by the platform team.
You must also watch out for drop rules that lock out the runner itself. A bad network rule can block pods from talking to DNS or external APIs. Test new rules in a staging namespace and check flow logs for dropped packets. Make sure every pipeline run logs the exact git commit and user identity. When you mask sensitive data in logs, rewrite emails, phone numbers, or card numbers.
Testing network rules in your build pipeline
Waiting until production to test network rules causes outages for your users. A small typo in a label can block your web app from its database. You can catch these errors early by running a test cluster during the build.
Your Bitbucket runner can spin up a small local cluster inside the build job. It installs Cilium and applies your app manifests along with the new network rules. Then the pipeline runs a quick test to check if pods can talk. If the database ping fails, the pipeline stops and alerts the developer right away. Only passing builds can move forward to update the live production cluster.
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
How should Bitbucket runners log in to a Kubernetes cluster?
Use OpenID Connect to link your Bitbucket workspace with your cloud or cluster identity provider. This setup gives each pipeline job a short-lived token instead of a static key.
Can a Bitbucket pipeline lock itself out through a Cilium rule?
Yes, a bad egress rule can block self-hosted runners that run inside the same cluster. Always add a baseline rule that lets runner pods reach Bitbucket and the cluster API.
How do we track who changed a Cilium network policy?
Require pull request approvals in Bitbucket and log the commit hash during every deployment job. Match the git commit log with Kubernetes audit logs to see the exact user.
Related guides
In this post