GitLab runner on Kubernetes¶
StageFreight on GitLab's Kubernetes executor, with no Docker daemon: non-root job pods with a read-only root filesystem, a shared cache volume, and a rootless buildkitd for image builds.
| File | Provides |
|---|---|
values.yaml |
the runner, for the gitlab/gitlab-runner Helm chart: job pod security, cache and BuildKit mounts, per-job scratch volume |
kustomization.yaml |
everything beside the runner, applied with kubectl apply -k |
serviceaccount.yaml |
the job pods' identity, with no API access |
cache.yaml |
the shared cache, a ReadWriteMany volume mounted at /stagefreight |
buildkitd.yaml · buildkitd.toml |
rootless buildkitd, its build cache volume and GC budget |
buildkitd-certificates.yaml |
BuildKit's own mTLS PKI, from cert-manager |
Before you begin¶
- cert-manager is installed in the cluster.
- A ReadWriteMany storage class (CephFS, NFS, …) for the cache, and a ReadWriteOnce class for buildkitd and job scratch.
- Nodes allow user namespaces for rootless buildkitd.
buildkitd.yamlruns it Unconfined as BuildKit's example does; a cluster enforcing restricted Pod Security needs a namespace exemption or Localhost seccomp/AppArmor profiles that grant only namespace creation. - A registered runner and its
glrt-…token.
Deploy¶
- Create the namespace and the runner token Secret:
kubectl create namespace gitlab-runner kubectl -n gitlab-runner create secret generic gitlab-runner \ --from-literal=runner-token=RUNNER_TOKEN \ --from-literal=runner-registration-token=RUNNER_TOKENis theglrt-…token. The chart mounts both keys; the legacy registration token stays empty. - Set the storage classes:
storageClassNameincache.yamland thebuildkitd-stateclaim inbuildkitd.yaml, andjobScratch.storageClassinvalues.yaml. To use another namespace, change it inkustomization.yamland in thebuildkitdcertificate's DNS names. - Apply the cache, buildkitd and its certificates:
- Install the runner, with
gitlabUrlinvalues.yamlset to your instance:
Verify¶
- buildkitd is ready and its certificates are issued:
buildkitd-0is1/1 Running, andbuildkit-ca,buildkitdandbuildkit-clientareTrue. - The runner shows as online under Settings → CI/CD → Runners.
- Run a pipeline. No
cache root … can't write itwarning appears in the job log.
Without a daemon¶
Everything runs as it does on a Docker runner:
- Images build into the content store and publish promotes, signs and attests them.
- A kind: command (or builder-image) step runs inside the job when its image is the CI image, and as a BuildKit build otherwise.
- A crucible build verifies both passes from OCI layouts.
- Ansible converge runs natively when the job image ships ansible-playbook and ssh-agent; otherwise reconcile is refused at preflight.
Two things need a daemon and are skipped or refused without one: provider: local registries,
and Compose docker_local targets.
The job pods need enough memory for the audition's test run; the Executor panel reports headroom
under the job's own memory limit. A job may run as another uid (run_as_user, run_as_group):
any uid works, as long as fs_group gives it write access to the cache.