How the GitLab agent for Kubernetes connects clusters you control to GitLab
The GitLab agent for Kubernetes connects a cluster to a self-managed GitLab without opening the cluster API to inbound traffic from GitLab. You install the agent inside the cluster, and the agent makes outbound connections to GitLab. That matters when a platform team runs clusters behind corporate firewalls or NAT, because the agent can reach API endpoints in real time and push cluster event information back to GitLab while the cluster keeps its inbound posture. The agent is the supported method for this pattern, so it is the starting point for any deployment design on this page.
Plan for one agent per cluster, with each agent registered in a GitLab project. The registration project is where the agent's configuration lives and where access rules are attached, so a shared agent across clusters would blur which project controls which cluster. Confirm with your GitLab administrator that your self-managed edition and tier include the agent. The agent is available on the Free, Premium and Ultimate tiers for GitLab Self-Managed, so tier choice does not block the agent itself, but it does affect which CI/CD and security features your teams get around it. Check the current tier table in the GitLab documentation on connecting a Kubernetes cluster before you commit to a model.
Before you install anything, decide which project owns each agent registration and who may change that project's configuration. Treat the registration project as a privileged control point, because whoever can edit its agent configuration can influence what the cluster accepts from GitLab. Record the cluster name, the registering project, the namespaces the agent may reach and the people who approve changes. Then confirm your network path: the agent needs outbound reachability to your GitLab instance, and your firewall or proxy team should approve that flow and the GitLab hostname it uses. Your GitLab version and the agent version should be checked against your cluster's Kubernetes version and your upgrade schedule, since the agent becomes one more component to upgrade alongside GitLab and the cluster.
What you need before installing the agent
The agent connects two systems that each have their own version and network rules, so most delays come from prerequisites rather than from the install itself. Confirm the GitLab side, the cluster side and the network path before scheduling work, and record the versions you will use. Each card below is one item to settle first.
Self-managed GitLab version and upgrade stops
Confirm the GitLab release your instance runs and whether it is on a supported line. GitLab maintains a small set of recent minor lines, and bug fixes reach only the current stable release, so an instance that lags behind may not get fixes. Upgrades must pass through required upgrade stops, which since GitLab 17.5 fall at versions x.2, x.5, x.8 and x.11. Plan any upgrade before the agent work, because agent behavior depends on the server version.
GitLab upgrade pathsAgent version compatibility with your release
The agent is released separately from the GitLab server, so the agent image or chart version must match what your GitLab release supports. Check the compatibility statement in the GitLab documentation for your exact release before you pull the agent into the cluster. Record both versions in your change ticket so a later server upgrade triggers a matching agent check.
GitLab agent docsSupported Kubernetes version
Choose a Kubernetes minor version that is still maintained when you go live, because the project maintains only the three most recent minor releases. Check the end-of-life dates on the release page before you commit to a version. Keep control plane and node versions within the version skew policy so the agent talks to a supported API server.
- Maintained minor releases
- 3
Flux minimum patch versions
If the cluster will run Flux for GitOps, check the minimum patch level for your Kubernetes minor version. The Flux install guide requires 1.34.1 or later for Kubernetes 1.34, 1.35.0 for 1.35, and 1.36.0 for 1.36 and later, and advises against running end-of-life Kubernetes versions in production. Pick a patch release that meets these floors before the bootstrap step.
Flux installation guideOutbound network path from cluster to GitLab
The agent works from inside the cluster and opens an outbound connection to your GitLab instance, so no inbound firewall rule to the cluster is needed. Confirm that nodes can reach the GitLab hostname over the required ports, that any proxy or NAT rules allow the traffic, and that TLS trust for your internal certificate authority is in place. Test name resolution and certificate validation from a pod, not only from a node.
Offline or air-gapped plan
If the cluster or GitLab has no internet access, decide early how images, charts and Flux artifacts will reach the environment. GitLab documents offline installation and separate guidance for security scanners, and Flux documents air-gapped installation. Confirm with your GitLab and Flux documentation which artifacts must be mirrored, and plan registry access for the agent image before the install window.
GitLab offline environmentsHow to register and install one agent per cluster
This sequence takes one Kubernetes cluster from no GitLab connection to a registered, connected agent that can reach the cluster from behind its firewall. Repeat it for each cluster, since GitLab recommends one agent per cluster.
Choose the agent project and group
The platform owner decides which GitLab group and project will hold the agent registration for each cluster. Keep the agent configuration in a project that only the platform team can maintain, because whoever can change that project controls what the agent is allowed to do. Confirm the group structure first, since access to the agent is scoped by group and project membership. Done when the team has written down the project path and the cluster name it will use, and the project exists on your self-managed instance.
Register the cluster agent in GitLab
In the chosen project, the platform engineer creates an agent configuration entry named for the cluster, for example by adding the agent definition in the project's Kubernetes agent settings. GitLab records the agent against that project, which is why the one-agent-per-cluster pattern keeps each cluster's permissions separate. Check the GitLab documentation for your version to confirm the exact menu path, since the interface changes between releases. Done when the agent name appears in the project's list of registered agents.
Generate the agent token
After registration, GitLab issues an agent token that the in-cluster agent uses to authenticate back to your GitLab instance. Store it as a secret in your own vault or CI variable store, not in a shared document or chat thread, because anyone holding the token can run the agent's connection. Confirm the token has been created and copied once, since GitLab may not show it again. Done when the token is stored in the location your team uses for cluster secrets.
Install the agent into the cluster
A cluster administrator applies the installation manifest or Helm chart that GitLab generates for the registered agent, using the token from the previous step and the GitLab server address for your self-managed instance. The agent runs as an outbound connection from inside the cluster, so the cluster does not need to accept inbound connections from GitLab. Make sure your cluster can reach the GitLab instance on the network path you have approved, and that any private certificate authority is trusted by the agent. Done when the install command completes without errors.
Confirm the pod is running in the agent namespace
Before checking GitLab, the cluster administrator checks that the agent workload is running in the namespace the installation created, using kubectl to list pods and read their logs. Logs that show repeated authentication or certificate errors point to a token, URL or trust problem that should be fixed before moving on. Confirm the pod is in a Running state with no restart loop. Done when the agent pod is ready and its logs show a successful connection attempt.
Verify the agent shows as connected in GitLab
Return to the agent entry in the GitLab project and confirm its status shows the agent as connected, along with the last contact time. This is the check that proves the outbound link works end to end, and it is the signal to use before granting CI/CD access. If the status stays disconnected, review the agent pod logs and confirm the token matches the registration. Done when GitLab reports the agent as connected for this cluster, and the team records the agent name against the cluster in its inventory.
Choosing between GitLab CI/CD access and Flux GitOps
The agent for Kubernetes supports two delivery paths into the same cluster, and choosing between them is a change control decision before it is a technical one. In the first path, CI/CD jobs in GitLab use the agent's Kubernetes context to apply manifests or run deployments, so a pipeline pushes changes to the cluster when it runs. In the second, Flux runs inside the cluster and pulls desired state from Git, so the cluster reconciles itself toward what is committed. Both can coexist, but a workload managed by both will fight over its state, so each namespace or application should have one owner.
Flux is the pull-based option. It integrates with GitLab, supports multiple Git repositories, and uses Kubernetes RBAC with impersonation so each reconciliation runs with the permissions of a service account you scope to a namespace. That design lets the platform team limit what a single application repository can change without giving a pipeline cluster-wide credentials. Flux can be installed with flux bootstrap, with the Flux Terraform provider, or with the Flux Operator, and its installation guide documents an air-gapped install, which matters if the cluster cannot reach public registries. Confirm which of these methods your team will operate and which Flux version your Kubernetes minor release supports before you commit to a design.
Before you choose, confirm three things with your change board and security team: who may trigger a deployment (protected branches, approvers, or pipeline roles), whether a pipeline with agent access may write to production namespaces, and how rollbacks are recorded. If every change must be traceable to a reviewed commit, Flux's pull model usually fits better. If releases are gated by pipeline stages and manual approvals, CI/CD access is simpler to audit in place. Many teams use CI/CD for build and test and Flux for production apply, and document that split in the project registration.
How GitLab groups, projects and agent access map to cluster permissions
This table compares each GitLab access point, from group membership to CI job tokens, with the Kubernetes identity and scope it produces in a cluster. Read it when deciding which GitLab object should be allowed to touch which namespace, and confirm every access configuration key against the agent documentation before you rely on it.
| Access point | What it grants in GitLab | What the cluster sees and how to scope it |
|---|---|---|
| Agent registration project | Holds the agent configuration and defines which projects and groups may use the agent for cluster access | The agent connects outbound from inside the cluster; scope is set by the configuration in this project, so restrict who has maintainer rights on it |
| Group membership | Users inherit access to projects in the group and its subgroups according to their role | Group role does not automatically equal Kubernetes permission; confirm which group-level access keys the agent honors and whether they map to RBAC |
| Project membership | Developers, maintainers and owners of a project gain its CI/CD and environment access | A deploying job acts through the agent under the scope granted to that project, not under the personal identity of the user who pushed the change |
| CI job token | A short-lived token issued to a pipeline job, limited to the project's permitted access | Use it to reach the cluster only where the agent authorizes the project; confirm token scope and expiry in the agent documentation |
| Environments | Named deployment targets such as staging or production, with their own access and approval rules | Map each environment to a single namespace or a narrow set of namespaces, and bind a Kubernetes Role to the identity the agent presents |
| Kubernetes namespace and RBAC | Defines what the cluster identity can read or change in each namespace | Grant the narrowest verbs and resources; avoid cluster-wide roles for project pipelines and review any binding that allows secret access |
| Illustrative: shared group with many projects | One group feeds several projects into one cluster | Test whether projects in the group can reach namespaces they do not own; a single agent authorization may be broader than intended |
Scoping access across groups and protecting the agent token
The agent gives a GitLab project a direct path into a cluster, so who can use it, who can edit its configuration and how its token is stored decide how far a compromise would reach. The cards below cover the controls that bound that reach, from the agent's Kubernetes permissions to the cluster settings that protect the secrets it touches.
Least-privilege RBAC for the agent
The agent authenticates to the Kubernetes API through a service account, and the RBAC bound to it sets the ceiling for every project that uses the agent. Grant only the verbs and namespaces each deployment path needs, and avoid binding cluster-admin for convenience. Check the bindings with the cluster's own tools after each agent upgrade, since the permissions your pipelines depend on are easy to widen by accident.
GitLab agent docsRestricting which projects use the agent
Access configuration in the agent's registration decides which GitLab projects and groups can reach the cluster through it. Limit authorization to the groups that own the workloads, and review it when teams or repositories change. A project that is not authorized should have no path to the cluster, even if its maintainers can edit CI files.
GitLab authentication docsTreating the agent token as a secret
The agent token is the credential that lets the in-cluster agent connect back to GitLab, so anyone holding it can impersonate the agent. Store it in a Kubernetes Secret, avoid copying it into chat, tickets or CI variables, and rotate it when a person with access leaves or a host is exposed. Confirm in the current GitLab documentation how a token is revoked and replaced before you need to do it under pressure.
Separating production and non-production agents
Register a separate agent for each cluster instead of sharing one agent across environments, which keeps a staging pipeline from reaching production by mistake. Keep production agent registrations in a group with a narrower membership and stricter approval rules. This follows GitLab's guidance of one agent per cluster and makes access reviews easier to scope.
Reviewing who changes the agent configuration
The agent configuration project holds the settings that define what the agent can access, so changes to it are as sensitive as changes to cluster RBAC. Require merge request review by someone outside the deploying team, restrict maintainer rights on that project, and log every change. Audit the project's membership on a fixed schedule, not only when a problem appears.
Pod Security Standards and encryption at rest
Deployments that arrive through the agent still run under the cluster's own controls. Enforce a Pod Security Standards level per namespace with Pod Security Admission, and configure encryption at rest for Secrets, because Kubernetes stores them unencrypted in etcd by default. Check both against the CIS Kubernetes Benchmark before production use, and confirm the settings on your distribution.
- Built-in Pod Security levels
- 3
How to test the connection before production deployments
Before any production pipeline depends on the agent, prove the path end to end in a non-production namespace. Install the agent in a test cluster, register it in the GitLab project, and run a pipeline that applies a harmless ConfigMap through the agent's Kubernetes access. Then repeat the check after every firewall or NAT change, because the agent connects outbound from inside the cluster and the test confirms that the required outbound route still works. Confirm that the agent reports as connected in GitLab and that a deliberate failure, such as a wrong namespace, produces a clear job error rather than a silent success. Ask your network team to document the exact destinations the agent needs so the test can be rerun when the perimeter changes.
Test the failure paths as well as the success path. Rotate the agent token in a test environment, then confirm the agent stops authenticating, that jobs fail visibly, and that the replacement token restores access with the same cluster registration. Next, check the scope boundary: run CI jobs from a project in a group that should not have access, and confirm they cannot reach namespaces outside the allowed list. The agent's access rules are set in the GitLab configuration for the agent, so review them in the same session and keep the results as evidence for your access review. If you deploy with Flux, install it in the test cluster, point it at a test repository, confirm that it reconciles a change, and then edit a live resource by hand to confirm that Flux reports the drift and restores the declared state.
Plan GitLab backups before the first production pipeline runs, since agent registrations, project settings and CI configuration live in the instance. Follow the GitLab backup and restore documentation to define backup frequency, storage location and retention, and rehearse a restore on a separate instance. Confirm which pieces your backup covers, particularly repository data and the secrets that the instance needs to decrypt stored values, and record where those secrets are kept. Ask your GitLab administrator to confirm the restore steps for your installation method and version, because the procedure depends on how the instance was deployed.
Why the agent shows disconnected or deployments fail
This table lists the failures teams hit most often when the GitLab agent or Flux stops reporting or cannot deploy, with the likely cause and the fix for each. Work down the rows in order, because agent connectivity and token problems are usually the first thing to rule out before looking at permissions or versions.
| Symptom | Likely cause | Fix |
|---|---|---|
| Agent shows disconnected | The agent token is wrong, expired, or was revoked in the GitLab project that registered the cluster. | Confirm the token in the registered project, check the agent logs in the cluster, then issue a new token and update the agent's Kubernetes secret before restarting the agent pod. |
| Agent cannot reach GitLab | Outbound egress from the cluster is blocked by a firewall, NAT rule or corporate proxy, so the agent cannot open its outbound connection. | Allow outbound connections from the agent to your GitLab host on the required port, or configure the proxy settings the agent needs. Test from a pod inside the cluster, not from a workstation. |
| Pipelines or syncs are refused for a project or group | The agent is not authorized for the project or group that is trying to use it, so access checks fail even though the agent is connected. | Add the project or group to the agent's authorization configuration in the project that registered the agent, then rerun the job. Keep the list as narrow as the teams that need the cluster. |
| Deployments fail with forbidden errors | The service account bound to the agent or Flux lacks RBAC permissions for the resources the workload creates, often because roles were scoped to a single namespace. | Review the error for the resource and verb that was denied, then grant the narrowest role that covers it in the target namespace. Avoid cluster-admin as a shortcut. |
| Flux controllers crash or refuse to reconcile | The Kubernetes cluster runs a patch version below the minimum that the Flux installation guide lists for the Flux release in use. | Check the cluster's patch version against the minimum listed for your Kubernetes minor version, patch the control plane and nodes, and confirm the Flux release supports that version before upgrading. |
| Agent and GitLab behave inconsistently after an upgrade | The GitLab instance and the agent image are on versions that do not match the agent compatibility guidance for the release in use. | Upgrade GitLab first when required, then update the agent image to a matching version and confirm both in the agent's logs and the GitLab UI. Plan the GitLab upgrade stops before changing the agent. |
| Agent or Flux pods fail to start in an air-gapped cluster | The agent, Flux controller or helper images are missing from the internal registry, so the cluster cannot pull them. | Mirror every image the agent and Flux manifests reference into the private registry, update the image references to that registry, and confirm pull secrets are present in the namespace. |
| Flux cannot read the Git repository | The repository credentials or deploy keys were rotated or scoped to a different project, or the network path to the GitLab host changed. | Confirm the credential's scope and expiry in GitLab, regenerate the secret the source controller uses, and test reachability from inside the cluster. |
How the agent, GitLab and clusters fit together
The diagram starts inside the cluster, where the agent for Kubernetes opens an outbound connection to self-managed GitLab, so no inbound firewall rule is needed. Requests from GitLab CI jobs and the agent reach the Kubernetes API through that connection, while Flux runs in the cluster and pulls its configuration from Git. Check that the trust boundary matches your network policy and that each cluster has its own agent registered to its own GitLab project.
Outbound agent connection and scoped access paths from GitLab into a firewalled cluster.
Questions buyers ask before connecting GitLab to their clusters
Which GitLab tier do we need for the agent and its CI/CD access?
The Kubernetes agent is available on the Free, Premium and Ultimate tiers for GitLab.com, GitLab Self-Managed and GitLab Dedicated, so the agent itself does not force a tier upgrade. The tier question is about the surrounding features. The GitLab pricing page lists advanced CI/CD and priority support for Premium, and application security testing, software supply chain security, vulnerability management and compliance features for Ultimate. Premium costs 29 US dollars per user per month billed annually, while Ultimate is custom priced. Decide which of those features your compliance and delivery workflows need, then request a quote for each tier in writing, including who pays for support and how seat counts change as teams grow.
How much does it cost to run GitLab ourselves and connect clusters?
Cost has three parts: GitLab licensing for each user on a paid tier, the infrastructure that hosts GitLab, and the labor to install, operate and upgrade it. Self-managed GitLab is free to install on the Free tier, but the infrastructure and staff time are yours to plan. Upgrades are a recurring cost because GitLab requires upgrades to pass through required upgrade stops, which fall at versions such as 18.2, 18.5 and 19.2 according to the GitLab upgrade paths documentation. Ask any partner for a quote that separates one-time setup from recurring operations, names who holds the admin credentials, and states what is excluded, such as runner capacity or backup storage.
How long does connecting clusters to GitLab take?
The duration depends mostly on three things: the number of clusters, the time needed for network and security approvals, and how access is designed across groups and projects. Each cluster needs its own agent registered in a GitLab project, so a platform with many clusters repeats that work, though the pattern is the same each time. Firewall or NAT rules that allow outbound connectivity from the cluster to GitLab often take longer to approve than the technical install. We do not publish a fixed duration for this work. Ask for a timeline that lists the cluster count, the approval steps with their owners, and the access model that must be agreed before work starts.
What do we need to provide before the work starts?
The work needs three groups of people in place. A GitLab administrator must grant the rights to create agent registrations and projects, and must confirm the instance's version and installation method. A cluster administrator must authorize the agent install and confirm the Kubernetes version and RBAC model. A network and security team must approve outbound connectivity from each cluster to the GitLab instance and sign off on the credentials and permissions the agent receives. Agree on the owner for each approval before scoping, because delays there are the most common reason the schedule slips.
Can our own team connect clusters to GitLab without a partner?
Yes, a team with GitLab administration and Kubernetes skills can install the agent and register projects by following the GitLab documentation. The harder part is the design work: deciding which groups and projects can reach which clusters, how CI/CD jobs authenticate, and how the agent's permissions are limited. Teams that already run Kubernetes and GitLab often do the install in-house and bring in a partner only for the access model, hardening or a review. Before deciding, check whether your team has time for approvals, testing and the upgrades that follow, and whether the people who would own the setup are available after go-live.
How does one agent per cluster scale as we add clusters?
GitLab recommends one agent per cluster, and each agent is registered in a GitLab project. Scaling therefore means adding one agent for each new cluster, with a repeatable registration pattern, consistent naming and a clear record of which project owns which agent. Each agent makes outbound connections, so new clusters also need their own network approvals. Ask for a plan that shows how the agent configuration is stored, how access is granted across groups, and how the team will track agents when clusters are retired or rebuilt.
Should we use Flux or GitLab CI/CD to deploy to clusters?
Use GitLab CI/CD when you want pipelines to push changes to a cluster as part of a build and release process, with the agent giving jobs access to the API. Use Flux when you want the cluster to pull desired state from Git and keep it in sync, which Flux does with a pull-based design and least-privilege access. Flux integrates with GitLab and supports Helm, Kustomize and OCI artifacts. Many teams use both, with CI/CD building and testing images and Flux applying declared state. Decide based on who should be able to change production, how drift should be handled, and how audit evidence will be produced.
Official GitLab and Flux documentation to read next
Start with the GitLab agent documentation before you install anything, because it defines the registration and connection model your design depends on: one agent per cluster, each registered in a GitLab project, with the agent opening the outbound connection so clusters behind a firewall or NAT can still be reached. Read the sections on agent configuration and CI/CD access closely, then confirm with your GitLab administrator which tier and deployment type your instance runs, since the agent is listed for Free, Premium and Ultimate on Self-Managed. The Connecting a Kubernetes cluster with GitLab guide is the reference for the exact configuration keys and project settings you will need.
If your GitLab or clusters have no route to the public internet, read the offline environments guidance next. It covers running self-managed GitLab in air-gapped networks and calls out separate steps for security scanners and GitLab Duo Self-Hosted, so check which of those features you plan to use and whether their offline setup changes the agent's image sources or package mirrors. Treat this as a checklist to confirm with your own network team, not as a guarantee that every integration works offline in your environment. The GitLab documentation on offline environments is the natural next read here.
For the GitOps layer, read the Flux documentation to understand how the source, kustomize and helm controllers use Kubernetes RBAC with impersonation, which is the mechanism that decides what each tenant's reconciliation can change. Map each GitLab group and project you plan to sync to a Flux source and a service account, and confirm that those accounts carry only the namespace permissions they need. Then read the Flux installation guide before choosing flux bootstrap, the Flux Terraform provider or the Flux Operator, and check its minimum supported Kubernetes patch versions against the cluster versions you plan to run. The Flux documentation and the Flux installation guide are the two pages to bookmark for the build.
How DeployOpen scopes and delivers GitLab agent connections
DeployOpen plans, installs and documents GitLab agent connections for Kubernetes clusters inside the client's own infrastructure. Each engagement starts with a written scope that names the clusters, GitLab groups and projects, and the deployment paths the agents will serve, so access decisions are agreed before any agent is installed.
How we scope
- Inventory the clusters, their network boundaries and which ones sit behind firewalls or NAT, since the agent connects outward from the cluster.
- Map GitLab groups, subgroups and projects to the clusters and namespaces each team may deploy into, and record who approves changes.
- Agree in writing whether Flux will run GitOps sync, whether CI/CD jobs will use the agent, and which Kubernetes versions are in scope.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts. Ongoing support is available as a retainer.
How we build
- Register one agent per cluster in its GitLab project, then install it with the chart and configuration settings agreed in the scope.
- Configure CI/CD access through the agent and test that jobs can reach only the namespaces the scope permits.
- Set up Flux against the agreed repositories with least-privilege Kubernetes RBAC, and test impersonation and multi-tenancy boundaries.
- Verify behavior in a test environment, including connection recovery after a network interruption and a deliberate denied-access check.
How we hand over
- Deliver a written record of agent registrations, access groups, RBAC bindings, Flux sources and the approval path for each environment.
- Document the upgrade sequence for GitLab, the agent and Flux, including GitLab's required upgrade stops and Kubernetes version support.
- Walk platform and security teams through the access model and the runbook for rotating agent tokens and removing a cluster.
How we support
- Offer retainers for ongoing support, upgrades of the agent and Flux, and periodic review of group and project access as teams change.
- Retest access boundaries after material changes to groups, clusters or GitLab versions, and report findings with fixes.
- Confirm with your GitLab tier and vendor documentation which agent features your installation includes before the scope is signed.

