From 9fba37540a5dab4bb20ce2d931fa298ad5f132d4 Mon Sep 17 00:00:00 2001 From: Talia Stocks <928827+taliastocks@users.noreply.github.com> Date: Mon, 12 Feb 2024 08:47:09 -0500 Subject: [PATCH] Expose volumeMounts and volumes in gha-runner-scale-set-controller (#3260) --- .../templates/deployment.yaml | 6 +++++ .../tests/template_test.go | 22 +++++++++++++------ .../values.yaml | 4 ++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/charts/gha-runner-scale-set-controller/templates/deployment.yaml b/charts/gha-runner-scale-set-controller/templates/deployment.yaml index 1b857b37de..2a32f525b1 100644 --- a/charts/gha-runner-scale-set-controller/templates/deployment.yaml +++ b/charts/gha-runner-scale-set-controller/templates/deployment.yaml @@ -110,10 +110,16 @@ spec: volumeMounts: - mountPath: /tmp name: tmp + {{- range .Values.volumeMounts }} + - {{ toYaml . | nindent 10 }} + {{- end }} terminationGracePeriodSeconds: 10 volumes: - name: tmp emptyDir: {} + {{- range .Values.volumes }} + - {{ toYaml . | nindent 8 }} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/gha-runner-scale-set-controller/tests/template_test.go b/charts/gha-runner-scale-set-controller/tests/template_test.go index d42c1d43cf..e72e0e37c0 100644 --- a/charts/gha-runner-scale-set-controller/tests/template_test.go +++ b/charts/gha-runner-scale-set-controller/tests/template_test.go @@ -424,10 +424,14 @@ func TestTemplate_ControllerDeployment_Customize(t *testing.T) { "tolerations[0].key": "foo", "affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key": "foo", "affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator": "bar", - "priorityClassName": "test-priority-class", - "flags.updateStrategy": "eventual", - "flags.logLevel": "info", - "flags.logFormat": "json", + "priorityClassName": "test-priority-class", + "flags.updateStrategy": "eventual", + "flags.logLevel": "info", + "flags.logFormat": "json", + "volumes[0].name": "customMount", + "volumes[0].configMap.name": "my-configmap", + "volumeMounts[0].name": "customMount", + "volumeMounts[0].mountPath": "/my/mount/path", }, KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), } @@ -470,9 +474,11 @@ func TestTemplate_ControllerDeployment_Customize(t *testing.T) { assert.Equal(t, int64(1000), *deployment.Spec.Template.Spec.SecurityContext.FSGroup) assert.Equal(t, "test-priority-class", deployment.Spec.Template.Spec.PriorityClassName) assert.Equal(t, int64(10), *deployment.Spec.Template.Spec.TerminationGracePeriodSeconds) - assert.Len(t, deployment.Spec.Template.Spec.Volumes, 1) + assert.Len(t, deployment.Spec.Template.Spec.Volumes, 2) assert.Equal(t, "tmp", deployment.Spec.Template.Spec.Volumes[0].Name) - assert.NotNil(t, 10, deployment.Spec.Template.Spec.Volumes[0].EmptyDir) + assert.NotNil(t, deployment.Spec.Template.Spec.Volumes[0].EmptyDir) + assert.Equal(t, "customMount", deployment.Spec.Template.Spec.Volumes[1].Name) + assert.Equal(t, "my-configmap", deployment.Spec.Template.Spec.Volumes[1].ConfigMap.Name) assert.Len(t, deployment.Spec.Template.Spec.NodeSelector, 1) assert.Equal(t, "bar", deployment.Spec.Template.Spec.NodeSelector["foo"]) @@ -521,9 +527,11 @@ func TestTemplate_ControllerDeployment_Customize(t *testing.T) { assert.True(t, *deployment.Spec.Template.Spec.Containers[0].SecurityContext.RunAsNonRoot) assert.Equal(t, int64(1000), *deployment.Spec.Template.Spec.Containers[0].SecurityContext.RunAsUser) - assert.Len(t, deployment.Spec.Template.Spec.Containers[0].VolumeMounts, 1) + assert.Len(t, deployment.Spec.Template.Spec.Containers[0].VolumeMounts, 2) assert.Equal(t, "tmp", deployment.Spec.Template.Spec.Containers[0].VolumeMounts[0].Name) assert.Equal(t, "/tmp", deployment.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath) + assert.Equal(t, "customMount", deployment.Spec.Template.Spec.Containers[0].VolumeMounts[1].Name) + assert.Equal(t, "/my/mount/path", deployment.Spec.Template.Spec.Containers[0].VolumeMounts[1].MountPath) } func TestTemplate_EnableLeaderElectionRole(t *testing.T) { diff --git a/charts/gha-runner-scale-set-controller/values.yaml b/charts/gha-runner-scale-set-controller/values.yaml index 3a63c829a9..43b797404d 100644 --- a/charts/gha-runner-scale-set-controller/values.yaml +++ b/charts/gha-runner-scale-set-controller/values.yaml @@ -72,6 +72,10 @@ tolerations: [] affinity: {} +# Mount volumes in the container. +volumes: [] +volumeMounts: [] + # Leverage a PriorityClass to ensure your pods survive resource shortages # ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ # PriorityClass: system-cluster-critical