From 5456b1b76e12474fd1fe302e8eade81848038979 Mon Sep 17 00:00:00 2001 From: dementhorr Date: Wed, 14 Feb 2024 19:14:28 +0100 Subject: [PATCH] Revert "Changed actions from StatefulSet to Deployment" This reverts commit e8aedb258cfa840107b2390a729c330bd1ead6e6. --- README.md | 64 +++++++++---------- .../gitea/act_runner/config-act-runner.yaml | 6 +- .../{deployment.yaml => statefulset.yaml} | 40 +++++++----- unittests/act_runner/config-act-runner.yaml | 2 +- unittests/act_runner/config-scripts.yaml | 2 +- unittests/act_runner/job.yaml | 2 +- unittests/act_runner/role-job.yaml | 2 +- unittests/act_runner/rolebinding-job.yaml | 2 +- unittests/act_runner/secret-token.yaml | 2 +- unittests/act_runner/serviceaccount-job.yaml | 2 +- .../{deployment.yaml => statefulset.yaml} | 12 ++-- values.yaml | 32 +++++----- 12 files changed, 89 insertions(+), 79 deletions(-) rename templates/gitea/act_runner/{deployment.yaml => statefulset.yaml} (67%) rename unittests/act_runner/{deployment.yaml => statefulset.yaml} (55%) diff --git a/README.md b/README.md index 6045880..3d90ae0 100644 --- a/README.md +++ b/README.md @@ -1001,38 +1001,38 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo ### GiteaActions -| Name | Description | Value | -| ---------------------------------------------- | --------------------------------------------------------------------------- | ------------------ | -| `actions.deployment.enabled` | Create an act runner Deployment | `false` | -| `actions.deployment.annotations` | Act runner annotations | `{}` | -| `actions.deployment.labels` | Act runner labels | `{}` | -| `actions.deployment.resources` | Act runner resources | `{}` | -| `actions.deployment.nodeSelector` | NodeSelector for the deployment | `{}` | -| `actions.deployment.tolerations` | Tolerations for the deployment | `[]` | -| `actions.deployment.affinity` | Affinity for the deployment | `{}` | -| `actions.deployment.config` | Act runner custom configuration | `""` | -| `actions.deployment.runnerLabels` | Act runner labels. | `""` | -| `actions.deployment.actRunnerImage.repository` | The Gitea act runner image | `gitea/act_runner` | -| `actions.deployment.actRunnerImage.tag` | The Gitea act runner tag | `0.2.6` | -| `actions.deployment.actRunnerImage.pullPolicy` | The Gitea act runner pullPolicy | `IfNotPresent` | -| `actions.deployment.dindImage.repository` | The Docker-in-Docker image | `docker` | -| `actions.deployment.dindImage.tag` | The Docker-in-Docker image tag | `24.0.7-dind` | -| `actions.deployment.dindImage.pullPolicy` | The Docker-in-Docker pullPolicy | `IfNotPresent` | -| `actions.job.enabled` | Create a job that will create and save the token in a Kubernetes Secret | `false` | -| `actions.job.annotations` | Job's annotations | `{}` | -| `actions.job.labels` | Job's labels | `{}` | -| `actions.job.resources` | Job's resources | `{}` | -| `actions.job.nodeSelector` | NodeSelector for the job | `{}` | -| `actions.job.tolerations` | Tolerations for the job | `[]` | -| `actions.job.affinity` | Affinity for the job | `{}` | -| `actions.job.tokenImage.repository` | The image that can create a token via `gitea actions generate-runner-token` | `gitea/gitea` | -| `actions.job.tokenImage.tag` | The token image tag that can create a token | `""` | -| `actions.job.tokenImage.pullPolicy` | The token image pullPolicy that can create a token | `IfNotPresent` | -| `actions.job.publishImage.repository` | The image that can create the secret via kubectl | `bitnami/kubectl` | -| `actions.job.publishImage.tag` | The publish image tag that can create the secret | `1.29.0` | -| `actions.job.publishImage.pullPolicy` | The publish image pullPolicy that can create the secret | `IfNotPresent` | -| `actions.existingSecret` | Secret that contains the token | `""` | -| `actions.existingSecretKey` | Secret key | `""` | +| Name | Description | Value | +| ----------------------------------------------- | --------------------------------------------------------------------------- | ------------------ | +| `actions.statefulset.enabled` | Create an act runner StatefulSet. | `false` | +| `actions.statefulset.annotations` | Act runner annotations | `{}` | +| `actions.statefulset.labels` | Act runner labels | `{}` | +| `actions.statefulset.resources` | Act runner resources | `{}` | +| `actions.statefulset.nodeSelector` | NodeSelector for the statefulset | `{}` | +| `actions.statefulset.tolerations` | Tolerations for the statefulset | `[]` | +| `actions.statefulset.affinity` | Affinity for the statefulset | `{}` | +| `actions.statefulset.config` | Act runner custom configuration. | `""` | +| `actions.statefulset.runnerLabels` | Act runner labels. | `""` | +| `actions.statefulset.actRunnerImage.repository` | The Gitea act runner image | `gitea/act_runner` | +| `actions.statefulset.actRunnerImage.tag` | The Gitea act runner tag | `0.2.6` | +| `actions.statefulset.actRunnerImage.pullPolicy` | The Gitea act runner pullPolicy | `IfNotPresent` | +| `actions.statefulset.dindImage.repository` | The Docker-in-Docker image | `docker` | +| `actions.statefulset.dindImage.tag` | The Docker-in-Docker image tag | `24.0.7-dind` | +| `actions.statefulset.dindImage.pullPolicy` | The Docker-in-Docker pullPolicy | `IfNotPresent` | +| `actions.job.enabled` | Create a job that will create and save the token in a Kubernetes Secret | `false` | +| `actions.job.annotations` | Job's annotations | `{}` | +| `actions.job.labels` | Job's labels | `{}` | +| `actions.job.resources` | Job's resources | `{}` | +| `actions.job.nodeSelector` | NodeSelector for the job | `{}` | +| `actions.job.tolerations` | Tolerations for the job | `[]` | +| `actions.job.affinity` | Affinity for the job | `{}` | +| `actions.job.tokenImage.repository` | The image that can create a token via `gitea actions generate-runner-token` | `gitea/gitea` | +| `actions.job.tokenImage.tag` | The token image tag that can create a token | `""` | +| `actions.job.tokenImage.pullPolicy` | The token image pullPolicy that can create a token | `IfNotPresent` | +| `actions.job.publishImage.repository` | The image that can create the secret via kubectl | `bitnami/kubectl` | +| `actions.job.publishImage.tag` | The publish image tag that can create the secret | `1.29.0` | +| `actions.job.publishImage.pullPolicy` | The publish image pullPolicy that can create the secret | `IfNotPresent` | +| `actions.existingSecret` | Secret that contains the token | `""` | +| `actions.existingSecretKey` | Secret key | `""` | ### Gitea diff --git a/templates/gitea/act_runner/config-act-runner.yaml b/templates/gitea/act_runner/config-act-runner.yaml index 07647a7..091f200 100644 --- a/templates/gitea/act_runner/config-act-runner.yaml +++ b/templates/gitea/act_runner/config-act-runner.yaml @@ -1,4 +1,4 @@ -{{- if .Values.actions.deployment.enabled }} +{{- if and (and .Values.actions.statefulset.enabled .Values.persistence.enabled) .Values.persistence.mount }} --- apiVersion: v1 kind: ConfigMap @@ -7,9 +7,9 @@ metadata: labels: {{- include "gitea.labels" . | nindent 4 }} data: - {{- if .Values.actions.deployment.config }} + {{- if .Values.actions.statefulset.config }} config.yaml: | - {{- with .Values.actions.deployment.config -}} + {{- with .Values.actions.statefulset.config -}} {{ . | nindent 4}} {{- end -}} {{- else }} diff --git a/templates/gitea/act_runner/deployment.yaml b/templates/gitea/act_runner/statefulset.yaml similarity index 67% rename from templates/gitea/act_runner/deployment.yaml rename to templates/gitea/act_runner/statefulset.yaml index 47886d0..b778820 100644 --- a/templates/gitea/act_runner/deployment.yaml +++ b/templates/gitea/act_runner/statefulset.yaml @@ -1,16 +1,16 @@ -{{- if .Values.actions.deployment.enabled }} +{{- if and (and .Values.actions.statefulset.enabled .Values.persistence.enabled) .Values.persistence.mount }} {{- $secretName := include "gitea.workername" (dict "global" . "worker" "actions-token") }} --- apiVersion: apps/v1 -kind: Deployment +kind: StatefulSet metadata: labels: {{- include "gitea.labels.actRunner" . | nindent 4 }} - {{- with .Values.actions.deployment.labels }} + {{- with .Values.actions.statefulset.labels }} {{- toYaml . | nindent 4 }} {{- end }} annotations: - {{- with .Values.actions.deployment.annotations }} + {{- with .Values.actions.statefulset.annotations }} {{- toYaml . | nindent 4 }} {{- end }} name: {{ include "gitea.fullname" . }}-act-runner @@ -22,7 +22,7 @@ spec: metadata: labels: {{- include "gitea.labels.actRunner" . | nindent 8 }} - {{- with .Values.actions.deployment.labels }} + {{- with .Values.actions.statefulset.labels }} {{- toYaml . | nindent 8 }} {{- end }} spec: @@ -38,8 +38,8 @@ spec: done containers: - name: act-runner - image: "{{ .Values.actions.deployment.actRunnerImage.repository }}:{{ .Values.actions.deployment.actRunnerImage.tag }}" - imagePullPolicy: {{ .Values.actions.deployment.actRunnerImage.pullPolicy }} + image: "{{ .Values.actions.statefulset.actRunnerImage.repository }}:{{ .Values.actions.statefulset.actRunnerImage.tag }}" + imagePullPolicy: {{ .Values.actions.statefulset.actRunnerImage.pullPolicy }} workingDir: /data env: - name: DOCKER_HOST @@ -56,20 +56,22 @@ spec: - name: GITEA_INSTANCE_URL value: "http://{{ include "gitea.fullname" . }}-http:{{ .Values.service.http.port }}" - name: GITEA_RUNNER_LABELS - value: "{{ .Values.actions.deployment.runnerLabels | default "ubuntu-latest" }}" + value: "{{ .Values.actions.statefulset.runnerLabels | default "ubuntu-latest" }}" - name: CONFIG_FILE value: /actrunner/config.yaml resources: - {{- toYaml .Values.actions.deployment.resources | nindent 12 }} + {{- toYaml .Values.actions.statefulset.resources | nindent 12 }} volumeMounts: - mountPath: /actrunner/config.yaml name: act-runner-config subPath: config.yaml - mountPath: /certs/server name: docker-certs + - mountPath: /data + name: data-act-runner - name: dind - image: "{{ .Values.actions.deployment.dindImage.repository }}:{{ .Values.actions.deployment.dindImage.tag }}" - imagePullPolicy: {{ .Values.actions.deployment.dindImage.pullPolicy }} + image: "{{ .Values.actions.statefulset.dindImage.repository }}:{{ .Values.actions.statefulset.dindImage.tag }}" + imagePullPolicy: {{ .Values.actions.statefulset.dindImage.pullPolicy }} env: - name: DOCKER_HOST value: tcp://127.0.0.1:2376 @@ -81,19 +83,19 @@ spec: # allowPrivilegeEscalation: true privileged: true resources: - {{- toYaml .Values.actions.deployment.resources | nindent 12 }} + {{- toYaml .Values.actions.statefulset.resources | nindent 12 }} volumeMounts: - mountPath: /certs/server name: docker-certs - {{- with .Values.actions.deployment.nodeSelector }} + {{- with .Values.actions.statefulset.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.actions.deployment.affinity }} + {{- with .Values.actions.statefulset.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.actions.deployment.tolerations }} + {{- with .Values.actions.statefulset.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} @@ -103,4 +105,12 @@ spec: name: {{ include "gitea.fullname" . }}-act-runner-config - name: docker-certs emptyDir: {} + volumeClaimTemplates: + - metadata: + name: data-act-runner + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Mi {{- end }} diff --git a/unittests/act_runner/config-act-runner.yaml b/unittests/act_runner/config-act-runner.yaml index 34c4e47..a9a1a85 100644 --- a/unittests/act_runner/config-act-runner.yaml +++ b/unittests/act_runner/config-act-runner.yaml @@ -9,7 +9,7 @@ tests: template: templates/gitea/act_runner/config-act-runner.yaml set: actions: - deployment: + statefulset: enabled: true asserts: - hasDocuments: diff --git a/unittests/act_runner/config-scripts.yaml b/unittests/act_runner/config-scripts.yaml index 6605c39..93314db 100644 --- a/unittests/act_runner/config-scripts.yaml +++ b/unittests/act_runner/config-scripts.yaml @@ -5,7 +5,7 @@ release: templates: - templates/gitea/act_runner/config-scripts.yaml tests: - - it: renders a ConfigMap + - it: renders a deployment template: templates/gitea/act_runner/config-scripts.yaml set: actions: diff --git a/unittests/act_runner/job.yaml b/unittests/act_runner/job.yaml index 55f195c..6ba7e7f 100644 --- a/unittests/act_runner/job.yaml +++ b/unittests/act_runner/job.yaml @@ -5,7 +5,7 @@ release: templates: - templates/gitea/act_runner/job.yaml tests: - - it: renders a Job + - it: renders a deployment template: templates/gitea/act_runner/job.yaml set: actions: diff --git a/unittests/act_runner/role-job.yaml b/unittests/act_runner/role-job.yaml index 9c04ba4..217f45a 100644 --- a/unittests/act_runner/role-job.yaml +++ b/unittests/act_runner/role-job.yaml @@ -5,7 +5,7 @@ release: templates: - templates/gitea/act_runner/role-job.yaml tests: - - it: renders a Role + - it: renders a role template: templates/gitea/act_runner/role-job.yaml set: actions: diff --git a/unittests/act_runner/rolebinding-job.yaml b/unittests/act_runner/rolebinding-job.yaml index 871364c..7c9d416 100644 --- a/unittests/act_runner/rolebinding-job.yaml +++ b/unittests/act_runner/rolebinding-job.yaml @@ -5,7 +5,7 @@ release: templates: - templates/gitea/act_runner/rolebinding-job.yaml tests: - - it: renders a RoleBinding + - it: renders a deployment template: templates/gitea/act_runner/rolebinding-job.yaml set: actions: diff --git a/unittests/act_runner/secret-token.yaml b/unittests/act_runner/secret-token.yaml index 41458d9..9cae9b6 100644 --- a/unittests/act_runner/secret-token.yaml +++ b/unittests/act_runner/secret-token.yaml @@ -5,7 +5,7 @@ release: templates: - templates/gitea/act_runner/secret-token.yaml tests: - - it: renders a Secret + - it: renders a deployment template: templates/gitea/act_runner/secret-token.yaml set: actions: diff --git a/unittests/act_runner/serviceaccount-job.yaml b/unittests/act_runner/serviceaccount-job.yaml index 753a421..f0f82a9 100644 --- a/unittests/act_runner/serviceaccount-job.yaml +++ b/unittests/act_runner/serviceaccount-job.yaml @@ -5,7 +5,7 @@ release: templates: - templates/gitea/act_runner/serviceaccount-job.yaml tests: - - it: renders a ServiceAccount + - it: renders a deployment template: templates/gitea/act_runner/serviceaccount-job.yaml set: actions: diff --git a/unittests/act_runner/deployment.yaml b/unittests/act_runner/statefulset.yaml similarity index 55% rename from unittests/act_runner/deployment.yaml rename to unittests/act_runner/statefulset.yaml index cece4d5..d94cb4a 100644 --- a/unittests/act_runner/deployment.yaml +++ b/unittests/act_runner/statefulset.yaml @@ -1,20 +1,20 @@ -suite: actions template | deployment +suite: actions template | statefulset release: name: gitea-unittests namespace: testing templates: - - templates/gitea/act_runner/deployment.yaml + - templates/gitea/act_runner/statefulset.yaml tests: - - it: renders a Deployment - template: templates/gitea/act_runner/deployment.yaml + - it: renders a deployment + template: templates/gitea/act_runner/statefulset.yaml set: actions: - deployment: + statefulset: enabled: true asserts: - hasDocuments: count: 1 - containsDocument: - kind: Deployment + kind: StatefulSet apiVersion: apps/v1 name: gitea-unittests-act-runner diff --git a/values.yaml b/values.yaml index 910d24a..22fc864 100644 --- a/values.yaml +++ b/values.yaml @@ -344,21 +344,21 @@ signing: # - must define deployment.env.GITEA__ACTIONS__ENABLED and GITEA__SERVER__LOCAL_ROOT_URL ## @section GiteaActions # -## @param actions.deployment.enabled Create an act runner Deployment -## @param actions.deployment.annotations Act runner annotations -## @param actions.deployment.labels Act runner labels -## @param actions.deployment.resources Act runner resources -## @param actions.deployment.nodeSelector NodeSelector for the deployment -## @param actions.deployment.tolerations Tolerations for the deployment -## @param actions.deployment.affinity Affinity for the deployment -## @param actions.deployment.config Act runner custom configuration -## @param actions.deployment.runnerLabels Act runner labels. -## @param actions.deployment.actRunnerImage.repository The Gitea act runner image -## @param actions.deployment.actRunnerImage.tag The Gitea act runner tag -## @param actions.deployment.actRunnerImage.pullPolicy The Gitea act runner pullPolicy -## @param actions.deployment.dindImage.repository The Docker-in-Docker image -## @param actions.deployment.dindImage.tag The Docker-in-Docker image tag -## @param actions.deployment.dindImage.pullPolicy The Docker-in-Docker pullPolicy +## @param actions.statefulset.enabled Create an act runner StatefulSet. +## @param actions.statefulset.annotations Act runner annotations +## @param actions.statefulset.labels Act runner labels +## @param actions.statefulset.resources Act runner resources +## @param actions.statefulset.nodeSelector NodeSelector for the statefulset +## @param actions.statefulset.tolerations Tolerations for the statefulset +## @param actions.statefulset.affinity Affinity for the statefulset +## @param actions.statefulset.config Act runner custom configuration. +## @param actions.statefulset.runnerLabels Act runner labels. +## @param actions.statefulset.actRunnerImage.repository The Gitea act runner image +## @param actions.statefulset.actRunnerImage.tag The Gitea act runner tag +## @param actions.statefulset.actRunnerImage.pullPolicy The Gitea act runner pullPolicy +## @param actions.statefulset.dindImage.repository The Docker-in-Docker image +## @param actions.statefulset.dindImage.tag The Docker-in-Docker image tag +## @param actions.statefulset.dindImage.pullPolicy The Docker-in-Docker pullPolicy ## @param actions.job.enabled Create a job that will create and save the token in a Kubernetes Secret ## @param actions.job.annotations Job's annotations ## @param actions.job.labels Job's labels @@ -375,7 +375,7 @@ signing: ## @param actions.existingSecret Secret that contains the token ## @param actions.existingSecretKey Secret key actions: - deployment: + statefulset: enabled: false annotations: {}