Skip to content

Kubernetes Runner Setup

Using the GitLab Kubernetes runner allows your CI jobs to run as pods in a Kubernetes cluster. Nix GitLab CI can be integrated with this setup, and using advanced configuration options like pod_spec makes it easy to add runner specific caching.

Using this Runner configuration ...

[[runners.kubernetes.pod_spec]]
name = "nix-ci-cache-secrets"
patch = '''
  containers:
  - name: build
    envFrom:
    - secretRef:
      name: nix-ci-cache-env
'''

... and a secret containing ...

NIX_CI_RUNNER_CACHE_STRATEGY: attic
ATTIC_SERVER: <in-cluster-url>  # example: http://atticd.<ns>.svc.cluster.local:8080
ATTIC_CACHE: ci  # name however you want, just needs to exist
ATTIC_TOKEN: <token>

... makes your jobs automatically cache their Nix store paths to the in-cluster attic when running with this runner.

Other runners could use cachix or no cache, you get the idea ;P

Note

This of course works with any executor where you can set environment variables. This is just an example how to do it in Kubernetes easily.