diff --git a/hosting/k8s/helm/templates/_helpers.tpl b/hosting/k8s/helm/templates/_helpers.tpl index cb148678c92..aba1933f2c9 100644 --- a/hosting/k8s/helm/templates/_helpers.tpl +++ b/hosting/k8s/helm/templates/_helpers.tpl @@ -559,6 +559,17 @@ Generate docker config for image pull secret {{- end }} {{- end }} +{{/* +Create the name of the webapp service account to use +*/}} +{{- define "trigger-v4.webappServiceAccountName" -}} +{{- if .Values.supervisor.serviceAccount.create }} +{{- default (printf "%s-webapp" (include "trigger-v4.fullname" .)) .Values.webapp.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.webapp.serviceAccount.name }} +{{- end }} +{{- end }} + {{/* Merge webapp ingress annotations to avoid duplicates */}} diff --git a/hosting/k8s/helm/templates/webapp.yaml b/hosting/k8s/helm/templates/webapp.yaml index 0dd1bddbc41..721e5e60705 100644 --- a/hosting/k8s/helm/templates/webapp.yaml +++ b/hosting/k8s/helm/templates/webapp.yaml @@ -1,10 +1,16 @@ +{{- if .Values.webapp.serviceAccount.create }} apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "trigger-v4.fullname" . }}-webapp + name: {{ include "trigger-v4.webappServiceAccountName" . }} labels: {{- $component := "webapp" }} {{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }} + {{- with .Values.webapp.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role @@ -27,7 +33,7 @@ metadata: {{- include "trigger-v4.componentLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 4 }} subjects: - kind: ServiceAccount - name: {{ include "trigger-v4.fullname" . }}-webapp + name: {{ include "trigger-v4.webappServiceAccountName" . }} namespace: {{ .Release.Namespace }} roleRef: kind: Role @@ -56,7 +62,7 @@ spec: labels: {{- include "trigger-v4.componentSelectorLabels" (dict "Chart" .Chart "Release" .Release "Values" .Values "component" $component) | nindent 8 }} spec: - serviceAccountName: {{ include "trigger-v4.fullname" . }}-webapp + serviceAccountName: {{ include "trigger-v4.webappServiceAccountName" . }} {{- with .Values.global.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }}