reworking controller chart

This commit is contained in:
Nikola Jokic 2026-02-05 14:28:42 +01:00
parent d6ab193085
commit 3616911adb
No known key found for this signature in database
GPG Key ID: 419BB425B0E501B0
7 changed files with 115 additions and 58 deletions

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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: