Skip to content

Commit a484fc9

Browse files
committed
allow for service account names to be defined separately
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
1 parent 8cee450 commit a484fc9

16 files changed

Lines changed: 58 additions & 99 deletions

charts/runtime-operator/templates/_helpers.tpl

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,49 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5151
{{- end }}
5252

5353
{{/*
54-
Create the name of the service account to use
54+
Create the name of the service account to use for the runtime-operator
5555
*/}}
56-
{{- define "runtime-operator.serviceAccountName" -}}
56+
{{- define "operator.serviceAccountName" -}}
5757
{{- if .Values.operator.serviceAccount.create }}
5858
{{- default (include "runtime-operator.fullname" .) .Values.operator.serviceAccount.name }}
5959
{{- else }}
6060
{{- default "default" .Values.operator.serviceAccount.name }}
6161
{{- end }}
6262
{{- end }}
6363

64+
{{/*
65+
Create the name of the service account to use for the runtime
66+
*/}}
67+
{{- define "runtime.serviceAccountName" -}}
68+
{{- if .Values.runtime.serviceAccount.create }}
69+
{{- default (printf "%s-runtime" (include "runtime-operator.fullname" .)) .Values.runtime.serviceAccount.name }}
70+
{{- else }}
71+
{{- default "default" .Values.runtime.serviceAccount.name }}
72+
{{- end }}
73+
{{- end }}
74+
75+
{{/*
76+
Create the name of the service account to use for the runtime gateway
77+
*/}}
78+
{{- define "gateway.serviceAccountName" -}}
79+
{{- if .Values.gateway.serviceAccount.create }}
80+
{{- default (printf "%s-gateway" (include "runtime-operator.fullname" .)) .Values.gateway.serviceAccount.name }}
81+
{{- else }}
82+
{{- default "default" .Values.gateway.serviceAccount.name }}
83+
{{- end }}
84+
{{- end }}
85+
86+
{{/*
87+
Create the name of the service account to use for NATS
88+
*/}}
89+
{{- define "nats.serviceAccountName" -}}
90+
{{- if .Values.nats.serviceAccount.create }}
91+
{{- default (printf "%s-nats" (include "runtime-operator.fullname" .)) .Values.nats.serviceAccount.name }}
92+
{{- else }}
93+
{{- default "default" .Values.nats.serviceAccount.name }}
94+
{{- end }}
95+
{{- end }}
96+
6497
{{/*
6598
Create the imagePullSecrets section for the chart.
6699
*/}}

charts/runtime-operator/templates/gateway/clusterrolebinding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ roleRef:
1313
name: {{ include "runtime-operator.fullname" . }}-gateway
1414
subjects:
1515
- kind: ServiceAccount
16-
name: {{ include "runtime-operator.serviceAccountName" . }}-gateway
16+
name: {{ include "gateway.serviceAccountName" . }}
1717
namespace: {{ .Release.Namespace }}
1818
{{- end }}
1919
{{- end }}

charts/runtime-operator/templates/gateway/deployment.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ spec:
1919
wasmcloud.com/name: runtime-gateway
2020
{{- include "runtime-operator.labels" . | nindent 8 }}
2121
spec:
22-
serviceAccountName: {{ include "runtime-operator.serviceAccountName" . }}-gateway
22+
# change this
23+
serviceAccountName: {{ include "gateway.serviceAccountName" . }}
2324
{{- include "runtime-operator.imagePullSecrets" . | nindent 6 }}
2425
containers:
2526
- name: runtime-operator

charts/runtime-operator/templates/gateway/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
apiVersion: v1
44
kind: ServiceAccount
55
metadata:
6-
name: {{ include "runtime-operator.serviceAccountName" . }}-gateway
6+
name: {{ include "gateway.serviceAccountName" . }}
77
namespace: {{ .Release.Namespace }}
88
labels:
99
{{- include "runtime-operator.labels" . | nindent 4 }}

charts/runtime-operator/templates/nats/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ spec:
2626
- name: nats-cert
2727
secret:
2828
secretName: {{ .Values.global.certificates.natsCertSecretName }}
29-
serviceAccountName: {{ include "runtime-operator.serviceAccountName" . }}-nats
29+
serviceAccountName: {{ include "nats.serviceAccountName" . }}
3030
{{- include "runtime-operator.imagePullSecrets" . | nindent 6 }}
3131
containers:
3232
- name: nats

charts/runtime-operator/templates/nats/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:
5-
name: {{ include "runtime-operator.serviceAccountName" . }}-nats
5+
name: {{ include "nats.serviceAccountName" . }}
66
namespace: {{ .Release.Namespace }}
77
labels:
88
{{- include "runtime-operator.labels" . | nindent 4 }}

charts/runtime-operator/templates/operator/clusterrole.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.operator.serviceAccount.create (not .Values.operator.watchNamespaces) -}}
1+
{{- if and .Values.operator.serviceAccount.create -}}
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:

charts/runtime-operator/templates/operator/clusterrolebinding-metrics.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ roleRef:
1212
name: {{ include "runtime-operator.fullname" . }}-metrics-auth
1313
subjects:
1414
- kind: ServiceAccount
15-
name: {{ include "runtime-operator.serviceAccountName" . }}
15+
name: {{ include "operator.serviceAccountName" . }}
1616
namespace: {{ .Release.Namespace }}
1717
{{- end }}

charts/runtime-operator/templates/operator/clusterrolebinding.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.operator.serviceAccount.create (not .Values.operator.watchNamespaces) -}}
1+
{{- if and .Values.operator.serviceAccount.create -}}
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRoleBinding
44
metadata:
@@ -12,6 +12,6 @@ roleRef:
1212
name: {{ include "runtime-operator.fullname" . }}
1313
subjects:
1414
- kind: ServiceAccount
15-
name: {{ include "runtime-operator.serviceAccountName" . }}
15+
name: {{ include "operator.serviceAccountName" . }}
1616
namespace: {{ .Release.Namespace }}
1717
{{- end }}

charts/runtime-operator/templates/operator/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
- name: operator-cert
2323
secret:
2424
secretName: {{ .Values.global.certificates.operatorCertSecretName }}
25-
serviceAccountName: {{ include "runtime-operator.serviceAccountName" . }}
25+
serviceAccountName: {{ include "operator.serviceAccountName" . }}
2626
{{- include "runtime-operator.imagePullSecrets" . | nindent 6 }}
2727
containers:
2828
- name: runtime-operator

0 commit comments

Comments
 (0)