The Simplest Way to Make Crossplane and Gitlab Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using crossplane and gitlab together lets teams build cloud resources from source code. You store resource files in Gitlab, and Crossplane reads them to create cloud systems. This workflow turns your code repo into the single source of truth. Teams review changes in merge requests before any cloud change happens. When a lead approves the merge, the pipeline sends the files to the cluster. Then the cluster controller talks to the cloud API and builds the new items. How crossplane and gitlab pa

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 crossplane and gitlab together lets teams build cloud resources from source code. You store resource files in Gitlab, and Crossplane reads them to create cloud systems.

This workflow turns your code repo into the single source of truth. Teams review changes in merge requests before any cloud change happens. When a lead approves the merge, the pipeline sends the files to the cluster. Then the cluster controller talks to the cloud API and builds the new items.

How crossplane and gitlab pass identity and data

Data flows from your code repo to your cluster during a pipeline run. A developer writes a manifest file and pushes it to a branch. The pipeline checks the syntax and waits for a peer review. After approval, a runner sends the file to the Kubernetes API server.

To do this, the runner must log in to the cluster. The best way is to use open standards for token exchange. Gitlab issues a short job token for each pipeline run. The cluster checks this token against the repo URL and branch name. If they match your rules, the cluster accepts the change.

You can also use Crossplane to manage Gitlab items like repos and group roles. In that setup, the flow goes the other way. The cluster needs a key to talk to the Gitlab API. A provider pod inside the cluster reads this key from a secret store. It then calls the API to create projects or set branch rules. It checks the state in a loop and fixes any drift it finds.

Common failure modes and how to scope roles

Many teams fail by using one big admin token for all pipeline jobs. They create a static key that never expires and paste it into settings. If an attacker steals that key, they can delete the whole cluster. Static keys also make it hard to see who ran a command. All logs just show the name of the shared bot account.

Another common bug happens when both tools try to change the same setting. A runner might update a project rule while the cluster tries to revert it. This creates a loop that eats up your API rate limits. You must pick one tool to own each specific resource type.

Crossplane Composition Security + GitLab CI Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix token risks, give each repo its own tiny role. Map each pipeline job to a specific Kubernetes role with tight limits. A frontend repo should only touch its own namespace. It should never have the power to build new cloud networks or databases.

When the cluster calls out to the Gitlab API, scope that token too. Do not use a personal key from a human admin. If that person leaves the company, your whole automation setup will break. Instead, use a group bot account with access only to the target group. Rotate that token on a set schedule so old keys cannot leak.

Keeping network paths and audit logs clean

Network paths between your runners and your cluster need strict rules. Do not open your Kubernetes API server to the whole public internet. Run your build agents inside your private cloud network. Let them talk to the cluster over a private link or peering route. This blocks outside attackers from probing your cluster port.

You also need clear logs for every change across both systems. Turn on Kubernetes audit logs to see which job token changed which resource. Match those cluster logs with your pipeline job IDs. When an outage happens, you can trace the bad change back to the exact commit. You can also mask emails or card numbers in log output to protect user data.

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

Should we push files from pipelines or pull them from the cluster?

Pulling from the cluster with a sync agent is safer for most teams. It keeps cluster keys out of your pipeline runners. If you push from jobs, use short tokens instead of static keys.

How do we stop API rate limit errors between the two tools?

Make sure only one system owns each resource setting. Increase the poll wait time on your cluster provider so it checks less often. Group small changes into fewer commits to cut down on pipeline runs.

What happens if someone changes a setting in the web UI by hand?

The cluster controller will spot the difference during its next check. It will overwrite the manual change to match the code in your repo. This keeps your setup clean and stops secret drift.

The query runs. The emails stay hidden.