diff --git a/charts/postgres-operator/.helmignore b/charts/postgres-operator/.helmignore index 5a41c7275..f0c131944 100644 --- a/charts/postgres-operator/.helmignore +++ b/charts/postgres-operator/.helmignore @@ -19,5 +19,3 @@ .project .idea/ *.tmproj -# ConfigMap -# templates/configmap.yaml diff --git a/charts/postgres-operator/templates/configmap.yaml b/charts/postgres-operator/templates/configmap.yaml index 15502522b..62c8f2b81 100644 --- a/charts/postgres-operator/templates/configmap.yaml +++ b/charts/postgres-operator/templates/configmap.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.configTarget "ConfigMap" }} apiVersion: v1 kind: ConfigMap metadata: @@ -23,3 +24,4 @@ data: {{ toYaml .Values.configDebug | indent 2 }} {{ toYaml .Values.configLoggingRestApi | indent 2 }} {{ toYaml .Values.configTeamsApi | indent 2 }} +{{- end }} diff --git a/charts/postgres-operator/templates/deployment.yaml b/charts/postgres-operator/templates/deployment.yaml index 04393416e..7010b07ac 100644 --- a/charts/postgres-operator/templates/deployment.yaml +++ b/charts/postgres-operator/templates/deployment.yaml @@ -1,4 +1,4 @@ -apiVersion: apps/v1beta2 +apiVersion: apps/v1 kind: Deployment metadata: labels: @@ -16,9 +16,11 @@ spec: template: metadata: annotations: + {{- if eq .Values.configTarget "ConfigMap" }} checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} - # In order to use the checksum of CRD OperatorConfiguration instead, use the following line instead - # {{ include (print $.Template.BasePath "/operatorconfiguration.yaml") . | sha256sum }} + {{- else }} + checksum/config: {{ include (print $.Template.BasePath "/operatorconfiguration.yaml") . | sha256sum }} + {{- end }} {{- if .Values.podAnnotations }} {{ toYaml .Values.podAnnotations | indent 8 }} {{- end }} @@ -39,11 +41,13 @@ spec: image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: + {{- if eq .Values.configTarget "ConfigMap" }} - name: CONFIG_MAP_NAME value: {{ template "postgres-operator.fullname" . }} - # In order to use the CRD OperatorConfiguration instead, uncomment these lines and comment out the two lines above - # - name: POSTGRES_OPERATOR_CONFIGURATION_OBJECT - # value: {{ template "postgres-operator.fullname" . }} + {{- else }} + - name: POSTGRES_OPERATOR_CONFIGURATION_OBJECT + value: {{ template "postgres-operator.fullname" . }} + {{- end }} resources: {{ toYaml .Values.resources | indent 10 }} {{- if .Values.imagePullSecrets }} diff --git a/charts/postgres-operator/templates/operatorconfiguration.yaml b/charts/postgres-operator/templates/operatorconfiguration.yaml index cf44a904f..c6e9f78b7 100644 --- a/charts/postgres-operator/templates/operatorconfiguration.yaml +++ b/charts/postgres-operator/templates/operatorconfiguration.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.configTarget "OperatorConfigurationCRD" }} apiVersion: "acid.zalan.do/v1" kind: OperatorConfiguration metadata: @@ -33,3 +34,4 @@ configuration: {{ toYaml .Values.configLoggingRestApi | indent 4 }} scalyr: {{ toYaml .Values.configScalyr | indent 4 }} +{{- end }} diff --git a/charts/postgres-operator/values-crd.yaml b/charts/postgres-operator/values-crd.yaml index 1902d9b40..c9c09ab10 100644 --- a/charts/postgres-operator/values-crd.yaml +++ b/charts/postgres-operator/values-crd.yaml @@ -13,6 +13,8 @@ image: podAnnotations: {} podLabels: {} +configTarget: "OperatorConfigurationCRD" + # general top-level configuration parameters configGeneral: # etcd connection string for Patroni. Empty uses K8s-native DCS. @@ -27,10 +29,10 @@ configGeneral: repair_period: 5m # period between consecutive sync requests resync_period: 30m - # map of sidecar names to docker images # can prevent certain cases of memory overcommitment # set_memory_request_to_limit: false + # map of sidecar names to docker images # sidecar_docker_images # example: "exampleimage:exampletag" @@ -140,7 +142,7 @@ configLoadBalancer: # defines the DNS name string template for the replica load balancer cluster replica_dns_name_format: "{cluster}-repl.{team}.{hostedzone}" -# Options to aid debugging of the operator itself +# options to aid debugging of the operator itself configDebug: # toggles verbose debug logs from the operator debug_logging: true diff --git a/charts/postgres-operator/values.yaml b/charts/postgres-operator/values.yaml index e13ad60de..e89c04fcc 100644 --- a/charts/postgres-operator/values.yaml +++ b/charts/postgres-operator/values.yaml @@ -13,7 +13,9 @@ image: podAnnotations: {} podLabels: {} -# config shared from ConfigMap and CRD +configTarget: "ConfigMap" + +# general configuration parameters configGeneral: # etcd connection string for Patroni. Empty uses K8s-native DCS. etcd_host: ""