From 8e5a13625a94437c301ccaa0f7a769a6f4de5c53 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Sat, 8 Aug 2026 11:46:55 +0200 Subject: [PATCH] fix: Make serviceAccount.name and serviceAccount.create work serviceAccount.name had no effect. This changes it so that the helper (operator.serviceAccountName) is used everywhere, default name is unchanged and with "create: false" giving a name is now required. --- deploy/helm/hive-operator/templates/_helpers.tpl | 4 ++-- deploy/helm/hive-operator/templates/deployment.yaml | 2 +- deploy/helm/hive-operator/templates/serviceaccount.yaml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deploy/helm/hive-operator/templates/_helpers.tpl b/deploy/helm/hive-operator/templates/_helpers.tpl index 7d4d39da..e5354470 100644 --- a/deploy/helm/hive-operator/templates/_helpers.tpl +++ b/deploy/helm/hive-operator/templates/_helpers.tpl @@ -65,9 +65,9 @@ Create the name of the service account to use */}} {{- define "operator.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "operator.fullname" .) .Values.serviceAccount.name }} +{{- default (printf "%s-serviceaccount" (include "operator.fullname" .)) .Values.serviceAccount.name }} {{- else }} -{{- default "default" .Values.serviceAccount.name }} +{{- required "serviceAccount.name is required when serviceAccount.create is false, because the chart then does not create a ServiceAccount for the operator to run as." .Values.serviceAccount.name }} {{- end }} {{- end }} diff --git a/deploy/helm/hive-operator/templates/deployment.yaml b/deploy/helm/hive-operator/templates/deployment.yaml index 06dde967..86be9ad2 100644 --- a/deploy/helm/hive-operator/templates/deployment.yaml +++ b/deploy/helm/hive-operator/templates/deployment.yaml @@ -29,7 +29,7 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "operator.fullname" . }}-serviceaccount + serviceAccountName: {{ include "operator.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: diff --git a/deploy/helm/hive-operator/templates/serviceaccount.yaml b/deploy/helm/hive-operator/templates/serviceaccount.yaml index 8ba0d58c..10633e5f 100644 --- a/deploy/helm/hive-operator/templates/serviceaccount.yaml +++ b/deploy/helm/hive-operator/templates/serviceaccount.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "operator.fullname" . }}-serviceaccount + name: {{ include "operator.serviceAccountName" . }} labels: {{- include "operator.labels" . | nindent 4 }} {{- with .Values.serviceAccount.annotations }} @@ -20,7 +20,7 @@ metadata: {{- include "operator.labels" . | nindent 4 }} subjects: - kind: ServiceAccount - name: {{ include "operator.fullname" . }}-serviceaccount + name: {{ include "operator.serviceAccountName" . }} namespace: {{ .Release.Namespace }} roleRef: kind: ClusterRole