From c57089a50c92dc787f0e642d16cf98dc3bc9c9ec Mon Sep 17 00:00:00 2001 From: Vladimir <26582191+SweetOps@users.noreply.github.com> Date: Mon, 4 Oct 2021 13:28:12 +0300 Subject: [PATCH] fix: update global values in github-actions-runners (#5) --- charts/github-actions-runners/Chart.yaml | 2 +- .../github-actions-runners/templates/hpa.yaml | 16 +++++++-- .../templates/runnerdeployment.yaml | 30 +++++++++-------- .../templates/serviceaccount.yaml | 7 ++-- charts/github-actions-runners/values.yaml | 33 +++++++++++++++---- 5 files changed, 64 insertions(+), 24 deletions(-) diff --git a/charts/github-actions-runners/Chart.yaml b/charts/github-actions-runners/Chart.yaml index 7a92d86..27bd35d 100644 --- a/charts/github-actions-runners/Chart.yaml +++ b/charts/github-actions-runners/Chart.yaml @@ -2,6 +2,6 @@ apiVersion: v2 name: github-actions-runners description: A Helm chart for provisioning Github Actions runners type: application -version: 0.0.3 +version: 0.1.0 maintainers: - name: SweetOps diff --git a/charts/github-actions-runners/templates/hpa.yaml b/charts/github-actions-runners/templates/hpa.yaml index c446b18..8aa88b9 100644 --- a/charts/github-actions-runners/templates/hpa.yaml +++ b/charts/github-actions-runners/templates/hpa.yaml @@ -3,7 +3,13 @@ {{- $enabled := printf "%t" .enabled }} {{- if regexMatch "nil" $enabled }}{{- $enabled = "true" }}{{- end }} {{- if (eq $enabled "true") }} -{{- if .autoscaling.enabled }} +{{- $autoscaling := .autoscaling | default dict }} +{{- $autoscalingEnabled := $autoscaling.enabled | default false }} +{{- $minReplicas := $autoscaling.minReplicas | default $.Values.global.autoscaling.minReplicas }} +{{- $maxReplicas := $autoscaling.maxReplicas | default $.Values.global.autoscaling.maxReplicas }} +{{- $scaleUpTriggers := $autoscaling.scaleUpTriggers | default $.Values.global.autoscaling.scaleUpTriggers }} +{{- $metrics := $autoscaling.metrics | default $.Values.global.autoscaling.metrics }} +{{- if $autoscalingEnabled }} kind: HorizontalRunnerAutoscaler apiVersion: actions.summerwind.dev/v1alpha1 metadata: @@ -12,12 +18,18 @@ metadata: github-actions-runner: {{ .name }} {{- include "github-actions-runners.labels" $ | nindent 4 }} spec: + minReplicas: {{ $minReplicas }} + maxReplicas: {{ $maxReplicas }} scaleTargetRef: name: {{ include "github-actions-runners.fullname" $ }}-{{ .name }} - {{- with .autoscaling.scaleUpTriggers }} + {{- with $scaleUpTriggers }} scaleUpTriggers: {{- toYaml . | nindent 4 }} {{- end }} + {{- with $metrics }} + metrics: + {{- toYaml . | nindent 4 }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/charts/github-actions-runners/templates/runnerdeployment.yaml b/charts/github-actions-runners/templates/runnerdeployment.yaml index bd45d25..869522c 100644 --- a/charts/github-actions-runners/templates/runnerdeployment.yaml +++ b/charts/github-actions-runners/templates/runnerdeployment.yaml @@ -3,6 +3,10 @@ {{- $enabled := printf "%t" .enabled }} {{- if regexMatch "nil" $enabled }}{{- $enabled = "true" }}{{- end }} {{- if (eq $enabled "true") }} +{{- $imageSpec := .image | default dict }} +{{- $repository := $imageSpec.repository | default $.Values.global.image.repository }} +{{- $tag := $imageSpec.tag | default $.Values.global.image.tag }} +{{- $pullPolicy := $imageSpec.pullPolicy | default $.Values.global.image.pullPolicy }} kind: RunnerDeployment apiVersion: actions.summerwind.dev/v1alpha1 metadata: @@ -14,7 +18,7 @@ spec: replicas: {{ .replicaCount | default $.Values.global.replicaCount }} template: metadata: - {{- with .podAnnotations }} + {{- with (default $.Values.global.podAnnotations .podAnnotations) }} annotations: {{- toYaml . | nindent 8 }} {{- end }} @@ -23,38 +27,38 @@ spec: {{- include "github-actions-runners.selectorLabels" $ | nindent 8 }} spec: serviceAccountName: {{ include "github-actions-runners.fullname" $ }}-{{ .name }} - image: "{{ .image.repository | default $.Values.global.image.repository }}:{{ .image.tag | default $.Values.global.image.tag }}" - imagePullPolicy: "{{ .image.pullPolicy | default $.Values.global.image.pullPolicy }}" + image: {{ printf "%s:%s" $repository $tag }} + imagePullPolicy: {{ $pullPolicy }} {{- if .config.githubRepository }} repository: "{{ .config.githubRepository }}" {{- end }} {{- if .config.githubOrganization }} organization: "{{ .config.githubOrganization }}" {{- end }} - {{- with .config.labels }} + {{- with (default $.Values.global.config.labels .config.labels )}} labels: {{- toYaml . | nindent 8 }} {{- end }} - ephemeral: "{{ .config.ephemeral | default $.Values.global.config.ephemeral }}" - dockerEnabled: "{{ .config.dockerEnabled | default $.Values.global.config.dockerEnabled }}" - dockerMTU: "{{ .config.dockerMTU | default $.Values.global.config.dockerMTU }}" + ephemeral: {{ .config.ephemeral | default $.Values.global.config.ephemeral }} + dockerEnabled: {{ .config.dockerEnabled | default $.Values.global.config.dockerEnabled }} + dockerMTU: {{ .config.dockerMTU | default $.Values.global.config.dockerMTU }} dockerRegistryMirror: "{{ .config.dockerRegistryMirror | default $.Values.global.config.dockerRegistryMirror }}" - dockerdWithinRunnerContainer: "{{ .config.dockerdWithinRunnerContainer | default $.Values.global.config.dockerdWithinRunnerContainer }}" + dockerdWithinRunnerContainer: {{ .config.dockerdWithinRunnerContainer | default $.Values.global.config.dockerdWithinRunnerContainer }} securityContext: - {{- toYaml .securityContext | nindent 8 }} - {{- with .nodeSelector }} + {{- toYaml (default $.Values.global.securityContext .securityContext )| nindent 8 }} + {{- with (default $.Values.global.nodeSelector .nodeSelector )}} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .affinity }} + {{- with (default $.Values.global.affinity .affinity) }} affinity: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .tolerations }} + {{- with (default $.Values.global.tolerations .tolerations) }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} resources: - {{- toYaml .resources | nindent 8 }} + {{- toYaml (default $.Values.global.resources .resources) | nindent 8 }} {{- end }} {{- end }} diff --git a/charts/github-actions-runners/templates/serviceaccount.yaml b/charts/github-actions-runners/templates/serviceaccount.yaml index 1bcb465..773e4cc 100644 --- a/charts/github-actions-runners/templates/serviceaccount.yaml +++ b/charts/github-actions-runners/templates/serviceaccount.yaml @@ -3,7 +3,10 @@ {{- $enabled := printf "%t" .enabled }} {{- if regexMatch "nil" $enabled }}{{- $enabled = "true" }}{{- end }} {{- if (eq $enabled "true") }} -{{- if .serviceAccount.create -}} +{{- $serviceAccount := .image | default dict }} +{{- $create := $serviceAccount.create | default $.Values.global.serviceAccount.create }} +{{- $annotations := $serviceAccount.annotations | default $.Values.global.serviceAccount.annotations }} +{{- if $create -}} apiVersion: v1 kind: ServiceAccount metadata: @@ -11,7 +14,7 @@ metadata: labels: github-actions-runner: {{ .name }} {{- include "github-actions-runners.labels" $ | nindent 4 }} - {{- with .serviceAccount.annotations }} + {{- with $annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/github-actions-runners/values.yaml b/charts/github-actions-runners/values.yaml index 4f248c4..427d89e 100644 --- a/charts/github-actions-runners/values.yaml +++ b/charts/github-actions-runners/values.yaml @@ -6,22 +6,46 @@ nameOverride: "" fullnameOverride: "" global: - replicaCount: 1 + replicaCount: 0 image: repository: summerwind/actions-runner-dind pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "v2.281.1-ubuntu-20.04" + + podAnnotations: {} + securityContext: {} + resources: {} + nodeSelector: {} + tolerations: [] + affinity: {} + + serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + config: ephemeral: true dockerEnabled: false dockerMTU: 1500 dockerRegistryMirror: https://mirror.gcr.io/ dockerdWithinRunnerContainer: true + labels: [] + + autoscaling: + minReplicas: 0 + maxReplicas: 3 + metrics: [] + scaleUpTriggers: [] + runnerDeployments: - name: default - enabled: true + enabled: false replicaCount: 1 image: repository: summerwind/actions-runner-dind @@ -39,9 +63,6 @@ runnerDeployments: podAnnotations: {} - podSecurityContext: {} - # fsGroup: 2000 - securityContext: {} # capabilities: # drop: @@ -88,7 +109,7 @@ runnerDeployments: affinity: {} autoscaling: - enabled: true + enabled: false scaleUpTriggers: - githubEvent: checkRun: