From 2d69e9bb9ab5e22b2f9aa3fed80361a9266653b8 Mon Sep 17 00:00:00 2001 From: Borislav Velkov Date: Wed, 11 Dec 2024 16:16:53 +0200 Subject: [PATCH 1/3] feat(helm): move dind to sidecar --- charts/gha-runner-scale-set/templates/_helpers.tpl | 11 +++++++++++ .../templates/autoscalingrunnerset.yaml | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/charts/gha-runner-scale-set/templates/_helpers.tpl b/charts/gha-runner-scale-set/templates/_helpers.tpl index bd71ed64c9..7cc9af4cc3 100644 --- a/charts/gha-runner-scale-set/templates/_helpers.tpl +++ b/charts/gha-runner-scale-set/templates/_helpers.tpl @@ -54,6 +54,14 @@ app.kubernetes.io/name: {{ include "gha-runner-scale-set.scale-set-name" . }} app.kubernetes.io/instance: {{ include "gha-runner-scale-set.scale-set-name" . }} {{- end }} +{{/* +Check if the Kubernetes version supports native sidecar containers (>=1.29). +*/}} +{{- define "gha-runner-scale-set.isK8sVersionGte129" -}} +{{- $version := .Capabilities.KubeVersion.Version -}} +{{- semverCompare ">=1.29.0" $version -}} +{{- end }} + {{- define "gha-runner-scale-set.githubsecret" -}} {{- if kindIs "string" .Values.githubConfigSecret }} {{- if not (empty .Values.githubConfigSecret) }} @@ -106,6 +114,9 @@ env: value: "123" securityContext: privileged: true +{{- if include "gha-runner-scale-set.isK8sVersionGte129" . }} +restartPolicy: Always +{{- end }} volumeMounts: - name: work mountPath: /home/runner/_work diff --git a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml index 39ebfef800..153b544994 100644 --- a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml +++ b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml @@ -127,6 +127,10 @@ spec: - name: init-dind-externals {{- include "gha-runner-scale-set.dind-init-container" . | nindent 8 }} {{- end }} + {{- if include "gha-runner-scale-set.isK8sVersionGte129" . }} + - name: dind + {{- include "gha-runner-scale-set.dind-container" . | nindent 8 }} + {{- end }} {{- with .Values.template.spec.initContainers }} {{- toYaml . | nindent 6 }} {{- end }} @@ -134,9 +138,11 @@ spec: containers: {{- if eq $containerMode.type "dind" }} - name: runner - {{- include "gha-runner-scale-set.dind-runner-container" . | nindent 8 }} + {{- include "gha-runner-scale-set.dind-runner-container" . | nindent 8 }} {{- if include "gha-runner-scale-set.isK8sVersionGte129" . }} + {{- if not (include "gha-runner-scale-set.isK8sVersionGte129" .) }} - name: dind {{- include "gha-runner-scale-set.dind-container" . | nindent 8 }} + {{- end }} {{- include "gha-runner-scale-set.non-runner-non-dind-containers" . | nindent 6 }} {{- else if eq $containerMode.type "kubernetes" }} - name: runner From db9c2aa08459eb521eac630c37c32378c52a8f88 Mon Sep 17 00:00:00 2001 From: Borislav Velkov Date: Wed, 11 Dec 2024 19:02:25 +0200 Subject: [PATCH 2/3] chore: copy paste error --- charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml index 153b544994..356b63f476 100644 --- a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml +++ b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml @@ -138,7 +138,7 @@ spec: containers: {{- if eq $containerMode.type "dind" }} - name: runner - {{- include "gha-runner-scale-set.dind-runner-container" . | nindent 8 }} {{- if include "gha-runner-scale-set.isK8sVersionGte129" . }} + {{- include "gha-runner-scale-set.dind-runner-container" . | nindent 8 }} {{- if not (include "gha-runner-scale-set.isK8sVersionGte129" .) }} - name: dind {{- include "gha-runner-scale-set.dind-container" . | nindent 8 }} From 71647e1a4586bdf425ed72315944ca9d78ec4464 Mon Sep 17 00:00:00 2001 From: Borislav Velkov Date: Thu, 12 Dec 2024 11:58:07 +0200 Subject: [PATCH 3/3] chore: switch from template to normal condition --- charts/gha-runner-scale-set/templates/_helpers.tpl | 10 +--------- .../templates/autoscalingrunnerset.yaml | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/charts/gha-runner-scale-set/templates/_helpers.tpl b/charts/gha-runner-scale-set/templates/_helpers.tpl index 7cc9af4cc3..4f693b1f5d 100644 --- a/charts/gha-runner-scale-set/templates/_helpers.tpl +++ b/charts/gha-runner-scale-set/templates/_helpers.tpl @@ -54,14 +54,6 @@ app.kubernetes.io/name: {{ include "gha-runner-scale-set.scale-set-name" . }} app.kubernetes.io/instance: {{ include "gha-runner-scale-set.scale-set-name" . }} {{- end }} -{{/* -Check if the Kubernetes version supports native sidecar containers (>=1.29). -*/}} -{{- define "gha-runner-scale-set.isK8sVersionGte129" -}} -{{- $version := .Capabilities.KubeVersion.Version -}} -{{- semverCompare ">=1.29.0" $version -}} -{{- end }} - {{- define "gha-runner-scale-set.githubsecret" -}} {{- if kindIs "string" .Values.githubConfigSecret }} {{- if not (empty .Values.githubConfigSecret) }} @@ -114,7 +106,7 @@ env: value: "123" securityContext: privileged: true -{{- if include "gha-runner-scale-set.isK8sVersionGte129" . }} +{{- if (ge (.Capabilities.KubeVersion.Minor | int) 29) }} restartPolicy: Always {{- end }} volumeMounts: diff --git a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml index 356b63f476..fed80336d4 100644 --- a/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml +++ b/charts/gha-runner-scale-set/templates/autoscalingrunnerset.yaml @@ -127,7 +127,7 @@ spec: - name: init-dind-externals {{- include "gha-runner-scale-set.dind-init-container" . | nindent 8 }} {{- end }} - {{- if include "gha-runner-scale-set.isK8sVersionGte129" . }} + {{- if (ge (.Capabilities.KubeVersion.Minor | int) 29) }} - name: dind {{- include "gha-runner-scale-set.dind-container" . | nindent 8 }} {{- end }} @@ -139,7 +139,7 @@ spec: {{- if eq $containerMode.type "dind" }} - name: runner {{- include "gha-runner-scale-set.dind-runner-container" . | nindent 8 }} - {{- if not (include "gha-runner-scale-set.isK8sVersionGte129" .) }} + {{- if not (ge (.Capabilities.KubeVersion.Minor | int) 29) }} - name: dind {{- include "gha-runner-scale-set.dind-container" . | nindent 8 }} {{- end }}