A deploy to a Kubernetes cluster from GitLab: agent or kubeconfig?

AdvancedScenarioGitLab CI
Answer

Situation read → Cluster connectivity choice.

What I'd do →

  1. Prefer the GitLab agent for Kubernetes: the in-cluster agent opens an outbound tunnel, so no cluster API exposure to runners.
  2. Grant CI access with ci_access in the agent config, and bind to namespaced RBAC.
  3. In jobs: kubectl config use-context group/project:agent-name then kubectl apply.
  4. Or use pull-based GitOps with Flux and the agent's Flux integration.

Why → Outbound-only connections are safer than kubeconfig secrets in CI.

Interview tip → Push CI deploy vs pull GitOps is a standard trade-off question.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI