Skip to content

Commit 5a0e95a

Browse files
authored
Add CRD configuration to Helm chart values.yaml (zalando#559)
* add templates for CRDs incl. crd-install hooks * support both config styles in values.yaml * fix ServiceAccount naming in values.yaml
1 parent ebda393 commit 5a0e95a

17 files changed

+425
-185
lines changed

charts/postgres-operator/Chart.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
apiVersion: v1
22
name: postgres-operator
3-
version: 0.1.0
4-
appVersion: 1.1.0
3+
version: 1.2.0
4+
appVersion: 1.2.0
55
home: https://github.com/zalando/postgres-operator
66
description: Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
77
keywords:
88
- postgres
99
- operator
10+
- cloud-native
11+
- patroni
12+
- spilo
1013
maintainers:
14+
- name: Zalando
15+
1116
- name: kimxogus
1217
1318
sources:

charts/postgres-operator/templates/clusterrole.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
apiVersion: rbac.authorization.k8s.io/v1beta1
33
kind: ClusterRole
44
metadata:
5-
name: {{ template "postgres-operator.fullname" . }}
5+
name: {{- if eq .Values.serviceAccount.name "" }}
6+
{{ template "postgres-operator.fullname" . }}
7+
{{- else }}
8+
{{ .Values.serviceAccount.name }}
9+
{{- end }}
610
labels:
711
app.kubernetes.io/name: {{ template "postgres-operator.name" . }}
812
helm.sh/chart: {{ template "postgres-operator.chart" . }}
@@ -140,7 +144,11 @@ rules:
140144
verbs:
141145
- bind
142146
resourceNames:
143-
- {{ template "postgres-operator.fullname" . }}
147+
- {{- if eq .Values.serviceAccount.name "" }}
148+
{{ template "postgres-operator.fullname" . }}
149+
{{- else }}
150+
{{ .Values.serviceAccount.name }}
151+
{{- end }}
144152
- apiGroups:
145153
- batch
146154
resources:

charts/postgres-operator/templates/clusterrolebinding.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRoleBinding
44
metadata:
5-
name: {{ template "postgres-operator.fullname" . }}
5+
name: {{- if eq .Values.serviceAccount.name "" }}
6+
{{ template "postgres-operator.fullname" . }}
7+
{{- else }}
8+
{{ .Values.serviceAccount.name }}
9+
{{- end }}
610
labels:
711
app.kubernetes.io/name: {{ template "postgres-operator.name" . }}
812
helm.sh/chart: {{ template "postgres-operator.chart" . }}
@@ -11,11 +15,19 @@ metadata:
1115
roleRef:
1216
apiGroup: rbac.authorization.k8s.io
1317
kind: ClusterRole
14-
name: {{ template "postgres-operator.fullname" . }}
18+
name: {{- if eq .Values.serviceAccount.name "" }}
19+
{{ template "postgres-operator.fullname" . }}
20+
{{- else }}
21+
{{ .Values.serviceAccount.name }}
22+
{{- end }}
1523
subjects:
1624
- kind: ServiceAccount
1725
# note: the cluster role binding needs to be defined
1826
# for every namespace the operator service account lives in.
19-
name: {{ template "postgres-operator.fullname" . }}
27+
name: {{- if eq .Values.serviceAccount.name "" }}
28+
{{ template "postgres-operator.fullname" . }}
29+
{{- else }}
30+
{{ .Values.serviceAccount.name }}
31+
{{- end }}
2032
namespace: {{ .Release.Namespace }}
2133
{{ end }}

charts/postgres-operator/templates/configmap.yaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,25 @@ metadata:
88
app.kubernetes.io/managed-by: {{ .Release.Service }}
99
app.kubernetes.io/instance: {{ .Release.Name }}
1010
data:
11-
pod_service_account_name: {{ template "postgres-operator.fullname" . }}
12-
{{ toYaml .Values.config | indent 2 }}
11+
pod_service_account_name: {{- if eq .Values.serviceAccount.name "" }}
12+
{{ template "postgres-operator.fullname" . }}
13+
{{- else }}
14+
{{ .Values.serviceAccount.name }}
15+
{{- end }}
16+
api_port: "{{ .Values.configLoggingRestApi.api_port }}"
17+
cluster_history_entries: "{{ .Values.configLoggingRestApi.cluster_history_entries }}"
18+
docker_image: {{ .Values.docker_image }}
19+
debug_logging: "{{ .Values.configDebug.debug_logging }}"
20+
enable_database_access: "{{ .Values.configDebug.enable_database_access }}"
21+
repair_period: {{ .Values.repair_period }}
22+
resync_period: {{ .Values.resync_period }}
23+
ring_log_lines: "{{ .Values.configLoggingRestApi.ring_log_lines }}"
24+
spilo_privileged: "{{ .Values.spilo_privileged }}"
25+
workers: "{{ .Values.workers }}"
26+
{{ toYaml .Values.configMap | indent 2 }}
27+
{{ toYaml .Values.configUsers | indent 2 }}
28+
{{ toYaml .Values.configKubernetes | indent 2 }}
29+
{{ toYaml .Values.configTimeouts | indent 2 }}
30+
{{ toYaml .Values.configLoadBalancer | indent 2 }}
31+
{{ toYaml .Values.configAwsOrGcp | indent 2 }}
32+
{{ toYaml .Values.configTeamsApi | indent 2 }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: postgresqls.acid.zalan.do
5+
annotations:
6+
"helm.sh/hook": crd-install
7+
spec:
8+
group: acid.zalan.do
9+
names:
10+
kind: postgresql
11+
listKind: postgresqlList
12+
plural: postgresqls
13+
singular: postgresql
14+
shortNames:
15+
- pg
16+
scope: Namespaced
17+
subresources:
18+
status: {}
19+
version: v1
20+
---
21+
apiVersion: apiextensions.k8s.io/v1beta1
22+
kind: CustomResourceDefinition
23+
metadata:
24+
name: operatorconfigurations.acid.zalan.do
25+
annotations:
26+
"helm.sh/hook": crd-install
27+
spec:
28+
group: acid.zalan.do
29+
names:
30+
kind: OperatorConfiguration
31+
listKind: OperatorConfigurationList
32+
plural: operatorconfigurations
33+
singular: operatorconfiguration
34+
shortNames:
35+
- pgc
36+
scope: Namespaced
37+
subresources:
38+
status: {}
39+
version: v1

charts/postgres-operator/templates/deployment.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ spec:
1717
metadata:
1818
annotations:
1919
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
20+
# In order to use the checksum of CRD OperatorConfiguration instead, use the following line instead
21+
# {{ include (print $.Template.BasePath "/operatorconfiguration.yaml") . | sha256sum }}
2022
{{- if .Values.podAnnotations }}
2123
{{ toYaml .Values.podAnnotations | indent 8 }}
2224
{{- end }}
@@ -27,14 +29,21 @@ spec:
2729
{{ toYaml .Values.podLabels | indent 8 }}
2830
{{- end }}
2931
spec:
30-
serviceAccountName: {{ template "postgres-operator.fullname" . }}
32+
serviceAccountName: {{- if eq .Values.serviceAccount.name "" }}
33+
{{ template "postgres-operator.fullname" . }}
34+
{{- else }}
35+
{{ .Values.serviceAccount.name }}
36+
{{- end }}
3137
containers:
3238
- name: {{ .Chart.Name }}
3339
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
3440
imagePullPolicy: {{ .Values.image.pullPolicy }}
3541
env:
3642
- name: CONFIG_MAP_NAME
3743
value: {{ template "postgres-operator.fullname" . }}
44+
# In order to use the CRD OperatorConfiguration instead, uncomment these lines and comment out the two lines above
45+
# - name: POSTGRES_OPERATOR_CONFIGURATION_OBJECT
46+
# value: {{ template "postgres-operator.fullname" . }}
3847
resources:
3948
{{ toYaml .Values.resources | indent 10 }}
4049
{{- if .Values.imagePullSecrets }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: "acid.zalan.do/v1"
2+
kind: OperatorConfiguration
3+
metadata:
4+
name: {{ template "postgres-operator.fullname" . }}
5+
labels:
6+
app.kubernetes.io/name: {{ template "postgres-operator.name" . }}
7+
helm.sh/chart: {{ template "postgres-operator.chart" . }}
8+
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
configuration:
11+
docker_image: {{ .Values.docker_image }}
12+
repair_period: {{ .Values.repair_period }}
13+
resync_period: {{ .Values.resync_period }}
14+
workers: {{ .Values.workers }}
15+
{{ toYaml .Values.configCRD | indent 2 }}
16+
users:
17+
{{ toYaml .Values.configUsers | indent 4 }}
18+
kubernetes:
19+
oauth_token_secret_name: {{ template "postgres-operator.fullname" . }}
20+
pod_service_account_name: operator
21+
spilo_privileged: {{ .Values.spilo_privileged }}
22+
{{ toYaml .Values.configKubernetes | indent 4 }}
23+
{{ toYaml .Values.configKubernetesCRD | indent 4 }}
24+
postgres_pod_resources:
25+
{{ toYaml .Values.configPostgresPodResources | indent 4 }}
26+
timeouts:
27+
{{ toYaml .Values.configTimeouts | indent 4 }}
28+
load_balancer:
29+
{{ toYaml .Values.configLoadBalancerCRD | indent 4 }}
30+
aws_or_gcp:
31+
{{ toYaml .Values.configAwsOrGcp | indent 4 }}
32+
logical_backup:
33+
{{ toYaml .Values.configLogicalBackup | indent 4 }}
34+
debug:
35+
{{ toYaml .Values.configDebug | indent 4 }}
36+
teams_api:
37+
{{ toYaml .Values.configTeamsApiCRD | indent 4 }}
38+
logging_rest_api:
39+
{{ toYaml .Values.configLoggingRestApi | indent 4 }}
40+
scalyr:
41+
{{ toYaml .Values.configScalyr | indent 4 }}

charts/postgres-operator/templates/serviceaccount.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:
5-
name: {{ template "postgres-operator.fullname" . }}
5+
name: {{- if eq .Values.serviceAccount.name "" }}
6+
{{ template "postgres-operator.fullname" . }}
7+
{{- else }}
8+
{{ .Values.serviceAccount.name }}
9+
{{- end }}
610
labels:
711
app.kubernetes.io/name: {{ template "postgres-operator.name" . }}
812
helm.sh/chart: {{ template "postgres-operator.chart" . }}

0 commit comments

Comments
 (0)