Skip to content

Cannot configure Kubernetes Affinity rules of Runner in main Helm chart

Summary

I would like to set affinity rules like mentioned here but it will not work. For example:

gitlab-runner:
  install: true
  runners:
    config: |
      [[runners]]
        [runners.kubernetes]
          [runners.kubernetes.affinity]
            [runners.kubernetes.affinity.node_affinity]
              [[runners.kubernetes.affinity.node_affinity.preferred_during_scheduling_ignored_during_execution]]
                weight = 100
                [runners.kubernetes.affinity.node_affinity.preferred_during_scheduling_ignored_during_execution.preference]
                  [[runners.kubernetes.affinity.node_affinity.preferred_during_scheduling_ignored_during_execution.preference.match_expressions]]
                    key = "node_pool"
                    operator = "In"
                    values = ["preemtible"]

I tested it using gitlab/gitlab-runner chart and I could reproduce the same problem. However, in order to fix it, I had to use the default approach to affinity rules, which is by setting affinity: {} on its values.yaml file, line 490.

I would like to have this option added in the main GitLab chart, and update the docs accordingly. PS: I tried it now and it is working, it just needs documentation on the values.yaml side.

Steps to reproduce

Install GitLab Helm chart with runners enabled and follow the docs to enable affinity rules for the Runners deployment

Current behavior

No Affinity rules added to the Runner deployment

Expected behavior

Affinity rules to be added

Versions

  • Chart: 7.8.1
  • Platform:
    • Cloud: GKE
  • Kubernetes:
    • Client:v1.29.1
    • Server: v1.25.16-gke.1268000
  • Helm:
    • Client: v3.14.0