2023-01-17 14:36:04 -05:00
{{ /*
Expand the name of the chart .
*/ }}
2023-08-21 15:36:14 +02:00
{{ - define "gha-base-name" - }}
gha-rs
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.name" - }}
2023-08-21 15:36:14 +02:00
{{ - default ( include "gha-base-name" .) . Values . nameOverride | trunc 63 | trimSuffix "-" }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-09-26 11:17:04 +02:00
{{ - define "gha-runner-scale-set.scale-set-name" - }}
{{ . Values . runnerScaleSetName | default . Release . Name }}
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ /*
Create a default fully qualified app name .
We truncate at 63 chars because some Kubernetes name fields are limited to this ( by the DNS naming spec ).
If release name contains chart name it will be used as a full name .
*/ }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.fullname" - }}
2023-08-21 15:36:14 +02:00
{{ - $name := default ( include "gha-base-name" .) }}
2023-09-26 11:17:04 +02:00
{{ - printf "%s-%s" ( include "gha-runner-scale-set.scale-set-name" .) $name | trunc 63 | trimSuffix "-" }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ /*
Create chart name and version as used by the chart label .
*/ }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.chart" - }}
2023-08-21 15:36:14 +02:00
{{ - printf "%s-%s" ( include "gha-base-name" .) . Chart . Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ /*
Common labels
*/ }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.labels" - }}
helm.sh/chart: {{ include "gha-runner-scale-set.chart" . }}
{{ include "gha-runner-scale-set.selectorLabels" . }}
2023-01-17 14:36:04 -05:00
{{ - if . Chart . AppVersion }}
app.kubernetes.io/version: {{ . Chart . AppVersion | quote }}
{{ - end }}
app.kubernetes.io/managed-by: {{ . Release . Service }}
2023-08-09 11:11:45 +02:00
app.kubernetes.io/part-of: gha-rs
2023-09-26 11:17:04 +02:00
actions.github.com/scale-set-name: {{ include "gha-runner-scale-set.scale-set-name" . }}
2023-04-03 21:06:12 +02:00
actions.github.com/scale-set-namespace: {{ . Release . Namespace }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ /*
Selector labels
*/ }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.selectorLabels" - }}
2023-09-26 11:17:04 +02:00
app.kubernetes.io/name: {{ include "gha-runner-scale-set.scale-set-name" . }}
app.kubernetes.io/instance: {{ include "gha-runner-scale-set.scale-set-name" . }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.githubsecret" - }}
2023-01-31 17:04:03 -05:00
{{ - if kindIs "string" . Values . githubConfigSecret }}
{{ - if not ( empty . Values . githubConfigSecret ) }}
{{ - . Values . githubConfigSecret }}
{{ - else }}
{{ - fail "Values.githubConfigSecret is required for setting auth with GitHub server." }}
{{ - end }}
{{ - else }}
2023-03-01 13:16:03 +01:00
{{ - include "gha-runner-scale-set.fullname" . }} -github-secret
2023-01-31 17:04:03 -05:00
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.noPermissionServiceAccountName" - }}
2023-06-27 19:32:47 +09:00
{{ - include "gha-runner-scale-set.fullname" . }} -no-permission
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.kubeModeRoleName" - }}
2023-08-09 11:11:45 +02:00
{{ - include "gha-runner-scale-set.fullname" . }} -kube-mode
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-04-03 21:06:12 +02:00
{{ - define "gha-runner-scale-set.kubeModeRoleBindingName" - }}
2023-08-09 11:11:45 +02:00
{{ - include "gha-runner-scale-set.fullname" . }} -kube-mode
2023-04-03 21:06:12 +02:00
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.kubeModeServiceAccountName" - }}
2023-06-27 19:32:47 +09:00
{{ - include "gha-runner-scale-set.fullname" . }} -kube-mode
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.dind-init-container" - }}
2023-03-16 09:21:43 -04:00
{{ - range $i , $val := . Values . template . spec . containers }}
{{ - if eq $val.name "runner" }}
2023-01-17 14:36:04 -05:00
image: {{ $val.image }}
command: ["cp"]
2023-03-10 06:18:21 -05:00
args: ["-r", "-v", "/home/runner/externals/.", "/home/runner/tmpDir/"]
2023-01-17 14:36:04 -05:00
volumeMounts:
- name: dind-externals
2023-03-10 06:18:21 -05:00
mountPath: /home/runner/tmpDir
2023-03-16 09:21:43 -04:00
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.dind-container" - }}
2023-01-17 14:36:04 -05:00
image: docker:dind
2023-09-22 13:41:50 +03:00
args:
- dockerd
2024-03-18 12:40:27 +01:00
- --host=unix:///var/run/docker.sock
2023-09-22 13:41:50 +03:00
- --group=$(DOCKER_GROUP_GID)
env:
- name: DOCKER_GROUP_GID
value: "123"
2023-01-17 14:36:04 -05:00
securityContext:
privileged: true
volumeMounts:
- name: work
2023-03-10 06:18:21 -05:00
mountPath: /home/runner/_work
2023-09-22 13:41:50 +03:00
- name: dind-sock
2024-03-18 12:40:27 +01:00
mountPath: /var/run
2023-01-17 14:36:04 -05:00
- name: dind-externals
2023-03-10 06:18:21 -05:00
mountPath: /home/runner/externals
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.dind-volume" - }}
2023-09-22 13:41:50 +03:00
- name: dind-sock
2023-01-17 14:36:04 -05:00
emptyDir: {}
- name: dind-externals
emptyDir: {}
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - define "gha-runner-scale-set.tls-volume" - }}
- name: github-server-tls-cert
configMap:
name: {{ . certificateFrom . configMapKeyRef . name }}
items:
- key: {{ . certificateFrom . configMapKeyRef . key }}
path: {{ . certificateFrom . configMapKeyRef . key }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.dind-work-volume" - }}
2023-01-17 14:36:04 -05:00
{{ - $createWorkVolume := 1 }}
{{ - range $i , $volume := . Values . template . spec . volumes }}
{{ - if eq $volume.name "work" }}
2023-03-16 09:21:43 -04:00
{{ - $createWorkVolume = 0 }}
2023-03-10 06:18:21 -05:00
- {{ $volume | toYaml | nindent 2 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - if eq $createWorkVolume 1 }}
- name: work
emptyDir: {}
{{ - end }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.kubernetes-mode-work-volume" - }}
2023-01-17 14:36:04 -05:00
{{ - $createWorkVolume := 1 }}
{{ - range $i , $volume := . Values . template . spec . volumes }}
{{ - if eq $volume.name "work" }}
2023-03-16 09:21:43 -04:00
{{ - $createWorkVolume = 0 }}
2023-03-10 06:18:21 -05:00
- {{ $volume | toYaml | nindent 2 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - if eq $createWorkVolume 1 }}
- name: work
ephemeral:
volumeClaimTemplate:
spec:
{{ - . Values . containerMode . kubernetesModeWorkVolumeClaim | toYaml | nindent 8 }}
{{ - end }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.non-work-volumes" - }}
2023-01-17 14:36:04 -05:00
{{ - range $i , $volume := . Values . template . spec . volumes }}
{{ - if ne $volume.name "work" }}
2023-03-09 17:23:32 +00:00
- {{ $volume | toYaml | nindent 2 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.non-runner-containers" - }}
2023-03-16 09:21:43 -04:00
{{ - range $i , $container := . Values . template . spec . containers }}
{{ - if ne $container.name "runner" }}
- {{ $container | toYaml | nindent 2 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-17 04:26:51 -04:00
{{ - define "gha-runner-scale-set.non-runner-non-dind-containers" - }}
{{ - range $i , $container := . Values . template . spec . containers }}
{{ - if and ( ne $container.name "runner" ) ( ne $container.name "dind" ) }}
- {{ $container | toYaml | nindent 2 }}
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.dind-runner-container" - }}
2023-03-09 17:23:32 +00:00
{{ - $tlsConfig := ( default ( dict ) . Values . githubServerTLS ) }}
2023-03-16 09:21:43 -04:00
{{ - range $i , $container := . Values . template . spec . containers }}
{{ - if eq $container.name "runner" }}
2023-01-17 14:36:04 -05:00
{{ - range $key , $val := $container }}
{{ - if and ( ne $key "env" ) ( ne $key "volumeMounts" ) ( ne $key "name" ) }}
2023-03-16 09:21:43 -04:00
{{ $key }} : {{ $val | toYaml | nindent 2 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - $setDockerHost := 1 }}
2023-02-15 17:29:56 -05:00
{{ - $setRunnerWaitDocker := 1 }}
2023-03-09 17:23:32 +00:00
{{ - $setNodeExtraCaCerts := 0 }}
{{ - $setRunnerUpdateCaCerts := 0 }}
{{ - if $tlsConfig.runnerMountPath }}
{{ - $setNodeExtraCaCerts = 1 }}
{{ - $setRunnerUpdateCaCerts = 1 }}
{{ - end }}
2023-01-17 14:36:04 -05:00
env:
{{ - with $container.env }}
{{ - range $i , $env := . }}
{{ - if eq $env.name "DOCKER_HOST" }}
2023-03-16 09:21:43 -04:00
{{ - $setDockerHost = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-02-15 17:29:56 -05:00
{{ - if eq $env.name "RUNNER_WAIT_FOR_DOCKER_IN_SECONDS" }}
2023-03-16 09:21:43 -04:00
{{ - $setRunnerWaitDocker = 0 }}
2023-02-15 17:29:56 -05:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if eq $env.name "NODE_EXTRA_CA_CERTS" }}
2023-03-16 09:21:43 -04:00
{{ - $setNodeExtraCaCerts = 0 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - if eq $env.name "RUNNER_UPDATE_CA_CERTS" }}
2023-03-16 09:21:43 -04:00
{{ - $setRunnerUpdateCaCerts = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-16 09:21:43 -04:00
- {{ $env | toYaml | nindent 4 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-02-15 14:29:52 -05:00
{{ - end }}
{{ - if $setDockerHost }}
2023-01-17 14:36:04 -05:00
- name: DOCKER_HOST
2024-03-18 12:40:27 +01:00
value: unix:///var/run/docker.sock
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-02-15 17:29:56 -05:00
{{ - if $setRunnerWaitDocker }}
- name: RUNNER_WAIT_FOR_DOCKER_IN_SECONDS
value: "120"
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if $setNodeExtraCaCerts }}
- name: NODE_EXTRA_CA_CERTS
value: {{ clean ( print $tlsConfig.runnerMountPath "/" $tlsConfig.certificateFrom.configMapKeyRef.key ) }}
{{ - end }}
{{ - if $setRunnerUpdateCaCerts }}
- name: RUNNER_UPDATE_CA_CERTS
value: "1"
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ - $mountWork := 1 }}
{{ - $mountDindCert := 1 }}
2023-03-09 17:23:32 +00:00
{{ - $mountGitHubServerTLS := 0 }}
{{ - if $tlsConfig.runnerMountPath }}
{{ - $mountGitHubServerTLS = 1 }}
{{ - end }}
2023-01-17 14:36:04 -05:00
volumeMounts:
{{ - with $container.volumeMounts }}
{{ - range $i , $volMount := . }}
{{ - if eq $volMount.name "work" }}
2023-03-16 09:21:43 -04:00
{{ - $mountWork = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-09-22 13:41:50 +03:00
{{ - if eq $volMount.name "dind-sock" }}
2023-03-16 09:21:43 -04:00
{{ - $mountDindCert = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if eq $volMount.name "github-server-tls-cert" }}
2023-03-16 09:21:43 -04:00
{{ - $mountGitHubServerTLS = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-16 09:21:43 -04:00
- {{ $volMount | toYaml | nindent 4 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - if $mountWork }}
- name: work
2023-03-10 06:18:21 -05:00
mountPath: /home/runner/_work
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - if $mountDindCert }}
2023-09-22 13:41:50 +03:00
- name: dind-sock
2024-03-18 12:40:27 +01:00
mountPath: /var/run
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if $mountGitHubServerTLS }}
- name: github-server-tls-cert
mountPath: {{ clean ( print $tlsConfig.runnerMountPath "/" $tlsConfig.certificateFrom.configMapKeyRef.key ) }}
subPath: {{ $tlsConfig.certificateFrom.configMapKeyRef.key }}
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-01 13:16:03 +01:00
{{ - define "gha-runner-scale-set.kubernetes-mode-runner-container" - }}
2023-03-09 17:23:32 +00:00
{{ - $tlsConfig := ( default ( dict ) . Values . githubServerTLS ) }}
2023-03-16 09:21:43 -04:00
{{ - range $i , $container := . Values . template . spec . containers }}
{{ - if eq $container.name "runner" }}
2023-01-17 14:36:04 -05:00
{{ - range $key , $val := $container }}
{{ - if and ( ne $key "env" ) ( ne $key "volumeMounts" ) ( ne $key "name" ) }}
2023-03-16 09:21:43 -04:00
{{ $key }} : {{ $val | toYaml | nindent 2 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - $setContainerHooks := 1 }}
{{ - $setPodName := 1 }}
{{ - $setRequireJobContainer := 1 }}
2023-03-09 17:23:32 +00:00
{{ - $setNodeExtraCaCerts := 0 }}
{{ - $setRunnerUpdateCaCerts := 0 }}
{{ - if $tlsConfig.runnerMountPath }}
{{ - $setNodeExtraCaCerts = 1 }}
{{ - $setRunnerUpdateCaCerts = 1 }}
{{ - end }}
2023-01-17 14:36:04 -05:00
env:
{{ - with $container.env }}
{{ - range $i , $env := . }}
{{ - if eq $env.name "ACTIONS_RUNNER_CONTAINER_HOOKS" }}
2023-03-16 09:21:43 -04:00
{{ - $setContainerHooks = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - if eq $env.name "ACTIONS_RUNNER_POD_NAME" }}
2023-03-16 09:21:43 -04:00
{{ - $setPodName = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - if eq $env.name "ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER" }}
2023-03-16 09:21:43 -04:00
{{ - $setRequireJobContainer = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if eq $env.name "NODE_EXTRA_CA_CERTS" }}
2023-03-16 09:21:43 -04:00
{{ - $setNodeExtraCaCerts = 0 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - if eq $env.name "RUNNER_UPDATE_CA_CERTS" }}
2023-03-16 09:21:43 -04:00
{{ - $setRunnerUpdateCaCerts = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-16 09:21:43 -04:00
- {{ $env | toYaml | nindent 4 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - if $setContainerHooks }}
- name: ACTIONS_RUNNER_CONTAINER_HOOKS
2023-03-10 06:18:21 -05:00
value: /home/runner/k8s/index.js
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - if $setPodName }}
- name: ACTIONS_RUNNER_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{ - end }}
{{ - if $setRequireJobContainer }}
- name: ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER
value: "true"
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if $setNodeExtraCaCerts }}
- name: NODE_EXTRA_CA_CERTS
value: {{ clean ( print $tlsConfig.runnerMountPath "/" $tlsConfig.certificateFrom.configMapKeyRef.key ) }}
{{ - end }}
{{ - if $setRunnerUpdateCaCerts }}
- name: RUNNER_UPDATE_CA_CERTS
value: "1"
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ - $mountWork := 1 }}
2023-03-09 17:23:32 +00:00
{{ - $mountGitHubServerTLS := 0 }}
{{ - if $tlsConfig.runnerMountPath }}
{{ - $mountGitHubServerTLS = 1 }}
{{ - end }}
2023-01-17 14:36:04 -05:00
volumeMounts:
{{ - with $container.volumeMounts }}
{{ - range $i , $volMount := . }}
{{ - if eq $volMount.name "work" }}
2023-03-16 09:21:43 -04:00
{{ - $mountWork = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if eq $volMount.name "github-server-tls-cert" }}
2023-03-16 09:21:43 -04:00
{{ - $mountGitHubServerTLS = 0 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-16 09:21:43 -04:00
- {{ $volMount | toYaml | nindent 4 }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
{{ - if $mountWork }}
- name: work
2023-03-10 06:18:21 -05:00
mountPath: /home/runner/_work
2023-01-17 14:36:04 -05:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - if $mountGitHubServerTLS }}
- name: github-server-tls-cert
mountPath: {{ clean ( print $tlsConfig.runnerMountPath "/" $tlsConfig.certificateFrom.configMapKeyRef.key ) }}
subPath: {{ $tlsConfig.certificateFrom.configMapKeyRef.key }}
{{ - end }}
2023-01-17 14:36:04 -05:00
{{ - end }}
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - define "gha-runner-scale-set.default-mode-runner-containers" - }}
{{ - $tlsConfig := ( default ( dict ) . Values . githubServerTLS ) }}
2023-03-16 09:21:43 -04:00
{{ - range $i , $container := . Values . template . spec . containers }}
{{ - if ne $container.name "runner" }}
2023-03-09 17:23:32 +00:00
- {{ $container | toYaml | nindent 2 }}
{{ - else }}
- name: {{ $container.name }}
{{ - range $key , $val := $container }}
{{ - if and ( ne $key "env" ) ( ne $key "volumeMounts" ) ( ne $key "name" ) }}
2023-03-16 09:21:43 -04:00
{{ $key }} : {{ $val | toYaml | nindent 4 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - end }}
{{ - $setNodeExtraCaCerts := 0 }}
{{ - $setRunnerUpdateCaCerts := 0 }}
{{ - if $tlsConfig.runnerMountPath }}
{{ - $setNodeExtraCaCerts = 1 }}
{{ - $setRunnerUpdateCaCerts = 1 }}
{{ - end }}
2023-12-18 16:01:34 +01:00
{{ - $mountGitHubServerTLS := 0 }}
{{ - if or $container.env $setNodeExtraCaCerts $setRunnerUpdateCaCerts }}
2023-03-09 17:23:32 +00:00
env:
{{ - with $container.env }}
{{ - range $i , $env := . }}
{{ - if eq $env.name "NODE_EXTRA_CA_CERTS" }}
2023-03-16 09:21:43 -04:00
{{ - $setNodeExtraCaCerts = 0 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - if eq $env.name "RUNNER_UPDATE_CA_CERTS" }}
2023-03-16 09:21:43 -04:00
{{ - $setRunnerUpdateCaCerts = 0 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
2023-03-16 09:21:43 -04:00
- {{ $env | toYaml | nindent 6 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - end }}
{{ - if $setNodeExtraCaCerts }}
- name: NODE_EXTRA_CA_CERTS
value: {{ clean ( print $tlsConfig.runnerMountPath "/" $tlsConfig.certificateFrom.configMapKeyRef.key ) }}
{{ - end }}
{{ - if $setRunnerUpdateCaCerts }}
- name: RUNNER_UPDATE_CA_CERTS
value: "1"
{{ - end }}
{{ - if $tlsConfig.runnerMountPath }}
{{ - $mountGitHubServerTLS = 1 }}
{{ - end }}
2023-12-18 16:01:34 +01:00
{{ - end }}
{{ - if or $container.volumeMounts $mountGitHubServerTLS }}
2023-03-09 17:23:32 +00:00
volumeMounts:
{{ - with $container.volumeMounts }}
{{ - range $i , $volMount := . }}
{{ - if eq $volMount.name "github-server-tls-cert" }}
2023-03-16 09:21:43 -04:00
{{ - $mountGitHubServerTLS = 0 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
2023-03-16 09:21:43 -04:00
- {{ $volMount | toYaml | nindent 6 }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - end }}
{{ - if $mountGitHubServerTLS }}
- name: github-server-tls-cert
mountPath: {{ clean ( print $tlsConfig.runnerMountPath "/" $tlsConfig.certificateFrom.configMapKeyRef.key ) }}
subPath: {{ $tlsConfig.certificateFrom.configMapKeyRef.key }}
{{ - end }}
2023-12-18 16:01:34 +01:00
{{ - end }}
2023-03-09 17:23:32 +00:00
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-14 09:45:44 -04:00
{{ - define "gha-runner-scale-set.managerRoleName" - }}
2023-08-09 11:11:45 +02:00
{{ - include "gha-runner-scale-set.fullname" . }} -manager
2023-03-14 09:45:44 -04:00
{{ - end }}
2023-04-03 21:06:12 +02:00
{{ - define "gha-runner-scale-set.managerRoleBindingName" - }}
2023-08-09 11:11:45 +02:00
{{ - include "gha-runner-scale-set.fullname" . }} -manager
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - define "gha-runner-scale-set.managerServiceAccountName" - }}
{{ - $searchControllerDeployment := 1 }}
{{ - if . Values . controllerServiceAccount }}
{{ - if . Values . controllerServiceAccount . name }}
{{ - $searchControllerDeployment = 0 }}
{{ - . Values . controllerServiceAccount . name }}
{{ - end }}
{{ - end }}
{{ - if eq $searchControllerDeployment 1 }}
2023-03-14 10:52:25 -04:00
{{ - $multiNamespacesCounter := 0 }}
{{ - $singleNamespaceCounter := 0 }}
2023-03-14 09:45:44 -04:00
{{ - $controllerDeployment := dict }}
2023-03-14 10:52:25 -04:00
{{ - $singleNamespaceControllerDeployments := dict }}
2023-03-14 09:45:44 -04:00
{{ - $managerServiceAccountName := "" }}
{{ - range $index , $deployment := ( lookup "apps/v1" "Deployment" "" "" ). items }}
2023-03-14 10:52:25 -04:00
{{ - if kindIs "map" $deployment.metadata.labels }}
2023-08-09 11:11:45 +02:00
{{ - if eq ( get $deployment.metadata.labels "app.kubernetes.io/part-of" ) "gha-rs-controller" }}
2023-03-14 10:52:25 -04:00
{{ - if hasKey $deployment.metadata.labels "actions.github.com/controller-watch-single-namespace" }}
{{ - $singleNamespaceCounter = add $singleNamespaceCounter 1 }}
{{ - $_ := set $singleNamespaceControllerDeployments ( get $deployment.metadata.labels "actions.github.com/controller-watch-single-namespace" ) $deployment }}
{{ - else }}
{{ - $multiNamespacesCounter = add $multiNamespacesCounter 1 }}
{{ - $controllerDeployment = $deployment }}
{{ - end }}
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-14 10:52:25 -04:00
{{ - if and ( eq $multiNamespacesCounter 0 ) ( eq $singleNamespaceCounter 0 ) }}
2023-08-09 11:11:45 +02:00
{{ - fail "No gha-rs-controller deployment found using label (app.kubernetes.io/part-of=gha-rs-controller). Consider setting controllerServiceAccount.name in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 09:45:44 -04:00
{{ - end }}
2023-03-14 10:52:25 -04:00
{{ - if and ( gt $multiNamespacesCounter 0 ) ( gt $singleNamespaceCounter 0 ) }}
2023-08-09 11:11:45 +02:00
{{ - fail "Found both gha-rs-controller installed with flags.watchSingleNamespace set and unset in cluster, this is not supported. Consider setting controllerServiceAccount.name in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 09:45:44 -04:00
{{ - end }}
2023-03-14 10:52:25 -04:00
{{ - if gt $multiNamespacesCounter 1 }}
2023-08-09 11:11:45 +02:00
{{ - fail "More than one gha-rs-controller deployment found using label (app.kubernetes.io/part-of=gha-rs-controller). Consider setting controllerServiceAccount.name in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 10:52:25 -04:00
{{ - end }}
{{ - if eq $multiNamespacesCounter 1 }}
{{ - with $controllerDeployment.metadata }}
{{ - $managerServiceAccountName = ( get $controllerDeployment.metadata.labels "actions.github.com/controller-service-account-name" ) }}
{{ - end }}
{{ - else if gt $singleNamespaceCounter 0 }}
{{ - if hasKey $singleNamespaceControllerDeployments . Release . Namespace }}
{{ - $controllerDeployment = get $singleNamespaceControllerDeployments . Release . Namespace }}
{{ - with $controllerDeployment.metadata }}
{{ - $managerServiceAccountName = ( get $controllerDeployment.metadata.labels "actions.github.com/controller-service-account-name" ) }}
{{ - end }}
{{ - else }}
2023-08-09 11:11:45 +02:00
{{ - fail "No gha-rs-controller deployment that watch this namespace found using label (actions.github.com/controller-watch-single-namespace). Consider setting controllerServiceAccount.name in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 10:52:25 -04:00
{{ - end }}
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - if eq $managerServiceAccountName "" }}
2023-08-09 11:11:45 +02:00
{{ - fail "No service account name found for gha-rs-controller deployment using label (actions.github.com/controller-service-account-name), consider setting controllerServiceAccount.name in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - $managerServiceAccountName }}
{{ - end }}
{{ - end }}
{{ - define "gha-runner-scale-set.managerServiceAccountNamespace" - }}
{{ - $searchControllerDeployment := 1 }}
{{ - if . Values . controllerServiceAccount }}
{{ - if . Values . controllerServiceAccount . namespace }}
{{ - $searchControllerDeployment = 0 }}
{{ - . Values . controllerServiceAccount . namespace }}
{{ - end }}
{{ - end }}
{{ - if eq $searchControllerDeployment 1 }}
2023-03-14 10:52:25 -04:00
{{ - $multiNamespacesCounter := 0 }}
{{ - $singleNamespaceCounter := 0 }}
2023-03-14 09:45:44 -04:00
{{ - $controllerDeployment := dict }}
2023-03-14 10:52:25 -04:00
{{ - $singleNamespaceControllerDeployments := dict }}
2023-03-14 09:45:44 -04:00
{{ - $managerServiceAccountNamespace := "" }}
{{ - range $index , $deployment := ( lookup "apps/v1" "Deployment" "" "" ). items }}
2023-03-14 10:52:25 -04:00
{{ - if kindIs "map" $deployment.metadata.labels }}
2023-08-09 11:11:45 +02:00
{{ - if eq ( get $deployment.metadata.labels "app.kubernetes.io/part-of" ) "gha-rs-controller" }}
2023-03-14 10:52:25 -04:00
{{ - if hasKey $deployment.metadata.labels "actions.github.com/controller-watch-single-namespace" }}
{{ - $singleNamespaceCounter = add $singleNamespaceCounter 1 }}
{{ - $_ := set $singleNamespaceControllerDeployments ( get $deployment.metadata.labels "actions.github.com/controller-watch-single-namespace" ) $deployment }}
{{ - else }}
{{ - $multiNamespacesCounter = add $multiNamespacesCounter 1 }}
{{ - $controllerDeployment = $deployment }}
{{ - end }}
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - end }}
{{ - end }}
2023-03-14 10:52:25 -04:00
{{ - if and ( eq $multiNamespacesCounter 0 ) ( eq $singleNamespaceCounter 0 ) }}
2024-02-26 09:51:07 -05:00
{{ - fail "No gha-rs-controller deployment found using label (app.kubernetes.io/part-of=gha-rs-controller). Consider setting controllerServiceAccount.namespace in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 09:45:44 -04:00
{{ - end }}
2023-03-14 10:52:25 -04:00
{{ - if and ( gt $multiNamespacesCounter 0 ) ( gt $singleNamespaceCounter 0 ) }}
2024-02-26 09:51:07 -05:00
{{ - fail "Found both gha-rs-controller installed with flags.watchSingleNamespace set and unset in cluster, this is not supported. Consider setting controllerServiceAccount.namespace in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 09:45:44 -04:00
{{ - end }}
2023-03-14 10:52:25 -04:00
{{ - if gt $multiNamespacesCounter 1 }}
2024-02-26 09:51:07 -05:00
{{ - fail "More than one gha-rs-controller deployment found using label (app.kubernetes.io/part-of=gha-rs-controller). Consider setting controllerServiceAccount.namespace in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 10:52:25 -04:00
{{ - end }}
{{ - if eq $multiNamespacesCounter 1 }}
{{ - with $controllerDeployment.metadata }}
{{ - $managerServiceAccountNamespace = ( get $controllerDeployment.metadata.labels "actions.github.com/controller-service-account-namespace" ) }}
{{ - end }}
{{ - else if gt $singleNamespaceCounter 0 }}
{{ - if hasKey $singleNamespaceControllerDeployments . Release . Namespace }}
{{ - $controllerDeployment = get $singleNamespaceControllerDeployments . Release . Namespace }}
{{ - with $controllerDeployment.metadata }}
{{ - $managerServiceAccountNamespace = ( get $controllerDeployment.metadata.labels "actions.github.com/controller-service-account-namespace" ) }}
{{ - end }}
{{ - else }}
2024-02-26 09:51:07 -05:00
{{ - fail "No gha-rs-controller deployment that watch this namespace found using label (actions.github.com/controller-watch-single-namespace). Consider setting controllerServiceAccount.namespace in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 10:52:25 -04:00
{{ - end }}
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - if eq $managerServiceAccountNamespace "" }}
2024-02-26 09:51:07 -05:00
{{ - fail "No service account namespace found for gha-rs-controller deployment using label (actions.github.com/controller-service-account-namespace), consider setting controllerServiceAccount.namespace in values.yaml to be explicit if you think the discovery is wrong." }}
2023-03-14 09:45:44 -04:00
{{ - end }}
{{ - $managerServiceAccountNamespace }}
{{ - end }}
{{ - end }}