From 424dee189552436ef61949731aafe5d4485e5046 Mon Sep 17 00:00:00 2001 From: Yi Hong Date: Thu, 19 Mar 2026 14:36:51 -0400 Subject: [PATCH] Add ability to customize the service account name. --- README.md | 1 + templates/statefulset.yaml | 3 +++ unittests/helm/statefulset.yaml | 12 ++++++++++++ values.yaml | 2 ++ 4 files changed, 18 insertions(+) diff --git a/README.md b/README.md index bb31207..740f951 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ You should be good to go! | `statefulset.dind.extraEnvs` | Allows adding custom environment variables, such as `DOCKER_IPTABLES_LEGACY` | `[]` | | `statefulset.persistence.size` | Size for persistence to store act runner data | `1Gi` | | `statefulset.securityContext` | Customize the SecurityContext | `{}` | +| `statefulset.serviceAccountName` | Customize the service account name | `{}` | | `existingSecret` | Secret that contains the token | `""` | | `existingSecretKey` | Secret key | `""` | | `giteaRootURL` | URL the act_runner registers and connect with | `""` | diff --git a/templates/statefulset.yaml b/templates/statefulset.yaml index 8cbcf3c..709e966 100644 --- a/templates/statefulset.yaml +++ b/templates/statefulset.yaml @@ -30,6 +30,9 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + {{- if .Values.statefulset.serviceAccountName }} + serviceAccountName: {{ .Values.statefulset.serviceAccountName }} + {{- end }} securityContext: {{- toYaml .Values.statefulset.securityContext | nindent 8 }} initContainers: diff --git a/unittests/helm/statefulset.yaml b/unittests/helm/statefulset.yaml index c863120..adbd497 100644 --- a/unittests/helm/statefulset.yaml +++ b/unittests/helm/statefulset.yaml @@ -461,3 +461,15 @@ tests: echo "Trying again in 3 seconds..." done echo "Gitea has been reached!" + - it: should render service account name correctly + template: templates/statefulset.yaml + set: + enabled: true + statefulset: + serviceAccountName: "my-service-account" + asserts: + - hasDocuments: + count: 1 + - equal: + path: spec.template.spec.serviceAccountName + value: "my-service-account" diff --git a/values.yaml b/values.yaml index 6e89f6d..6537cde 100644 --- a/values.yaml +++ b/values.yaml @@ -32,6 +32,7 @@ ## @param statefulset.dind.extraEnvs Allows adding custom environment variables, such as `DOCKER_IPTABLES_LEGACY` ## @param statefulset.persistence.size Size for persistence to store act runner data ## @param statefulset.securityContext Customize the SecurityContext +## @param statefulset.serviceAccountName Customize the service account name ## @param existingSecret Secret that contains the token ## @param existingSecretKey Secret key ## @param giteaRootURL URL the act_runner registers and connect with @@ -47,6 +48,7 @@ statefulset: affinity: {} extraVolumes: [] securityContext: {} + serviceAccountName: null actRunner: registry: "docker.gitea.com"