Skip to content

Commit cc1ffdc

Browse files
authored
enable controllerID for chart and allow configurable pod cluster role (zalando#876)
1 parent 07c5da3 commit cc1ffdc

File tree

7 files changed

+49
-5
lines changed

7 files changed

+49
-5
lines changed

charts/postgres-operator/templates/_helpers.tpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ Create a service account name.
3131
{{ default (include "postgres-operator.fullname" .) .Values.serviceAccount.name }}
3232
{{- end -}}
3333

34+
{{/*
35+
Create a pod service account name.
36+
*/}}
37+
{{- define "postgres-pod.serviceAccountName" -}}
38+
{{ default (printf "%s-%v" (include "postgres-operator.fullname" .) "pod") .Values.podServiceAccount.name }}
39+
{{- end -}}
40+
41+
{{/*
42+
Create a controller ID.
43+
*/}}
44+
{{- define "postgres-operator.controllerID" -}}
45+
{{ default (include "postgres-operator.fullname" .) .Values.controllerID.name }}
46+
{{- end -}}
47+
3448
{{/*
3549
Create chart name and version as used by the chart label.
3650
*/}}

charts/postgres-operator/templates/clusterrole-postgres-pod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
name: postgres-pod
5+
name: {{ include "postgres-pod.serviceAccountName" . }}
66
labels:
77
app.kubernetes.io/name: {{ template "postgres-operator.name" . }}
88
helm.sh/chart: {{ template "postgres-operator.chart" . }}

charts/postgres-operator/templates/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ metadata:
99
app.kubernetes.io/managed-by: {{ .Release.Service }}
1010
app.kubernetes.io/instance: {{ .Release.Name }}
1111
data:
12+
pod_service_account_name: {{ include "postgres-pod.serviceAccountName" . }}
1213
{{ toYaml .Values.configGeneral | indent 2 }}
1314
{{ toYaml .Values.configUsers | indent 2 }}
1415
{{ toYaml .Values.configKubernetes | indent 2 }}

charts/postgres-operator/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ spec:
4343
{{- else }}
4444
- name: POSTGRES_OPERATOR_CONFIGURATION_OBJECT
4545
value: {{ template "postgres-operator.fullname" . }}
46+
{{- end }}
47+
{{- if .Values.controllerID.create }}
48+
- name: CONTROLLER_ID
49+
value: {{ template "postgres-operator.controllerID" . }}
4650
{{- end }}
4751
resources:
4852
{{ toYaml .Values.resources | indent 10 }}

charts/postgres-operator/templates/operatorconfiguration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ configuration:
1313
users:
1414
{{ toYaml .Values.configUsers | indent 4 }}
1515
kubernetes:
16+
pod_service_account_name: {{ include "postgres-pod.serviceAccountName" . }}
1617
oauth_token_secret_name: {{ template "postgres-operator.fullname" . }}
1718
{{ toYaml .Values.configKubernetes | indent 4 }}
1819
postgres_pod_resources:

charts/postgres-operator/values-crd.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ configKubernetes:
103103
# service account definition as JSON/YAML string to be used by postgres cluster pods
104104
# pod_service_account_definition: ""
105105

106-
# name of service account to be used by postgres cluster pods
107-
pod_service_account_name: "postgres-pod"
108106
# role binding definition as JSON/YAML string to be used by pod service account
109107
# pod_service_account_role_binding_definition: ""
110108

@@ -284,6 +282,11 @@ serviceAccount:
284282
# If not set and create is true, a name is generated using the fullname template
285283
name:
286284

285+
podServiceAccount:
286+
# The name of the ServiceAccount to be used by postgres cluster pods
287+
# If not set a name is generated using the fullname template and "-pod" suffix
288+
name: "postgres-pod"
289+
287290
priorityClassName: ""
288291

289292
resources:
@@ -305,3 +308,12 @@ tolerations: []
305308
# Node labels for pod assignment
306309
# Ref: https://kubernetes.io/docs/user-guide/node-selection/
307310
nodeSelector: {}
311+
312+
controllerID:
313+
# Specifies whether a controller ID should be defined for the operator
314+
# Note, all postgres manifest must then contain the following annotation to be found by this operator
315+
# "acid.zalan.do/controller": <controller-ID-of-the-operator>
316+
create: false
317+
# The name of the controller ID to use.
318+
# If not set and create is true, a name is generated using the fullname template
319+
name:

charts/postgres-operator/values.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ configKubernetes:
9696
# service account definition as JSON/YAML string to be used by postgres cluster pods
9797
# pod_service_account_definition: ""
9898

99-
# name of service account to be used by postgres cluster pods
100-
pod_service_account_name: "postgres-pod"
10199
# role binding definition as JSON/YAML string to be used by pod service account
102100
# pod_service_account_role_binding_definition: ""
103101

@@ -260,6 +258,11 @@ serviceAccount:
260258
# If not set and create is true, a name is generated using the fullname template
261259
name:
262260

261+
podServiceAccount:
262+
# The name of the ServiceAccount to be used by postgres cluster pods
263+
# If not set a name is generated using the fullname template and "-pod" suffix
264+
name: "postgres-pod"
265+
263266
priorityClassName: ""
264267

265268
resources:
@@ -281,3 +284,12 @@ tolerations: []
281284
# Node labels for pod assignment
282285
# Ref: https://kubernetes.io/docs/user-guide/node-selection/
283286
nodeSelector: {}
287+
288+
controllerID:
289+
# Specifies whether a controller ID should be defined for the operator
290+
# Note, all postgres manifest must then contain the following annotation to be found by this operator
291+
# "acid.zalan.do/controller": <controller-ID-of-the-operator>
292+
create: false
293+
# The name of the controller ID to use.
294+
# If not set and create is true, a name is generated using the fullname template
295+
name:

0 commit comments

Comments
 (0)