From 6d799a463d34242d83853f957bc393788ee150cb Mon Sep 17 00:00:00 2001 From: juan131 Date: Mon, 25 Nov 2019 17:30:10 +0100 Subject: [PATCH 1/2] [bitnami/postgresql-ha] Lint chart + standardisation Signed-off-by: juan131 --- bitnami/postgresql-ha/Chart.yaml | 26 +- bitnami/postgresql-ha/README.md | 8 +- ...alues-production-with-ingress-and-pdb.yaml | 24 + bitnami/postgresql-ha/templates/_helpers.tpl | 13 + .../postgresql-ha/templates/ldap-secrets.yaml | 2 +- .../templates/networkpolicy.yaml | 32 +- .../templates/pgpool/deployment.yaml | 407 +++++++------- .../templates/pgpool/ingress.yaml | 27 +- .../postgresql-ha/templates/pgpool/pdb.yaml | 12 +- .../templates/pgpool/secrets.yaml | 2 +- .../templates/pgpool/service.yaml | 34 +- .../templates/postgresql/configmap.yaml | 34 +- .../postgresql/extended-configmap.yaml | 16 +- .../postgresql/initdb-scripts-configmap.yaml | 14 +- .../templates/postgresql/metrics-service.yaml | 14 +- .../templates/postgresql/pdb.yaml | 12 +- .../templates/postgresql/secrets.yaml | 2 +- .../postgresql/service-headless.yaml | 12 +- .../templates/postgresql/service.yaml | 12 +- .../templates/postgresql/servicemonitor.yaml | 20 +- .../templates/postgresql/statefulset.yaml | 527 +++++++++--------- bitnami/postgresql-ha/values-production.yaml | 117 +++- bitnami/postgresql-ha/values.yaml | 104 +++- 23 files changed, 796 insertions(+), 675 deletions(-) create mode 100644 bitnami/postgresql-ha/ci/values-production-with-ingress-and-pdb.yaml diff --git a/bitnami/postgresql-ha/Chart.yaml b/bitnami/postgresql-ha/Chart.yaml index 9b9de97bd..3f0b3823f 100644 --- a/bitnami/postgresql-ha/Chart.yaml +++ b/bitnami/postgresql-ha/Chart.yaml @@ -1,23 +1,23 @@ apiVersion: v1 name: postgresql-ha -version: 1.0.2 +version: 1.1.0 appVersion: 11.6.0 description: Chart for PostgreSQL with HA architecture (using Replication Manager (repmgr) and Pgpool). keywords: -- postgresql -- repmgr -- pgpool -- postgres -- database -- sql -- replication -- cluster -- high availability + - postgresql + - repmgr + - pgpool + - postgres + - database + - sql + - replication + - cluster + - high availability home: https://www.postgresql.org/ icon: https://bitnami.com/assets/stacks/postgresql/img/postgresql-stack-110x117.png sources: -- https://github.com/bitnami/bitnami-docker-postgresql + - https://github.com/bitnami/bitnami-docker-postgresql maintainers: -- name: Bitnami - email: containers@bitnami.com + - name: Bitnami + email: containers@bitnami.com engine: gotpl diff --git a/bitnami/postgresql-ha/README.md b/bitnami/postgresql-ha/README.md index e9a6cb622..39a814152 100644 --- a/bitnami/postgresql-ha/README.md +++ b/bitnami/postgresql-ha/README.md @@ -74,8 +74,8 @@ The following table lists the configurable parameters of the PostgreSQL HA chart | `postgresqlImage.debug` | Specify if debug logs should be enabled | `false` | | `postgresql.replicaCount` | The number of replicas to deploy | `2` | | `postgresql.updateStrategyType` | Statefulset update strategy policy | `RollingUpdate` | -| `postgresql.antiAffinity` | Pod anti-affinity policy | `soft` | -| `postgresql.nodeAffinity` | Node affinity policy | `{}` (The value is evaluated as a template) | +| `postgresql.podAnnotations` | Additional pod annotations | `{}` | +| `postgresql.affinity` | Map of node/pod affinities | `{}` (The value is evaluated as a template) | | `postgresql.nodeSelector` | Node labels for pod assignment | `{}` (The value is evaluated as a template) | | `postgresql.tolerations` | Tolerations for pod assignment | `[]` (The value is evaluated as a template) | | `postgresql.securityContext.enabled` | Enable security context for PostgreSQL with Repmgr | `true` | @@ -115,8 +115,8 @@ The following table lists the configurable parameters of the PostgreSQL HA chart | `pgpoolImage.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) | | `pgpoolImage.debug` | Specify if debug logs should be enabled | `false` | | `pgpool.replicaCount` | The number of replicas to deploy | `2` | -| `pgpool.antiAffinity` | Pod anti-affinity policy | `soft` | -| `pgpool.nodeAffinity` | Node affinity policy | `{}` (The value is evaluated as a template) | +| `pgpool.podAnnotations` | Additional pod annotations | `{}` | +| `pgpool.affinity` | Map of node/pod affinities | `{}` (The value is evaluated as a template) | | `pgpool.nodeSelector` | Node labels for pod assignment | `{}` (The value is evaluated as a template) | | `pgpool.tolerations` | Tolerations for pod assignment | `[]` (The value is evaluated as a template) | | `pgpool.securityContext.enabled` | Enable security context for Pgpool | `true` | diff --git a/bitnami/postgresql-ha/ci/values-production-with-ingress-and-pdb.yaml b/bitnami/postgresql-ha/ci/values-production-with-ingress-and-pdb.yaml new file mode 100644 index 000000000..229477f94 --- /dev/null +++ b/bitnami/postgresql-ha/ci/values-production-with-ingress-and-pdb.yaml @@ -0,0 +1,24 @@ +# Test values file for generating all of the yaml and check that +# the rendering is correct + +ingress: + enabled: true + tls: [] + +postgresql: + pdb: + create: true + +pgpool: + pdb: + create: true + +networkPolicy: + enabled: true + allowExternal: false + +metrics: + enabled: true + ## Kubeval doesn't recognise ServiceMonitor as a valid K8s object + # serviceMonitor: + # enabled: true diff --git a/bitnami/postgresql-ha/templates/_helpers.tpl b/bitnami/postgresql-ha/templates/_helpers.tpl index ac157d74b..582a1b33b 100644 --- a/bitnami/postgresql-ha/templates/_helpers.tpl +++ b/bitnami/postgresql-ha/templates/_helpers.tpl @@ -653,6 +653,19 @@ Return the appropriate apiVersion for networkPolicy {{- end -}} {{- end -}} +{{/* +Renders a value that contains template. +Usage: +{{ include "postgresql-ha.tplValue" (dict "value" .Values.path.to.the.Value "context" $) }} +*/}} +{{- define "postgresql-ha.tplValue" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{- else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} + {{/* Compile all warnings into a single message, and call fail. */}} diff --git a/bitnami/postgresql-ha/templates/ldap-secrets.yaml b/bitnami/postgresql-ha/templates/ldap-secrets.yaml index 1afa85e7a..689fd30a4 100644 --- a/bitnami/postgresql-ha/templates/ldap-secrets.yaml +++ b/bitnami/postgresql-ha/templates/ldap-secrets.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ include "postgresql-ha.ldap" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} type: Opaque data: bind-password: {{ (include "postgresql-ha.ldapPassword" .) | b64enc | quote }} diff --git a/bitnami/postgresql-ha/templates/networkpolicy.yaml b/bitnami/postgresql-ha/templates/networkpolicy.yaml index 1ed09dc28..9303dece4 100644 --- a/bitnami/postgresql-ha/templates/networkpolicy.yaml +++ b/bitnami/postgresql-ha/templates/networkpolicy.yaml @@ -3,25 +3,25 @@ kind: NetworkPolicy apiVersion: {{ template "postgresql-ha.networkPolicy.apiVersion" . }} metadata: name: {{ include "postgresql-ha.fullname" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} spec: podSelector: matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 6 }} app.kubernetes.io/component: postgresql ingress: - # Allow inbound connections - - ports: - - port: 5432 - {{- if not .Values.networkPolicy.allowExternal }} - from: - - podSelector: - matchLabels: - {{ template "postgresql-ha.fullname" . }}-client: "true" - - podSelector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 12 }} - app.kubernetes.io/component: pgpool - {{- end }} - # Allow prometheus scrapes - - ports: - - port: 9187 + # Allow inbound connections + - ports: + - port: 5432 + {{- if not .Values.networkPolicy.allowExternal }} + from: + - podSelector: + matchLabels: + {{ template "postgresql-ha.fullname" . }}-client: "true" + - podSelector: + matchLabels: {{- include "postgresql-ha.matchLabels" . | nindent 18 }} + app.kubernetes.io/component: pgpool + {{- end }} + # Allow prometheus scrapes + - ports: + - port: 9187 {{- end }} diff --git a/bitnami/postgresql-ha/templates/pgpool/deployment.yaml b/bitnami/postgresql-ha/templates/pgpool/deployment.yaml index db910da81..266a1e693 100644 --- a/bitnami/postgresql-ha/templates/pgpool/deployment.yaml +++ b/bitnami/postgresql-ha/templates/pgpool/deployment.yaml @@ -13,34 +13,19 @@ spec: metadata: labels: {{ include "postgresql-ha.labels" . | nindent 8 }} app.kubernetes.io/component: pgpool + {{- if .Values.pgpool.podAnnotations }} + annotations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.pgpool.podAnnotations "context" $) | nindent 8 }} + {{- end }} spec: {{- include "postgresql-ha.imagePullSecrets" . | indent 6 }} - affinity: - {{- if eq .Values.pgpool.antiAffinity "hard" }} - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - topologyKey: "kubernetes.io/hostname" - labelSelector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 18 }} - app.kubernetes.io/component: pgpool - {{- else if eq .Values.pgpool.antiAffinity "soft" }} - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - podAffinityTerm: - topologyKey: kubernetes.io/hostname - labelSelector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 18 }} - app.kubernetes.io/component: pgpool - {{- end }} - {{- if .Values.pgpool.nodeAffinity }} - nodeAffinity: {{ toYaml .Values.pgpool.nodeAffinity | nindent 10 }} - {{- end }} - {{- with .Values.pgpool.nodeSelector }} - nodeSelector: {{ tpl (toYaml .) $ | nindent 8 }} + {{- if .Values.pgpool.affinity }} + affinity: {{- include "postgresql-ha.tplValue" (dict "value" .Values.pgpool.affinity "context" $) | nindent 8 }} {{- end }} - {{- with .Values.pgpool.tolerations }} - tolerations: {{ tpl (toYaml .) $ | nindent 8 }} + {{- if .Values.pgpool.nodeSelector }} + nodeSelector: {{- include "postgresql-ha.tplValue" (dict "value" .Values.pgpool.nodeSelector "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.pgpool.tolerations }} + tolerations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.pgpool.tolerations "context" $) | nindent 8 }} {{- end }} {{- if .Values.pgpool.securityContext.enabled }} securityContext: @@ -53,202 +38,204 @@ spec: {{- $releaseNamespace := .Release.Namespace }} {{- $clusterDomain:= .Values.clusterDomain }} initContainers: - - name: wait-for-backend-nodes - image: {{ include "postgresql-ha.volumePermissionsImage" . }} - imagePullPolicy: {{ .Values.volumePermissionsImage.pullPolicy | quote }} - env: - - name: PGPOOL_BACKEND_NODES - value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $i }}:{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:5432,{{ end }} - command: - - /bin/bash - - -c - - | - dns_lookup() { - local host="${1:?host is missing}" - getent ahosts "$host" | awk '/STREAM/ {print $1 }' - } - is_hostname_resolved() { - local -r host="${1:?missing value}" - if [[ -n "$(dns_lookup "$host")" ]]; then - true - else - false - fi - } - read -r -a nodes <<< "$(tr ',;' ' ' <<< "${PGPOOL_BACKEND_NODES}")" - declare -i node_counter=0 - for node in "${nodes[@]}"; do - read -r -a fields <<< "$(tr ':' ' ' <<< "${node}")" - host="${fields[1]:?field host is needed}" - for ((i = 1 ; i <= 10 ; i+=1 )); do - is_hostname_resolved "$host" && node_counter+=1 && break - sleep 5 - done - done - if [[ $node_counter -ne ${#nodes[@]} ]]; then - echo "Not enough active backend nodes!" - exit 1 - fi - echo "Every backend node is active!" - exit 0 - {{- if .Values.pgpool.securityContext.enabled }} - securityContext: - runAsUser: {{ .Values.pgpool.securityContext.runAsUser }} - {{- end }} + - name: wait-for-backend-nodes + image: {{ include "postgresql-ha.volumePermissionsImage" . }} + imagePullPolicy: {{ .Values.volumePermissionsImage.pullPolicy | quote }} + env: + - name: PGPOOL_BACKEND_NODES + value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $i }}:{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:5432,{{ end }} + command: + - /bin/bash + - -c + - | + dns_lookup() { + local host="${1:?host is missing}" + getent ahosts "$host" | awk '/STREAM/ {print $1 }' + } + is_hostname_resolved() { + local -r host="${1:?missing value}" + if [[ -n "$(dns_lookup "$host")" ]]; then + true + else + false + fi + } + read -r -a nodes <<< "$(tr ',;' ' ' <<< "${PGPOOL_BACKEND_NODES}")" + declare -i node_counter=0 + for node in "${nodes[@]}"; do + read -r -a fields <<< "$(tr ':' ' ' <<< "${node}")" + host="${fields[1]:?field host is needed}" + for ((i = 1 ; i <= 10 ; i+=1 )); do + is_hostname_resolved "$host" && node_counter+=1 && break + sleep 5 + done + done + if [[ $node_counter -ne ${#nodes[@]} ]]; then + echo "Not enough active backend nodes!" + exit 1 + fi + echo "Every backend node is active!" + exit 0 + {{- if .Values.pgpool.securityContext.enabled }} + securityContext: + runAsUser: {{ .Values.pgpool.securityContext.runAsUser }} + {{- end }} containers: - - name: pgpool - image: {{ include "postgresql-ha.pgpoolImage" . }} - imagePullPolicy: {{ .Values.pgpoolImage.pullPolicy | quote }} - {{- if .Values.pgpool.securityContext.enabled }} - securityContext: - runAsUser: {{ .Values.pgpool.securityContext.runAsUser }} - {{- end }} - env: - - name: BITNAMI_DEBUG - value: {{ ternary "true" "false" .Values.pgpoolImage.debug | quote }} - - name: PGPOOL_BACKEND_NODES - value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $i }}:{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:5432,{{ end }} - - name: PGPOOL_SR_CHECK_USER - value: {{ (include "postgresql-ha.postgresqlRepmgrUsername" .) | quote }} - {{- if .Values.postgresql.usePasswordFile }} - - name: PGPOOL_SR_CHECK_PASSWORD_FILE - value: "/opt/bitnami/pgpool/secrets/pgpool-sr-check-password" - {{- else }} - - name: PGPOOL_SR_CHECK_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.postgresqlSecretName" . }} - key: repmgr-password - {{- end }} - - name: PGPOOL_ENABLE_LDAP - value: {{ ternary "yes" "no" .Values.ldap.enabled | quote }} - {{- if .Values.ldap.enabled }} - - name: PGPOOL_LDAP_URI - value: {{ .Values.ldap.uri | quote }} - - name: PGPOOL_LDAP_BASE - value: {{ .Values.ldap.base | quote }} - - name: PGPOOL_LDAP_BIND_DN - value: {{ .Values.ldap.binddn | quote }} - - name: PGPOOL_LDAP_BIND_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.ldapSecretName" . }} - key: bind-password - {{- if .Values.ldap.bslookup }} - - name: PGPOOL_LDAP_BASE_LOOKUP - value: {{ .Values.ldap.bslookup | quote }} - {{- end }} - {{- if .Values.ldap.scope }} - - name: PGPOOL_LDAP_SCOPE - value: {{ .Values.ldap.scope | quote }} - {{- end }} - {{- if .Values.ldap.tlsReqcert }} - - name: PGPOOL_LDAP_TLS_REQCERT - value: {{ .Values.ldap.tlsReqcert | quote }} - {{- end }} - - name: PGPOOL_LDAP_NSS_INITGROUPS_IGNOREUSERS - value: {{ .Values.ldap.nssInitgroupsIgnoreusers | quote }} - {{- end }} - - name: PGPOOL_POSTGRES_USERNAME - value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} - {{- if .Values.postgresql.usePasswordFile }} - - name: PGPOOL_POSTGRES_PASSWORD_FILE - value: "/opt/bitnami/pgpool/secrets/pgpool-password" - {{- else }} - - name: PGPOOL_POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.postgresqlSecretName" . }} - key: postgresql-password - {{- end }} - - name: PGPOOL_ADMIN_USERNAME - value: {{ (include "postgresql-ha.pgpoolAdminUsername" .) | quote }} - {{- if .Values.pgpool.usePasswordFile }} - - name: PGPOOL_ADMIN_PASSWORD_FILE - value: "/opt/bitnami/pgpool/secrets/admin-password" - {{- else }} - - name: PGPOOL_ADMIN_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.pgpoolSecretName" . }} - key: admin-password - {{- end }} - ports: - - name: postgresql - containerPort: 5432 - protocol: TCP - {{- if and .Values.pgpool.livenessProbe.enabled (not .Values.ldap.enabled) }} - livenessProbe: - exec: - command: - - bash - - -ec - - | - if nodes=$(PGPASSWORD=${PGPOOL_POSTGRES_PASSWORD} psql -U {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}{{- end }} -h 127.0.0.1 -tA -c "show pool_nodes;" | grep "up" | wc -l); then - if [[ $nodes -eq {{ $postgresqlReplicaCount }} ]]; then - true + - name: pgpool + image: {{ include "postgresql-ha.pgpoolImage" . }} + imagePullPolicy: {{ .Values.pgpoolImage.pullPolicy | quote }} + {{- if .Values.pgpool.securityContext.enabled }} + securityContext: + runAsUser: {{ .Values.pgpool.securityContext.runAsUser }} + {{- end }} + env: + - name: BITNAMI_DEBUG + value: {{ ternary "true" "false" .Values.pgpoolImage.debug | quote }} + - name: PGPOOL_BACKEND_NODES + value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $i }}:{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }}:5432,{{ end }} + - name: PGPOOL_SR_CHECK_USER + value: {{ (include "postgresql-ha.postgresqlRepmgrUsername" .) | quote }} + {{- if .Values.postgresql.usePasswordFile }} + - name: PGPOOL_SR_CHECK_PASSWORD_FILE + value: "/opt/bitnami/pgpool/secrets/pgpool-sr-check-password" + {{- else }} + - name: PGPOOL_SR_CHECK_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.postgresqlSecretName" . }} + key: repmgr-password + {{- end }} + - name: PGPOOL_ENABLE_LDAP + value: {{ ternary "yes" "no" .Values.ldap.enabled | quote }} + {{- if .Values.ldap.enabled }} + - name: PGPOOL_LDAP_URI + value: {{ .Values.ldap.uri | quote }} + - name: PGPOOL_LDAP_BASE + value: {{ .Values.ldap.base | quote }} + - name: PGPOOL_LDAP_BIND_DN + value: {{ .Values.ldap.binddn | quote }} + - name: PGPOOL_LDAP_BIND_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.ldapSecretName" . }} + key: bind-password + {{- if .Values.ldap.bslookup }} + - name: PGPOOL_LDAP_BASE_LOOKUP + value: {{ .Values.ldap.bslookup | quote }} + {{- end }} + {{- if .Values.ldap.scope }} + - name: PGPOOL_LDAP_SCOPE + value: {{ .Values.ldap.scope | quote }} + {{- end }} + {{- if .Values.ldap.tlsReqcert }} + - name: PGPOOL_LDAP_TLS_REQCERT + value: {{ .Values.ldap.tlsReqcert | quote }} + {{- end }} + - name: PGPOOL_LDAP_NSS_INITGROUPS_IGNOREUSERS + value: {{ .Values.ldap.nssInitgroupsIgnoreusers | quote }} + {{- end }} + - name: PGPOOL_POSTGRES_USERNAME + value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} + {{- if .Values.postgresql.usePasswordFile }} + - name: PGPOOL_POSTGRES_PASSWORD_FILE + value: "/opt/bitnami/pgpool/secrets/pgpool-password" + {{- else }} + - name: PGPOOL_POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.postgresqlSecretName" . }} + key: postgresql-password + {{- end }} + - name: PGPOOL_ADMIN_USERNAME + value: {{ (include "postgresql-ha.pgpoolAdminUsername" .) | quote }} + {{- if .Values.pgpool.usePasswordFile }} + - name: PGPOOL_ADMIN_PASSWORD_FILE + value: "/opt/bitnami/pgpool/secrets/admin-password" + {{- else }} + - name: PGPOOL_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.pgpoolSecretName" . }} + key: admin-password + {{- end }} + ports: + - name: postgresql + containerPort: 5432 + protocol: TCP + {{- if and .Values.pgpool.livenessProbe.enabled (not .Values.ldap.enabled) }} + livenessProbe: + exec: + command: + - bash + - -ec + - | + if nodes=$(PGPASSWORD=${PGPOOL_POSTGRES_PASSWORD} psql -U {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}{{- end }} -h 127.0.0.1 -tA -c "show pool_nodes;" | grep "up" | wc -l); then + if [[ $nodes -eq {{ $postgresqlReplicaCount }} ]]; then + true + else + false + fi else false fi - else - false - fi - initialDelaySeconds: {{ .Values.pgpool.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.pgpool.livenessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.pgpool.livenessProbe.timeoutSeconds }} - successThreshold: {{ .Values.pgpool.livenessProbe.successThreshold }} - failureThreshold: {{ .Values.pgpool.livenessProbe.failureThreshold }} - {{- end }} - {{- if and .Values.pgpool.readinessProbe.enabled (not .Values.ldap.enabled) }} - readinessProbe: - exec: - command: - - bash - - -ec - - | - if nodes=$(PGPASSWORD=${PGPOOL_POSTGRES_PASSWORD} psql -U {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}{{- end }} -h 127.0.0.1 -tA -c "show pool_nodes;" | wc -l); then - if [[ $nodes -eq {{ $postgresqlReplicaCount }} ]]; then - true + initialDelaySeconds: {{ .Values.pgpool.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.pgpool.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.pgpool.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.pgpool.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.pgpool.livenessProbe.failureThreshold }} + {{- end }} + {{- if and .Values.pgpool.readinessProbe.enabled (not .Values.ldap.enabled) }} + readinessProbe: + exec: + command: + - bash + - -ec + - | + if nodes=$(PGPASSWORD=${PGPOOL_POSTGRES_PASSWORD} psql -U {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }}{{- end }} -h 127.0.0.1 -tA -c "show pool_nodes;" | wc -l); then + if [[ $nodes -eq {{ $postgresqlReplicaCount }} ]]; then + true + else + false + fi else false fi - else - false - fi - initialDelaySeconds: {{ .Values.pgpool.readinessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.pgpool.readinessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.pgpool.readinessProbe.timeoutSeconds }} - successThreshold: {{ .Values.pgpool.readinessProbe.successThreshold }} - failureThreshold: {{ .Values.pgpool.readinessProbe.failureThreshold }} - {{- end }} - {{- if .Values.pgpool.resources }} - resources: {{- toYaml .Values.pgpool.resources | nindent 10 }} - {{- end }} - volumeMounts: + initialDelaySeconds: {{ .Values.pgpool.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.pgpool.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.pgpool.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.pgpool.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.pgpool.readinessProbe.failureThreshold }} + {{- end }} + {{- if .Values.pgpool.resources }} + resources: {{- toYaml .Values.pgpool.resources | nindent 12 }} + {{- end }} + volumeMounts: + {{- if .Values.postgresql.usePasswordFile }} + - name: postgresql-password + mountPath: /opt/bitnami/pgpool/secrets/ + {{- end }} + {{- if .Values.pgpool.usePasswordFile }} + - name: pgpool-password + mountPath: /opt/bitnami/pgpool/secrets/ + {{- end }} + {{- if or .Values.postgresql.usePasswordFile .Values.pgpool.usePasswordFile }} + volumes: {{- if .Values.postgresql.usePasswordFile }} - name: postgresql-password - mountPath: /opt/bitnami/pgpool/secrets/ + secret: + secretName: {{ include "postgresql-ha.postgresqlSecretName" . }} + items: + - key: postgresql-password + path: pgpool-password + - key: repmgr-password + path: pgpool-sr-check-password {{- end }} {{- if .Values.pgpool.usePasswordFile }} - name: pgpool-password - mountPath: /opt/bitnami/pgpool/secrets/ + secret: + secretName: {{ include "postgresql-ha.pgpoolSecretName" . }} + items: + - key: admin-password + path: admin-password {{- end }} - volumes: - {{- if .Values.postgresql.usePasswordFile }} - - name: postgresql-password - secret: - secretName: {{ include "postgresql-ha.postgresqlSecretName" . }} - items: - - key: postgresql-password - path: pgpool-password - - key: repmgr-password - path: pgpool-sr-check-password - {{- end }} - {{- if .Values.pgpool.usePasswordFile }} - - name: pgpool-password - secret: - secretName: {{ include "postgresql-ha.pgpoolSecretName" . }} - items: - - key: admin-password - path: admin-password {{- end }} diff --git a/bitnami/postgresql-ha/templates/pgpool/ingress.yaml b/bitnami/postgresql-ha/templates/pgpool/ingress.yaml index eee71e1a6..efbd876ac 100644 --- a/bitnami/postgresql-ha/templates/pgpool/ingress.yaml +++ b/bitnami/postgresql-ha/templates/pgpool/ingress.yaml @@ -4,27 +4,26 @@ apiVersion: extensions/v1beta1 kind: Ingress metadata: name: {{ include "postgresql-ha.fullname" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} annotations: {{- if .Values.ingress.certManager }} kubernetes.io/tls-acme: "true" {{- end }} - {{- range $key, $value := .Values.ingress.annotations }} - {{ $key }}: {{ $value | quote }} + {{- if .Values.ingress.annotations }} + {{- include "postgresql-ha.tplValue" (dict "value" .Values.ingress.annotations "context" $) | nindent 4 }} {{- end }} spec: rules: - {{- range .Values.ingress.hosts }} - - host: {{ .name }} - http: - paths: - - path: {{ default "/" .path }} - backend: - serviceName: {{ $serviceName | quote }} - servicePort: postgresql - {{- end }} + {{- range .Values.ingress.hosts }} + - host: {{ .name }} + http: + paths: + - path: {{ default "/" .path }} + backend: + serviceName: {{ $serviceName | quote }} + servicePort: postgresql + {{- end }} {{- if .Values.ingress.tls }} - tls: -{{ toYaml .Values.ingress.tls | indent 4 }} + tls: {{- toYaml .Values.ingress.tls | nindent 4 }} {{- end }} {{- end }} diff --git a/bitnami/postgresql-ha/templates/pgpool/pdb.yaml b/bitnami/postgresql-ha/templates/pgpool/pdb.yaml index 27169a1bb..dd63b03c5 100644 --- a/bitnami/postgresql-ha/templates/pgpool/pdb.yaml +++ b/bitnami/postgresql-ha/templates/pgpool/pdb.yaml @@ -3,16 +3,16 @@ apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: {{ include "postgresql-ha.pgpool" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: pgpool spec: -{{- if .Values.pgpool.pdb.minAvailable }} + {{- if .Values.pgpool.pdb.minAvailable }} minAvailable: {{ .Values.pgpool.pdb.minAvailable }} -{{- end }} -{{- if .Values.pgpool.pdb.maxUnavailable }} + {{- end }} + {{- if .Values.pgpool.pdb.maxUnavailable }} maxUnavailable: {{ .Values.pgpool.pdb.maxUnavailable }} -{{- end }} + {{- end }} selector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 4 }} + matchLabels: {{- include "postgresql-ha.matchLabels" . | nindent 6 }} app.kubernetes.io/component: pgpool {{- end }} diff --git a/bitnami/postgresql-ha/templates/pgpool/secrets.yaml b/bitnami/postgresql-ha/templates/pgpool/secrets.yaml index def54ed32..c712d5ef3 100644 --- a/bitnami/postgresql-ha/templates/pgpool/secrets.yaml +++ b/bitnami/postgresql-ha/templates/pgpool/secrets.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ include "postgresql-ha.pgpool" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: pgpool type: Opaque data: diff --git a/bitnami/postgresql-ha/templates/pgpool/service.yaml b/bitnami/postgresql-ha/templates/pgpool/service.yaml index c603d4b9b..dc2b1be59 100644 --- a/bitnami/postgresql-ha/templates/pgpool/service.yaml +++ b/bitnami/postgresql-ha/templates/pgpool/service.yaml @@ -2,32 +2,30 @@ apiVersion: v1 kind: Service metadata: name: {{ include "postgresql-ha.pgpool" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} -{{- with .Values.service.annotations }} - annotations: -{{ toYaml . | indent 4 }} -{{- end }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} + {{- if .Values.service.annotations }} + annotations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.service.annotations "context" $) | nindent 4 }} + {{- end }} spec: type: {{ .Values.service.type }} - {{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }} + {{- if and (not (empty .Values.service.loadBalancerIP)) (eq .Values.service.type "LoadBalancer") }} loadBalancerIP: {{ .Values.service.loadBalancerIP }} {{- end }} {{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges }} - loadBalancerSourceRanges: - {{ with .Values.service.loadBalancerSourceRanges }} -{{ toYaml . | indent 4 }} -{{- end }} + loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }} {{- end }} {{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }} clusterIP: {{ .Values.service.clusterIP }} {{- end }} ports: - - name: postgresql - port: {{ .Values.service.port }} - targetPort: postgresql - protocol: TCP - {{- if .Values.service.nodePort }} - nodePort: {{ .Values.service.nodePort }} - {{- end }} - selector: {{ include "postgresql-ha.matchLabels" . | nindent 4 }} + - name: postgresql + port: {{ .Values.service.port }} + targetPort: postgresql + protocol: TCP + {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePort)) }} + nodePort: {{ .Values.service.nodePort }} + {{- else if eq .Values.service.type "ClusterIP" }} + nodePort: null + {{- end }} + selector: {{- include "postgresql-ha.matchLabels" . | nindent 4 }} app.kubernetes.io/component: pgpool diff --git a/bitnami/postgresql-ha/templates/postgresql/configmap.yaml b/bitnami/postgresql-ha/templates/postgresql/configmap.yaml index 46e3c1e16..3b412cb01 100644 --- a/bitnami/postgresql-ha/templates/postgresql/configmap.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/configmap.yaml @@ -3,27 +3,27 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ printf "%s-configuration" (include "postgresql-ha.postgresql" .) }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql data: -{{- if (.Files.Glob "files/repmgr.conf") }} -{{ (.Files.Glob "files/repmgr.conf").AsConfig | indent 2 }} -{{- else if .Values.postgresql.repmgrConfiguration }} + {{- if (.Files.Glob "files/repmgr.conf") }} + {{- (.Files.Glob "files/repmgr.conf").AsConfig | nindent 2 }} + {{- else if .Values.postgresql.repmgrConfiguration }} repmgr.conf: | -{{ .Values.postgresql.repmgrConfiguration | indent 4 }} -{{- end }} -{{- if (.Files.Glob "files/postgresql.conf") }} -{{ (.Files.Glob "files/postgresql.conf").AsConfig | indent 2 }} -{{- else if .Values.postgresql.configuration }} + {{- .Values.postgresql.repmgrConfiguration | nindent 4 }} + {{- end }} + {{- if (.Files.Glob "files/postgresql.conf") }} + {{- (.Files.Glob "files/postgresql.conf").AsConfig | nindent 2 }} + {{- else if .Values.postgresql.configuration }} postgresql.conf: | -{{- range $key, $value := default dict .Values.postgresql.configuration }} + {{- range $key, $value := default dict .Values.postgresql.configuration }} {{ $key | snakecase }}={{ $value }} -{{- end }} -{{- end }} -{{- if (.Files.Glob "files/pg_hba.conf") }} -{{ (.Files.Glob "files/pg_hba.conf").AsConfig | indent 2 }} -{{- else if .Values.postgresql.pgHbaConfiguration }} + {{- end }} + {{- end }} + {{- if (.Files.Glob "files/pg_hba.conf") }} + {{- (.Files.Glob "files/pg_hba.conf").AsConfig | nindent 2 }} + {{- else if .Values.postgresql.pgHbaConfiguration }} pg_hba.conf: | -{{ .Values.postgresql.pgHbaConfiguration | indent 4 }} -{{- end }} + {{- .Values.postgresql.pgHbaConfiguration | nindent 4 }} + {{- end }} {{- end }} diff --git a/bitnami/postgresql-ha/templates/postgresql/extended-configmap.yaml b/bitnami/postgresql-ha/templates/postgresql/extended-configmap.yaml index 1515c44c7..e3bfb72ae 100644 --- a/bitnami/postgresql-ha/templates/postgresql/extended-configmap.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/extended-configmap.yaml @@ -3,16 +3,16 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ printf "%s-extended-configuration" (include "postgresql-ha.postgresql" .) }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql data: -{{- with .Files.Glob "files/conf.d/*.conf" }} -{{ .AsConfig | indent 2 }} -{{- end }} -{{ with .Values.postgresql.extendedConf }} + {{- with .Files.Glob "files/conf.d/*.conf" }} + {{- .AsConfig | nindent 2 }} + {{- end }} + {{- with .Values.postgresql.extendedConf }} override.conf: | -{{- range $key, $value := . }} + {{- range $key, $value := . }} {{ $key | snakecase }}={{ $value }} -{{- end }} -{{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/bitnami/postgresql-ha/templates/postgresql/initdb-scripts-configmap.yaml b/bitnami/postgresql-ha/templates/postgresql/initdb-scripts-configmap.yaml index 0e2caf735..99b4f1d13 100644 --- a/bitnami/postgresql-ha/templates/postgresql/initdb-scripts-configmap.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/initdb-scripts-configmap.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ printf "%s-initdb-scripts" (include "postgresql-ha.postgresql" .) }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql {{- with .Files.Glob "files/docker-entrypoint-initdb.d/*.sql.gz" }} binaryData: @@ -12,10 +12,10 @@ binaryData: {{- end }} {{- end }} data: -{{- with .Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql}" }} -{{ .AsConfig | indent 2 }} -{{- end }} -{{- with .Values.postgresql.initdbScripts }} -{{ toYaml . | indent 2 }} -{{- end }} + {{- with .Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql}" }} + {{- .AsConfig | nindent 2 }} + {{- end }} + {{- with .Values.postgresql.initdbScripts }} + {{- toYaml . | nindent 2 }} + {{- end }} {{- end }} diff --git a/bitnami/postgresql-ha/templates/postgresql/metrics-service.yaml b/bitnami/postgresql-ha/templates/postgresql/metrics-service.yaml index ef0cd5b2e..d13e4c756 100644 --- a/bitnami/postgresql-ha/templates/postgresql/metrics-service.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/metrics-service.yaml @@ -3,15 +3,17 @@ apiVersion: v1 kind: Service metadata: name: {{ include "postgresql-ha.postgresql" . }}-metrics - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql - annotations: {{ toYaml .Values.metrics.annotations | nindent 4 }} + {{- if .Values.metrics.annotations }} + annotations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.metrics.annotations "context" $) | nindent 4 }} + {{- end }} spec: type: ClusterIP ports: - - name: metrics - port: 9187 - targetPort: metrics - selector: {{ include "postgresql-ha.matchLabels" . | nindent 4 }} + - name: metrics + port: 9187 + targetPort: metrics + selector: {{- include "postgresql-ha.matchLabels" . | nindent 4 }} app.kubernetes.io/component: postgresql {{- end }} diff --git a/bitnami/postgresql-ha/templates/postgresql/pdb.yaml b/bitnami/postgresql-ha/templates/postgresql/pdb.yaml index 11709ca6f..c4e7b6d45 100644 --- a/bitnami/postgresql-ha/templates/postgresql/pdb.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/pdb.yaml @@ -3,16 +3,16 @@ apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: name: {{ include "postgresql-ha.postgresql" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql spec: -{{- if .Values.postgresql.pdb.minAvailable }} + {{- if .Values.postgresql.pdb.minAvailable }} minAvailable: {{ .Values.postgresql.pdb.minAvailable }} -{{- end }} -{{- if .Values.postgresql.pdb.maxUnavailable }} + {{- end }} + {{- if .Values.postgresql.pdb.maxUnavailable }} maxUnavailable: {{ .Values.postgresql.pdb.maxUnavailable }} -{{- end }} + {{- end }} selector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 4 }} + matchLabels: {{- include "postgresql-ha.matchLabels" . | nindent 6 }} app.kubernetes.io/component: postgresql {{- end }} diff --git a/bitnami/postgresql-ha/templates/postgresql/secrets.yaml b/bitnami/postgresql-ha/templates/postgresql/secrets.yaml index 54fda12d2..33bd4eef9 100644 --- a/bitnami/postgresql-ha/templates/postgresql/secrets.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/secrets.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ include "postgresql-ha.postgresql" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql type: Opaque data: diff --git a/bitnami/postgresql-ha/templates/postgresql/service-headless.yaml b/bitnami/postgresql-ha/templates/postgresql/service-headless.yaml index 4a407a84a..026b357ab 100644 --- a/bitnami/postgresql-ha/templates/postgresql/service-headless.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/service-headless.yaml @@ -2,14 +2,14 @@ apiVersion: v1 kind: Service metadata: name: {{ include "postgresql-ha.postgresql" . }}-headless - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} spec: type: ClusterIP clusterIP: None ports: - - name: postgresql - port: 5432 - targetPort: postgresql - protocol: TCP - selector: {{ include "postgresql-ha.matchLabels" . | nindent 4 }} + - name: postgresql + port: 5432 + targetPort: postgresql + protocol: TCP + selector: {{- include "postgresql-ha.matchLabels" . | nindent 4 }} app.kubernetes.io/component: postgresql diff --git a/bitnami/postgresql-ha/templates/postgresql/service.yaml b/bitnami/postgresql-ha/templates/postgresql/service.yaml index 9e2675171..053f1580f 100644 --- a/bitnami/postgresql-ha/templates/postgresql/service.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/service.yaml @@ -2,14 +2,14 @@ apiVersion: v1 kind: Service metadata: name: {{ include "postgresql-ha.postgresql" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql spec: type: ClusterIP ports: - - name: postgresql - port: 5432 - targetPort: postgresql - protocol: TCP - selector: {{ include "postgresql-ha.matchLabels" . | nindent 4 }} + - name: postgresql + port: 5432 + targetPort: postgresql + protocol: TCP + selector: {{- include "postgresql-ha.matchLabels" . | nindent 4 }} app.kubernetes.io/component: postgresql diff --git a/bitnami/postgresql-ha/templates/postgresql/servicemonitor.yaml b/bitnami/postgresql-ha/templates/postgresql/servicemonitor.yaml index 437dc8e4d..b2606dd4f 100644 --- a/bitnami/postgresql-ha/templates/postgresql/servicemonitor.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/servicemonitor.yaml @@ -6,24 +6,24 @@ metadata: {{- if .Values.metrics.serviceMonitor.namespace }} namespace: {{ .Values.metrics.serviceMonitor.namespace }} {{- end }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql {{- range $key, $value := .Values.metrics.serviceMonitor.selector }} {{ $key }}: {{ $value | quote }} {{- end }} spec: selector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 6 }} + matchLabels: {{- include "postgresql-ha.matchLabels" . | nindent 6 }} app.kubernetes.io/component: postgresql endpoints: - - port: metrics - {{- if .Values.metrics.serviceMonitor.interval }} - interval: {{ .Values.metrics.serviceMonitor.interval }} - {{- end }} - {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} - scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} - {{- end }} + - port: metrics + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} namespaceSelector: matchNames: - - {{ .Release.Namespace }} + - {{ .Release.Namespace }} {{- end }} diff --git a/bitnami/postgresql-ha/templates/postgresql/statefulset.yaml b/bitnami/postgresql-ha/templates/postgresql/statefulset.yaml index b05b6295e..b9793247e 100644 --- a/bitnami/postgresql-ha/templates/postgresql/statefulset.yaml +++ b/bitnami/postgresql-ha/templates/postgresql/statefulset.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "postgresql-ha.postgresql" . }} - labels: {{ include "postgresql-ha.labels" . | nindent 4 }} + labels: {{- include "postgresql-ha.labels" . | nindent 4 }} app.kubernetes.io/component: postgresql spec: serviceName: {{ include "postgresql-ha.postgresql" . }}-headless @@ -13,40 +13,25 @@ spec: rollingUpdate: null {{- end }} selector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 6 }} + matchLabels: {{- include "postgresql-ha.matchLabels" . | nindent 6 }} app.kubernetes.io/component: postgresql template: metadata: - labels: {{ include "postgresql-ha.labels" . | nindent 8 }} + labels: {{- include "postgresql-ha.labels" . | nindent 8 }} app.kubernetes.io/component: postgresql + {{- if .Values.postgresql.podAnnotations }} + annotations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.postgresql.podAnnotations "context" $) | nindent 8 }} + {{- end }} spec: {{- include "postgresql-ha.imagePullSecrets" . | indent 6 }} - affinity: - {{- if eq .Values.postgresql.antiAffinity "hard" }} - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - topologyKey: "kubernetes.io/hostname" - labelSelector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 18 }} - app.kubernetes.io/component: postgresql - {{- else if eq .Values.postgresql.antiAffinity "soft" }} - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - weight: 1 - podAffinityTerm: - topologyKey: kubernetes.io/hostname - labelSelector: - matchLabels: {{ include "postgresql-ha.matchLabels" . | nindent 18 }} - app.kubernetes.io/component: postgresql - {{- end }} - {{- if .Values.postgresql.nodeAffinity }} - nodeAffinity: {{ toYaml .Values.postgresql.nodeAffinity | nindent 10 }} - {{- end }} - {{- with .Values.postgresql.nodeSelector }} - nodeSelector: {{ tpl (toYaml .) $ | nindent 8 }} + {{- if .Values.postgresql.affinity }} + affinity: {{- include "postgresql-ha.tplValue" (dict "value" .Values.postgresql.affinity "context" $) | nindent 8 }} {{- end }} - {{- with .Values.postgresql.tolerations }} - tolerations: {{ tpl (toYaml .) $ | nindent 8 }} + {{- if .Values.postgresql.nodeSelector }} + nodeSelector: {{- include "postgresql-ha.tplValue" (dict "value" .Values.postgresql.nodeSelector "context" $) | nindent 8 }} + {{- end }} + {{- if .Values.postgresql.tolerations }} + tolerations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.postgresql.tolerations "context" $) | nindent 8 }} {{- end }} {{- if .Values.postgresql.securityContext.enabled }} securityContext: @@ -54,271 +39,271 @@ spec: {{- end }} {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }} initContainers: - - name: init-chmod-data - image: {{ include "postgresql-ha.volumePermissionsImage" . }} - imagePullPolicy: {{ .Values.volumePermissionsImage.pullPolicy | quote }} - command: - - sh - - -c - - | - mkdir -p {{ .Values.persistence.mountPath }}/data - chmod 700 {{ .Values.persistence.mountPath }}/data - find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \ - xargs chown -R {{ .Values.postgresql.securityContext.runAsUser }}:{{ .Values.postgresql.securityContext.fsGroup }} - securityContext: - runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }} - volumeMounts: - - name: data - mountPath: {{ .Values.persistence.mountPath }} + - name: init-chmod-data + image: {{ include "postgresql-ha.volumePermissionsImage" . }} + imagePullPolicy: {{ .Values.volumePermissionsImage.pullPolicy | quote }} + command: + - sh + - -c + - | + mkdir -p {{ .Values.persistence.mountPath }}/data + chmod 700 {{ .Values.persistence.mountPath }}/data + find {{ .Values.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \ + xargs chown -R {{ .Values.postgresql.securityContext.runAsUser }}:{{ .Values.postgresql.securityContext.fsGroup }} + securityContext: + runAsUser: {{ .Values.volumePermissions.securityContext.runAsUser }} + {{- if .Values.volumePermissions.resources }} + resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }} + {{- end }} + volumeMounts: + - name: data + mountPath: {{ .Values.persistence.mountPath }} {{- end }} containers: - - name: postgresql - image: {{ include "postgresql-ha.postgresqlImage" . }} - imagePullPolicy: {{ .Values.postgresqlImage.pullPolicy | quote }} - {{- if .Values.postgresql.securityContext.enabled }} - securityContext: - runAsUser: {{ .Values.postgresql.securityContext.runAsUser }} - {{- end }} - # Auxiliar vars to populate environment variables - {{- $postgresqlReplicaCount := int .Values.postgresql.replicaCount }} - {{- $postgresqlFullname := include "postgresql-ha.postgresql" . }} - {{- $postgresqlHeadlessServiceName := printf "%s-headless" (include "postgresql-ha.postgresql" .) }} - {{- $releaseNamespace := .Release.Namespace }} - {{- $clusterDomain:= .Values.clusterDomain }} - env: - - name: BITNAMI_DEBUG - value: {{ ternary "true" "false" .Values.postgresqlImage.debug | quote }} - # PostgreSQL configuration - - name: POSTGRESQL_VOLUME_DIR - value: {{ .Values.persistence.mountPath | quote }} - - name: PGDATA - value: {{ printf "%s/%s" .Values.persistence.mountPath "data" | quote }} - - name: POSTGRES_USERNAME - value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} - {{- if .Values.postgresql.usePasswordFile }} - - name: POSTGRES_PASSWORD_FILE - value: "/opt/bitnami/postgresql/secrets/postgresql-password" - {{- else }} - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.postgresqlSecretName" . }} - key: postgresql-password - {{- end }} - {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} - - name: POSTGRES_DB - value: {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} - {{- end }} - # Repmgr configuration - - name: MY_POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: REPMGR_UPGRADE_EXTENSION - value: {{ ternary "yes" "no" .Values.postgresql.upgradeRepmgrExtension | quote }} - - name: REPMGR_PGHBA_TRUST_ALL - value: {{ ternary "yes" "no" .Values.postgresql.pgHbaTrustAll | quote }} - - name: REPMGR_MOUNTED_CONF_DIR - value: "/bitnami/repmgr/conf" - - name: REPMGR_PARTNER_NODES - value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }},{{ end }} - - name: REPMGR_PRIMARY_HOST - value: {{ printf "%s-0.%s.%s.svc.%s" $postgresqlFullname $postgresqlHeadlessServiceName .Release.Namespace $clusterDomain | quote }} - - name: REPMGR_NODE_NAME - value: "$(MY_POD_NAME)" - - name: REPMGR_NODE_NETWORK_NAME - value: "$(MY_POD_NAME).{{ $postgresqlHeadlessServiceName }}.{{ .Release.Namespace }}.svc.{{ $clusterDomain }}" - - name: REPMGR_LOG_LEVEL - value: {{ .Values.postgresql.repmgrLogLevel | quote }} - - name: REPMGR_CONNECT_TIMEOUT - value: {{ .Values.postgresql.repmgrConnectTimeout | quote }} - - name: REPMGR_RECONNECT_ATTEMPTS - value: {{ .Values.postgresql.repmgrReconnectAttempts | quote }} - - name: REPMGR_RECONNECT_INTERVAL - value: {{ .Values.postgresql.repmgrReconnectInterval | quote }} - - name: REPMGR_USERNAME - value: {{ (include "postgresql-ha.postgresqlRepmgrUsername" .) | quote }} - {{- if .Values.postgresql.usePasswordFile }} - - name: REPMGR_PASSWORD_FILE - value: "/opt/bitnami/repmgr/secrets/repmgr-password" - {{- else }} - - name: REPMGR_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.postgresqlSecretName" . }} - key: repmgr-password - {{- end }} - {{- if (include "postgresql-ha.repmgrDatabase" .) }} - - name: REPMGR_DATABASE - value: {{ (include "postgresql-ha.repmgrDatabase" .) | quote }} - {{- end }} - ports: - name: postgresql - containerPort: 5432 - protocol: TCP - {{- if .Values.postgresql.livenessProbe.enabled }} - livenessProbe: - exec: - command: - - sh - - -c - {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} - - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 + image: {{ include "postgresql-ha.postgresqlImage" . }} + imagePullPolicy: {{ .Values.postgresqlImage.pullPolicy | quote }} + {{- if .Values.postgresql.securityContext.enabled }} + securityContext: + runAsUser: {{ .Values.postgresql.securityContext.runAsUser }} + {{- end }} + # Auxiliar vars to populate environment variables + {{- $postgresqlReplicaCount := int .Values.postgresql.replicaCount }} + {{- $postgresqlFullname := include "postgresql-ha.postgresql" . }} + {{- $postgresqlHeadlessServiceName := printf "%s-headless" (include "postgresql-ha.postgresql" .) }} + {{- $releaseNamespace := .Release.Namespace }} + {{- $clusterDomain:= .Values.clusterDomain }} + env: + - name: BITNAMI_DEBUG + value: {{ ternary "true" "false" .Values.postgresqlImage.debug | quote }} + # PostgreSQL configuration + - name: POSTGRESQL_VOLUME_DIR + value: {{ .Values.persistence.mountPath | quote }} + - name: PGDATA + value: {{ printf "%s/%s" .Values.persistence.mountPath "data" | quote }} + - name: POSTGRES_USERNAME + value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} + {{- if .Values.postgresql.usePasswordFile }} + - name: POSTGRES_PASSWORD_FILE + value: "/opt/bitnami/postgresql/secrets/postgresql-password" {{- else }} - - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -h 127.0.0.1 + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.postgresqlSecretName" . }} + key: postgresql-password {{- end }} - initialDelaySeconds: {{ .Values.postgresql.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.postgresql.livenessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.postgresql.livenessProbe.timeoutSeconds }} - successThreshold: {{ .Values.postgresql.livenessProbe.successThreshold }} - failureThreshold: {{ .Values.postgresql.livenessProbe.failureThreshold }} - {{- end }} - {{- if .Values.postgresql.readinessProbe.enabled }} - readinessProbe: - exec: - command: - - sh - - -c {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} - - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 + - name: POSTGRES_DB + value: {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} + {{- end }} + # Repmgr configuration + - name: MY_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: REPMGR_UPGRADE_EXTENSION + value: {{ ternary "yes" "no" .Values.postgresql.upgradeRepmgrExtension | quote }} + - name: REPMGR_PGHBA_TRUST_ALL + value: {{ ternary "yes" "no" .Values.postgresql.pgHbaTrustAll | quote }} + - name: REPMGR_MOUNTED_CONF_DIR + value: "/bitnami/repmgr/conf" + - name: REPMGR_PARTNER_NODES + value: {{range $e, $i := until $postgresqlReplicaCount }}{{ $postgresqlFullname }}-{{ $i }}.{{ $postgresqlHeadlessServiceName }}.{{ $releaseNamespace }}.svc.{{ $clusterDomain }},{{ end }} + - name: REPMGR_PRIMARY_HOST + value: {{ printf "%s-0.%s.%s.svc.%s" $postgresqlFullname $postgresqlHeadlessServiceName .Release.Namespace $clusterDomain | quote }} + - name: REPMGR_NODE_NAME + value: "$(MY_POD_NAME)" + - name: REPMGR_NODE_NETWORK_NAME + value: "$(MY_POD_NAME).{{ $postgresqlHeadlessServiceName }}.{{ .Release.Namespace }}.svc.{{ $clusterDomain }}" + - name: REPMGR_LOG_LEVEL + value: {{ .Values.postgresql.repmgrLogLevel | quote }} + - name: REPMGR_CONNECT_TIMEOUT + value: {{ .Values.postgresql.repmgrConnectTimeout | quote }} + - name: REPMGR_RECONNECT_ATTEMPTS + value: {{ .Values.postgresql.repmgrReconnectAttempts | quote }} + - name: REPMGR_RECONNECT_INTERVAL + value: {{ .Values.postgresql.repmgrReconnectInterval | quote }} + - name: REPMGR_USERNAME + value: {{ (include "postgresql-ha.postgresqlRepmgrUsername" .) | quote }} + {{- if .Values.postgresql.usePasswordFile }} + - name: REPMGR_PASSWORD_FILE + value: "/opt/bitnami/repmgr/secrets/repmgr-password" {{- else }} - - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -h 127.0.0.1 + - name: REPMGR_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.postgresqlSecretName" . }} + key: repmgr-password + {{- end }} + {{- if (include "postgresql-ha.repmgrDatabase" .) }} + - name: REPMGR_DATABASE + value: {{ (include "postgresql-ha.repmgrDatabase" .) | quote }} + {{- end }} + ports: + - name: postgresql + containerPort: 5432 + protocol: TCP + {{- if .Values.postgresql.livenessProbe.enabled }} + livenessProbe: + exec: + command: + - sh + - -c + {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} + - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 + {{- else }} + - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -h 127.0.0.1 + {{- end }} + initialDelaySeconds: {{ .Values.postgresql.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.postgresql.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.postgresql.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.postgresql.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.postgresql.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.postgresql.readinessProbe.enabled }} + readinessProbe: + exec: + command: + - sh + - -c + {{- if not (empty (include "postgresql-ha.postgresqlDatabase" .)) }} + - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -d {{ (include "postgresql-ha.postgresqlDatabase" .) | quote }} -h 127.0.0.1 + {{- else }} + - exec pg_isready -U {{ include "postgresql-ha.postgresqlUsername" . | quote }} -h 127.0.0.1 + {{- end }} + initialDelaySeconds: {{ .Values.postgresql.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.postgresql.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.postgresql.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.postgresql.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.postgresql.readinessProbe.failureThreshold }} + {{- end }} + {{- if .Values.postgresql.resources }} + resources: {{- toYaml .Values.postgresql.resources | nindent 12 }} + {{- end }} + volumeMounts: + {{- if or (.Files.Glob "files/repmgr.conf") (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresql.repmgrConfiguration .Values.postgresql.configuration .Values.postgresql.pgHbaConfiguration .Values.postgresql.configurationCM }} + - name: postgresql-config + mountPath: /bitnami/repmgr/conf + {{- end }} + {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresql.extendedConf .Values.postgresql.extendedConfCM }} + - name: postgresql-extended-config + mountPath: /bitnami/repmgr/conf/conf.d/ + {{- end }} + {{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.postgresql.initdbScriptsCM .Values.postgresql.initdbScripts }} + - name: custom-init-scripts + mountPath: /docker-entrypoint-initdb.d/ + {{- end }} + {{- if .Values.postgresql.usePasswordFile }} + - name: postgresql-password + mountPath: /opt/bitnami/postgresql/secrets/ + {{- end }} + {{- if .Values.persistence.enabled }} + - name: data + mountPath: {{ .Values.persistence.mountPath }} + {{- end }} + {{- if .Values.metrics.enabled }} + - name: metrics + image: {{ include "postgresql-ha.metricsImage" . }} + imagePullPolicy: {{ .Values.metricsImage.pullPolicy | quote }} + {{- if .Values.metrics.securityContext.enabled }} + securityContext: + runAsUser: {{ .Values.metrics.securityContext.runAsUser }} + {{- end }} + env: + - name: DATA_SOURCE_URI + value: {{ printf "127.0.0.1:5432/%s?sslmode=disable" (include "postgresql-ha.postgresqlDatabase" .) | quote }} + {{- if .Values.postgresql.usePasswordFile }} + - name: DATA_SOURCE_PASS_FILE + value: "/opt/bitnami/postgresql/secrets/postgresql-password" + {{- else }} + - name: DATA_SOURCE_PASS + valueFrom: + secretKeyRef: + name: {{ include "postgresql-ha.postgresqlSecretName" . }} + key: postgresql-password + {{- end }} + - name: DATA_SOURCE_USER + value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} + ports: + - name: metrics + containerPort: 9187 + protocol: TCP + {{- if .Values.metrics.livenessProbe.enabled }} + livenessProbe: + httpGet: + path: / + port: metrics + initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }} + successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }} + failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }} + {{- end }} + {{- if .Values.metrics.readinessProbe.enabled }} + readinessProbe: + httpGet: + path: / + port: metrics + initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }} + timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }} + successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }} + failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }} + {{- end }} + {{- if .Values.metrics.resources }} + resources: {{- toYaml .Values.metrics.resources | nindent 12 }} + {{- end }} + volumeMounts: + {{- if .Values.postgresql.usePasswordFile }} + - name: postgresql-password + mountPath: /opt/bitnami/postgresql/secrets/ {{- end }} - initialDelaySeconds: {{ .Values.postgresql.readinessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.postgresql.readinessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.postgresql.readinessProbe.timeoutSeconds }} - successThreshold: {{ .Values.postgresql.readinessProbe.successThreshold }} - failureThreshold: {{ .Values.postgresql.readinessProbe.failureThreshold }} {{- end }} - {{- if .Values.postgresql.resources }} - resources: {{- toYaml .Values.postgresql.resources | nindent 10 }} - {{- end }} - volumeMounts: + volumes: {{- if or (.Files.Glob "files/repmgr.conf") (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresql.repmgrConfiguration .Values.postgresql.configuration .Values.postgresql.pgHbaConfiguration .Values.postgresql.configurationCM }} - name: postgresql-config - mountPath: /bitnami/repmgr/conf + configMap: + name: {{ include "postgresql-ha.postgresqlConfigurationCM" . }} {{- end }} {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresql.extendedConf .Values.postgresql.extendedConfCM }} - name: postgresql-extended-config - mountPath: /bitnami/repmgr/conf/conf.d/ + configMap: + name: {{ template "postgresql-ha.postgresqlExtendedConfCM" . }} + {{- end }} + {{- if .Values.postgresql.usePasswordFile }} + - name: postgresql-password + secret: + secretName: {{ include "postgresql-ha.postgresqlSecretName" . }} {{- end }} {{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.postgresql.initdbScriptsCM .Values.postgresql.initdbScripts }} - name: custom-init-scripts - mountPath: /docker-entrypoint-initdb.d/ + configMap: + name: {{ template "postgresql-ha.postgresqlInitdbScriptsCM" . }} {{- end }} - {{- if .Values.postgresql.usePasswordFile }} - - name: postgresql-password - mountPath: /opt/bitnami/postgresql/secrets/ - {{- end }} - {{- if .Values.persistence.enabled }} - - name: data - mountPath: {{ .Values.persistence.mountPath }} - {{- end }} - {{- if .Values.metrics.enabled }} - - name: metrics - image: {{ include "postgresql-ha.metricsImage" . }} - imagePullPolicy: {{ .Values.metricsImage.pullPolicy | quote }} - {{- if .Values.metrics.securityContext.enabled }} - securityContext: - runAsUser: {{ .Values.metrics.securityContext.runAsUser }} - {{- end }} - env: - - name: DATA_SOURCE_URI - value: {{ printf "127.0.0.1:5432/%s?sslmode=disable" (include "postgresql-ha.postgresqlDatabase" .) | quote }} - {{- if .Values.postgresql.usePasswordFile }} - - name: DATA_SOURCE_PASS_FILE - value: "/opt/bitnami/postgresql/secrets/postgresql-password" - {{- else }} - - name: DATA_SOURCE_PASS - valueFrom: - secretKeyRef: - name: {{ include "postgresql-ha.postgresqlSecretName" . }} - key: postgresql-password - {{- end }} - - name: DATA_SOURCE_USER - value: {{ (include "postgresql-ha.postgresqlUsername" .) | quote }} - ports: - - name: metrics - containerPort: 9187 - protocol: TCP - {{- if .Values.metrics.livenessProbe.enabled }} - livenessProbe: - httpGet: - path: / - port: metrics - initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }} - successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }} - failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }} - {{- end }} - {{- if .Values.metrics.readinessProbe.enabled }} - readinessProbe: - httpGet: - path: / - port: metrics - initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }} - timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }} - successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }} - failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }} - {{- end }} - {{- if .Values.metrics.resources }} - resources: {{- toYaml .Values.metrics.resources | nindent 10 }} - {{- end }} - volumeMounts: - {{- if .Values.postgresql.usePasswordFile }} - - name: postgresql-password - mountPath: /opt/bitnami/postgresql/secrets/ - {{- end }} - {{- end }} - volumes: - {{- if or (.Files.Glob "files/repmgr.conf") (.Files.Glob "files/postgresql.conf") (.Files.Glob "files/pg_hba.conf") .Values.postgresql.repmgrConfiguration .Values.postgresql.configuration .Values.postgresql.pgHbaConfiguration .Values.postgresql.configurationCM }} - - name: postgresql-config - configMap: - name: {{ include "postgresql-ha.postgresqlConfigurationCM" . }} - {{- end }} - {{- if or (.Files.Glob "files/conf.d/*.conf") .Values.postgresql.extendedConf .Values.postgresql.extendedConfCM }} - - name: postgresql-extended-config - configMap: - name: {{ template "postgresql-ha.postgresqlExtendedConfCM" . }} - {{- end }} - {{- if .Values.postgresql.usePasswordFile }} - - name: postgresql-password - secret: - secretName: {{ include "postgresql-ha.postgresqlSecretName" . }} - {{- end }} - {{- if or (.Files.Glob "files/docker-entrypoint-initdb.d/*.{sh,sql,sql.gz}") .Values.postgresql.initdbScriptsCM .Values.postgresql.initdbScripts }} - - name: custom-init-scripts - configMap: - name: {{ template "postgresql-ha.postgresqlInitdbScriptsCM" . }} - {{- end }} {{- if and .Values.persistence.enabled .Values.persistence.existingClaim }} - - name: data - persistentVolumeClaim: + - name: data + persistentVolumeClaim: {{- with .Values.persistence.existingClaim }} - claimName: {{ tpl . $ }} + claimName: {{ tpl . $ }} {{- end }} {{- else if not .Values.persistence.enabled }} - - name: data - emptyDir: {} + - name: data + emptyDir: {} {{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} volumeClaimTemplates: - - metadata: - name: data - {{- with .Values.persistence.annotations }} - annotations: - {{- range $key, $value := . }} - {{ $key }}: {{ $value }} - {{- end }} - {{- end }} - spec: - accessModes: - {{- range .Values.persistence.accessModes }} - - {{ . | quote }} - {{- end }} - resources: - requests: - storage: {{ .Values.persistence.size | quote }} -{{ include "postgresql-ha.storageClass" . | indent 6 }} + - metadata: + name: data + {{- if .Values.persistence.annotations }} + annotations: {{- include "postgresql-ha.tplValue" (dict "value" .Values.persistence.annotations "context" $) | nindent 10 }} + {{- end }} + spec: + accessModes: + {{- range .Values.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{ include "postgresql-ha.storageClass" . | indent 8 }} {{- end }} diff --git a/bitnami/postgresql-ha/values-production.yaml b/bitnami/postgresql-ha/values-production.yaml index e558e59c9..811f11801 100644 --- a/bitnami/postgresql-ha/values-production.yaml +++ b/bitnami/postgresql-ha/values-production.yaml @@ -130,15 +130,15 @@ postgresql: ## updateStrategyType: RollingUpdate - ## Pod AntiAffinity - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity + ## Additional pod annotations + ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ ## - antiAffinity: soft + podAnnotations: {} - ## Node Affinity. The value is evaluated as a template. - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature + ## Affinity for pod assignment + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity ## - nodeAffinity: {} + affinity: {} ## Node labels for pod assignment. Evaluated as a template. ## Ref: https://kubernetes.io/docs/user-guide/node-selection/ @@ -158,10 +158,24 @@ postgresql: fsGroup: 1001 runAsUser: 1001 - ## PostgreSQL pods' resource requests and limits + ## PostgreSQL containers' resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## - resources: {} + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 250m + # memory: 256Mi + requests: {} + # cpu: 250m + # memory: 256Mi + + ## PostgreSQL container's liveness and readiness probes + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + ## livenessProbe: enabled: true initialDelaySeconds: 30 @@ -186,11 +200,6 @@ postgresql: minAvailable: 1 # maxUnavailable: 1 - ## Pgpool configuration parameters - ## - adminUsername: admin - # adminPassword: - ## PostgreSQL configuration parameters ## username: postgres @@ -201,6 +210,7 @@ postgresql: ## upgradeRepmgrExtension: false + ## Configures pg_hba.conf to trust every user ## pgHbaTrustAll: false @@ -279,15 +289,15 @@ pgpool: ## replicaCount: 1 - ## Pod AntiAffinity - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity + ## Additional pod annotations + ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ ## - antiAffinity: soft + podAnnotations: {} - ## Node Affinity. The value is evaluated as a template. - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature + ## Affinity for pod assignment + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity ## - nodeAffinity: {} + affinity: {} ## Node labels for pod assignment. Evaluated as a template. ## Ref: https://kubernetes.io/docs/user-guide/node-selection/ @@ -307,10 +317,24 @@ pgpool: fsGroup: 0 runAsUser: 0 - ## Pgpool pods' resource requests and limits + ## Pgpool containers' resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## - resources: {} + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 250m + # memory: 256Mi + requests: {} + # cpu: 250m + # memory: 256Mi + + ## Pgpool container's liveness and readiness probes + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + ## livenessProbe: enabled: true initialDelaySeconds: 30 @@ -335,6 +359,11 @@ pgpool: minAvailable: 1 # maxUnavailable: 1 + ## Pgpool configuration parameters + ## + adminUsername: admin + # adminPassword: + ## LDAP parameters ## ldap: @@ -360,6 +389,20 @@ volumePermissions: ## securityContext: runAsUser: 0 + ## Init container' resource requests and limits + ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ + ## + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 100m + # memory: 128Mi + requests: {} + # cpu: 100m + # memory: 128Mi ## PostgreSQL Prometheus exporter parameters ## @@ -372,10 +415,24 @@ metrics: enabled: true runAsUser: 1001 - ## Prometheus exporter pods' resource requests and limits + ## Prometheus exporter containers' resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## - resources: {} + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 250m + # memory: 256Mi + requests: {} + # cpu: 250m + # memory: 256Mi + + ## Prometheus exporter container's liveness and readiness probes + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + ## livenessProbe: enabled: true initialDelaySeconds: 30 @@ -391,7 +448,7 @@ metrics: successThreshold: 1 failureThreshold: 6 - ## Annotations for Prometheus expoerter + ## Annotations for Prometheus exporter ## annotations: prometheus.io/scrape: "true" @@ -488,21 +545,21 @@ ingress: ## ## If tls is set to true, annotation ingress.kubernetes.io/secure-backends: "true" will automatically be set ## If certManager is set to true, annotation kubernetes.io/tls-acme: "true" will automatically be set - annotations: + annotations: {} # kubernetes.io/ingress.class: nginx ## The list of hostnames to be covered with this ingress record. ## Most likely this will be just one host, but in the event more hosts are needed, this is an array hosts: - - name: postgresql.local - path: / + - name: postgresql.local + path: / ## The tls configuration for the ingress ## see: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls tls: - - hosts: - - postgresql.local - secretName: postgresql.local-tls + - hosts: + - postgresql.local + secretName: postgresql.local-tls secrets: ## If you're providing your own certificates, please use this to add the certificates as secrets diff --git a/bitnami/postgresql-ha/values.yaml b/bitnami/postgresql-ha/values.yaml index 5fe228942..edc8a839f 100644 --- a/bitnami/postgresql-ha/values.yaml +++ b/bitnami/postgresql-ha/values.yaml @@ -130,15 +130,15 @@ postgresql: ## updateStrategyType: RollingUpdate - ## Pod AntiAffinity - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity + ## Additional pod annotations + ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ ## - antiAffinity: soft + podAnnotations: {} - ## Node Affinity. The value is evaluated as a template. - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature + ## Affinity for pod assignment + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity ## - nodeAffinity: {} + affinity: {} ## Node labels for pod assignment. Evaluated as a template. ## Ref: https://kubernetes.io/docs/user-guide/node-selection/ @@ -158,10 +158,24 @@ postgresql: fsGroup: 1001 runAsUser: 1001 - ## PostgreSQL pods' resource requests and limits + ## PostgreSQL containers' resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## - resources: {} + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 250m + # memory: 256Mi + requests: {} + # cpu: 250m + # memory: 256Mi + + ## PostgreSQL container's liveness and readiness probes + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + ## livenessProbe: enabled: true initialDelaySeconds: 30 @@ -275,15 +289,15 @@ pgpool: ## replicaCount: 1 - ## Pod AntiAffinity - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity + ## Additional pod annotations + ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ ## - antiAffinity: soft + podAnnotations: {} - ## Node Affinity. The value is evaluated as a template. - ## ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity-beta-feature + ## Affinity for pod assignment + ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity ## - nodeAffinity: {} + affinity: {} ## Node labels for pod assignment. Evaluated as a template. ## Ref: https://kubernetes.io/docs/user-guide/node-selection/ @@ -303,10 +317,24 @@ pgpool: fsGroup: 0 runAsUser: 0 - ## Pgpool pods' resource requests and limits + ## Pgpool containers' resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## - resources: {} + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 250m + # memory: 256Mi + requests: {} + # cpu: 250m + # memory: 256Mi + + ## Pgpool container's liveness and readiness probes + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + ## livenessProbe: enabled: true initialDelaySeconds: 30 @@ -361,6 +389,20 @@ volumePermissions: ## securityContext: runAsUser: 0 + ## Init container' resource requests and limits + ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ + ## + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 100m + # memory: 128Mi + requests: {} + # cpu: 100m + # memory: 128Mi ## PostgreSQL Prometheus exporter parameters ## @@ -373,10 +415,24 @@ metrics: enabled: true runAsUser: 1001 - ## Prometheus exporter pods' resource requests and limits + ## Prometheus exporter containers' resource requests and limits ## ref: http://kubernetes.io/docs/user-guide/compute-resources/ ## - resources: {} + resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + limits: {} + # cpu: 250m + # memory: 256Mi + requests: {} + # cpu: 250m + # memory: 256Mi + + ## Prometheus exporter container's liveness and readiness probes + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + ## livenessProbe: enabled: true initialDelaySeconds: 30 @@ -489,21 +545,21 @@ ingress: ## ## If tls is set to true, annotation ingress.kubernetes.io/secure-backends: "true" will automatically be set ## If certManager is set to true, annotation kubernetes.io/tls-acme: "true" will automatically be set - annotations: + annotations: {} # kubernetes.io/ingress.class: nginx ## The list of hostnames to be covered with this ingress record. ## Most likely this will be just one host, but in the event more hosts are needed, this is an array hosts: - - name: postgresql.local - path: / + - name: postgresql.local + path: / ## The tls configuration for the ingress ## see: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls tls: - - hosts: - - postgresql.local - secretName: postgresql.local-tls + - hosts: + - postgresql.local + secretName: postgresql.local-tls secrets: ## If you're providing your own certificates, please use this to add the certificates as secrets From 2acb1b328f2df9b45588ddb1493346524493368a Mon Sep 17 00:00:00 2001 From: Bitnami Containers Date: Mon, 25 Nov 2019 17:11:23 +0000 Subject: [PATCH 2/2] [bitnami/postgresql-ha] Update components versions Signed-off-by: Bitnami Containers --- bitnami/postgresql-ha/values-production.yaml | 6 +++--- bitnami/postgresql-ha/values.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bitnami/postgresql-ha/values-production.yaml b/bitnami/postgresql-ha/values-production.yaml index 811f11801..79cd732f8 100644 --- a/bitnami/postgresql-ha/values-production.yaml +++ b/bitnami/postgresql-ha/values-production.yaml @@ -29,7 +29,7 @@ postgresqlImage: registry: docker.io repository: bitnami/postgresql-repmgr - tag: 11.6.0-debian-9-r0 + tag: 11.6.0-debian-9-r7 ## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## @@ -51,7 +51,7 @@ postgresqlImage: pgpoolImage: registry: docker.io repository: bitnami/pgpool - tag: 4.1.0-debian-9-r10 + tag: 4.1.0-debian-9-r20 ## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## @@ -90,7 +90,7 @@ volumePermissionsImage: metricsImage: registry: docker.io repository: bitnami/postgres-exporter - tag: 0.7.0-debian-9-r12 + tag: 0.8.0-debian-9-r0 ## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## diff --git a/bitnami/postgresql-ha/values.yaml b/bitnami/postgresql-ha/values.yaml index edc8a839f..c22c600b3 100644 --- a/bitnami/postgresql-ha/values.yaml +++ b/bitnami/postgresql-ha/values.yaml @@ -29,7 +29,7 @@ postgresqlImage: registry: docker.io repository: bitnami/postgresql-repmgr - tag: 11.6.0-debian-9-r0 + tag: 11.6.0-debian-9-r7 ## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## @@ -51,7 +51,7 @@ postgresqlImage: pgpoolImage: registry: docker.io repository: bitnami/pgpool - tag: 4.1.0-debian-9-r10 + tag: 4.1.0-debian-9-r20 ## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ## @@ -90,7 +90,7 @@ volumePermissionsImage: metricsImage: registry: docker.io repository: bitnami/postgres-exporter - tag: 0.7.0-debian-9-r12 + tag: 0.8.0-debian-9-r0 ## Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images ##