From 3616911adbd6cd57e6ead8266d2274b93a4525ad Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Thu, 5 Feb 2026 14:28:42 +0100 Subject: [PATCH] reworking controller chart --- .../templates/_controller_template.tpl | 8 +-- .../templates/deployment.yaml | 20 ++++++-- ...ller_deployment_extra_containers_test.yaml | 21 ++++---- ...ller_deployment_pod_extra_fields_test.yaml | 22 ++++---- ...troller_deployment_volume_mounts_test.yaml | 25 +++++++++ .../controller_deployment_volumes_test.yaml | 26 ++++++++++ .../values.yaml | 51 +++++++++---------- 7 files changed, 115 insertions(+), 58 deletions(-) create mode 100644 charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volume_mounts_test.yaml create mode 100644 charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volumes_test.yaml diff --git a/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl b/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl index 9cde6375..6cf073ff 100644 --- a/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl +++ b/charts/gha-runner-scale-set-controller-experimental/templates/_controller_template.tpl @@ -115,12 +115,8 @@ securityContext: volumeMounts: - mountPath: /tmp name: tmp - {{- with .Values.controller.manager.container.extraVolumeMounts }} - {{- range . }} - - {{- toYaml . | nindent 4 }} - {{- end }} - {{- end }} - {{- range .Values.controller.pod.extraVolumeMounts }} + {{- $podVolumeMounts := (.Values.controller.pod.volumeMounts | default list) -}} + {{- range $podVolumeMounts }} - {{- toYaml . | nindent 4 }} {{- end }} {{- end }} \ No newline at end of file diff --git a/charts/gha-runner-scale-set-controller-experimental/templates/deployment.yaml b/charts/gha-runner-scale-set-controller-experimental/templates/deployment.yaml index 13b55176..2a5e1c95 100644 --- a/charts/gha-runner-scale-set-controller-experimental/templates/deployment.yaml +++ b/charts/gha-runner-scale-set-controller-experimental/templates/deployment.yaml @@ -17,6 +17,16 @@ spec: labels: {{- include "gha-controller-template.labels" . | nindent 8 }} spec: + {{- $pod := (.Values.controller.pod | default dict) -}} + {{- if and (hasKey .Values.controller "pod") (not (kindIs "map" $pod)) -}} + {{- fail "controller.pod must be an object" -}} + {{- end -}} + {{- $podSpec := (index $pod "spec" | default dict) -}} + {{- if and (hasKey $pod "spec") (not (kindIs "map" $podSpec)) -}} + {{- fail "controller.pod.spec must be an object" -}} + {{- end -}} + + {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} @@ -25,18 +35,20 @@ spec: containers: - {{- include "gha-controller-template.manager-container" . | nindent 10 }} - {{- range .Values.controller.pod.containers }} + {{- $extraContainers := (index $podSpec "containers" | default list) -}} + {{- range $extraContainers }} - {{- toYaml . | nindent 10 }} {{- end }} - terminationGracePeriodSeconds: {{ default 10 .Values.controller.pod.terminationGracePeriodSeconds }} + terminationGracePeriodSeconds: {{ default 10 (index $podSpec "terminationGracePeriodSeconds") }} volumes: - name: tmp emptyDir: {} - {{- range .Values.controller.pod.extraVolumes }} + {{- $podVolumes := (index $podSpec "volumes" | default list) -}} + {{- range $podVolumes }} - {{- toYaml . | nindent 10 }} {{- end }} - {{- $runnerPodSpecExtraFields := (omit .Values.controller.pod "containers" "serviceAccountName" "terminationGracePeriodSeconds") -}} + {{- $runnerPodSpecExtraFields := (omit $podSpec "containers" "serviceAccountName" "terminationGracePeriodSeconds" "volumes") -}} {{- if gt (len $runnerPodSpecExtraFields) 0 }} {{- toYaml $runnerPodSpecExtraFields | nindent 6 }} {{- end }} \ No newline at end of file diff --git a/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_extra_containers_test.yaml b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_extra_containers_test.yaml index a3d033e4..2b504a88 100644 --- a/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_extra_containers_test.yaml +++ b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_extra_containers_test.yaml @@ -6,16 +6,17 @@ tests: set: controller: pod: - containers: - - name: "sidecar" - image: "busybox:1.36" - command: - - "sh" - - "-c" - args: - - "echo hello && sleep 3600" - - name: "another" - image: "alpine:3.19" + spec: + containers: + - name: "sidecar" + image: "busybox:1.36" + command: + - "sh" + - "-c" + args: + - "echo hello && sleep 3600" + - name: "another" + image: "alpine:3.19" release: name: "test-name" namespace: "test-namespace" diff --git a/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_pod_extra_fields_test.yaml b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_pod_extra_fields_test.yaml index 246a4dcb..bc15523d 100644 --- a/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_pod_extra_fields_test.yaml +++ b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_pod_extra_fields_test.yaml @@ -6,15 +6,16 @@ tests: set: controller: pod: - nodeSelector: - kubernetes.io/os: linux - tolerations: - - key: "dedicated" - operator: "Equal" - value: "arc" - effect: "NoSchedule" - hostNetwork: true - dnsPolicy: "ClusterFirstWithHostNet" + spec: + nodeSelector: + kubernetes.io/os: linux + tolerations: + - key: "dedicated" + operator: "Equal" + value: "arc" + effect: "NoSchedule" + hostNetwork: true + dnsPolicy: "ClusterFirstWithHostNet" release: name: "test-name" namespace: "test-namespace" @@ -39,7 +40,8 @@ tests: set: controller: pod: - serviceAccountName: "hacker-sa" + spec: + serviceAccountName: "hacker-sa" release: name: "test-name" namespace: "test-namespace" diff --git a/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volume_mounts_test.yaml b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volume_mounts_test.yaml new file mode 100644 index 00000000..9ed4d0fd --- /dev/null +++ b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volume_mounts_test.yaml @@ -0,0 +1,25 @@ +suite: "Controller Deployment volume mounts" +templates: + - deployment.yaml +tests: + - it: should append controller.pod.volumeMounts to manager container + set: + controller: + manager: + container: + image: "ghcr.io/actions/gha-runner-scale-set-controller:latest" + pod: + volumeMounts: + - name: my-config + mountPath: /etc/my-config + readOnly: true + release: + name: "test-name" + namespace: "test-namespace" + asserts: + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: + name: my-config + mountPath: /etc/my-config + readOnly: true diff --git a/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volumes_test.yaml b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volumes_test.yaml new file mode 100644 index 00000000..c3361207 --- /dev/null +++ b/charts/gha-runner-scale-set-controller-experimental/tests/controller_deployment_volumes_test.yaml @@ -0,0 +1,26 @@ +suite: "Controller Deployment volumes" +templates: + - deployment.yaml +tests: + - it: should append controller.pod.spec.volumes to pod spec volumes + set: + controller: + manager: + container: + image: "ghcr.io/actions/gha-runner-scale-set-controller:latest" + pod: + spec: + volumes: + - name: my-config + configMap: + name: my-config + release: + name: "test-name" + namespace: "test-namespace" + asserts: + - contains: + path: spec.template.spec.volumes + content: + name: my-config + configMap: + name: my-config diff --git a/charts/gha-runner-scale-set-controller-experimental/values.yaml b/charts/gha-runner-scale-set-controller-experimental/values.yaml index 899313ac..9023b0be 100644 --- a/charts/gha-runner-scale-set-controller-experimental/values.yaml +++ b/charts/gha-runner-scale-set-controller-experimental/values.yaml @@ -55,8 +55,6 @@ controller: securityContext: {} # Container-level resource requests/limits. resources: {} - # Additional volume mounts on the manager container. - extraVolumeMounts: [] # Extra container ports (metrics port is derived from controller.metrics). extraPorts: [] @@ -74,34 +72,31 @@ controller: metadata: labels: {} annotations: {} - spec: {} - # Pod-level security context. - securityContext: {} - # Pod priority class name. - priorityClassName: "" - # Node selection constraints. - nodeSelector: {} - # Pod tolerations. - tolerations: [] - # Pod affinity. - affinity: {} - # Pod topology spread constraints. - topologySpreadConstraints: [] - # Pod termination grace period (overrides default 10s). - terminationGracePeriodSeconds: null - # Extra volumes appended to the default ones. - extraVolumes: [] - # Extra volume mounts appended to the default ones. - extraVolumeMounts: [] + # PodSpec fields applied to spec.template.spec. + # Note: containers provided here are appended after the built-in manager container. + spec: + # Pod-level security context. + securityContext: {} + # Pod priority class name. + priorityClassName: "" + # Node selection constraints. + nodeSelector: {} + # Pod tolerations. + tolerations: [] + # Pod affinity. + affinity: {} + # Pod topology spread constraints. + topologySpreadConstraints: [] + # Pod termination grace period (overrides default 10s). + terminationGracePeriodSeconds: null + # Additional volumes appended to the default ones. + volumes: [] + # Additional containers appended after the manager container. + containers: [] - # Raw extra podSpec fields to be merged into spec.template.spec. - # Example: - # extraSpec: - # hostAliases: - # - ip: "127.0.0.1" - # hostnames: ["example.local"] - extraSpec: {} + # Additional volume mounts appended to the manager container's default ones. + volumeMounts: [] # Metrics configuration. If omitted, metrics are disabled. # metrics: