[bitnami/postgresql] Support for global postgresql fullnameOverride (#33616)

This commit is contained in:
Koren Peretz
2025-05-13 12:14:16 +03:00
committed by GitHub
parent 61b330aa4f
commit 7e006db0e1
14 changed files with 44 additions and 32 deletions

View File

@@ -1,8 +1,12 @@
# Changelog
## 16.7.3 (2025-05-12)
## 16.7.4 (2025-05-13)
* [bitnami/postgresql] :zap: :arrow_up: Update dependency references ([#33619](https://github.com/bitnami/charts/pull/33619))
* [bitnami/postgresql] Support for global postgresql fullnameOverride ([#33616](https://github.com/bitnami/charts/pull/33616))
## <small>16.7.3 (2025-05-13)</small>
* [bitnami/postgresql] :zap: :arrow_up: Update dependency references (#33619) ([ab01617](https://github.com/bitnami/charts/commit/ab0161760fa3754e64945e5a94fd95866c8b929e)), closes [#33619](https://github.com/bitnami/charts/issues/33619)
## <small>16.7.2 (2025-05-09)</small>

View File

@@ -38,4 +38,4 @@ maintainers:
name: postgresql
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/postgresql
version: 16.7.3
version: 16.7.4

View File

@@ -28,7 +28,7 @@ In order to replicate the container startup scripts execute this command:
{{- else }}
{{- $customUser := include "postgresql.v1.username" . }}
{{- $postgresPassword := include "common.secrets.lookup" (dict "secret" (include "common.names.fullname" .) "key" .Values.auth.secretKeys.adminPasswordKey "defaultValue" (ternary .Values.auth.postgresPassword .Values.auth.password (eq $customUser "postgres")) "context" $) -}}
{{- $postgresPassword := include "common.secrets.lookup" (dict "secret" (include "postgresql.v1.chart.fullname" .) "key" .Values.auth.secretKeys.adminPasswordKey "defaultValue" (ternary .Values.auth.postgresPassword .Values.auth.password (eq $customUser "postgres")) "context" $) -}}
{{- $authEnabled := and (not (or .Values.global.postgresql.auth.existingSecret .Values.auth.existingSecret)) (or $postgresPassword .Values.auth.enablePostgresUser (and (not (empty $customUser)) (ne $customUser "postgres"))) }}
{{- if not $authEnabled }}
@@ -68,11 +68,11 @@ To get the password for "{{ default "postgres" $customUser }}" run:
To connect to your database run the following command:
{{- if $authEnabled }}
kubectl run {{ include "common.names.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ $releaseNamespace }} --image {{ include "postgresql.v1.image" . }} --env="PGPASSWORD=$POSTGRES_PASSWORD" \
kubectl run {{ include "postgresql.v1.chart.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ $releaseNamespace }} --image {{ include "postgresql.v1.image" . }} --env="PGPASSWORD=$POSTGRES_PASSWORD" \
--command -- psql --host {{ include "postgresql.v1.primary.fullname" . }} -U {{ default "postgres" $customUser }} -d {{- if include "postgresql.v1.database" . }} {{ include "postgresql.v1.database" . }}{{- else }} postgres{{- end }} -p {{ include "postgresql.v1.service.port" . }}
{{- else }}
kubectl run {{ include "common.names.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ $releaseNamespace }} --image {{ include "postgresql.v1.image" . }} \
kubectl run {{ include "postgresql.v1.chart.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ $releaseNamespace }} --image {{ include "postgresql.v1.image" . }} \
--command -- psql --host {{ include "postgresql.v1.primary.fullname" . }} -d {{- if include "postgresql.v1.database" . }} {{ include "postgresql.v1.database" . }}{{- else }} postgres{{- end }} -p {{ include "postgresql.v1.service.port" . }}
{{- end }}

View File

@@ -5,12 +5,20 @@ SPDX-License-Identifier: APACHE-2.0
{{/* vim: set filetype=mustache: */}}
{{/*
Create a global name for the chart to use and parse with other naming functions
Please use instead of "common.names.fullname" to preserve support for .Values.global.postgresql.fullnameOverride
*/}}
{{- define "postgresql.v1.chart.fullname" -}}
{{- default (include "common.names.fullname" .) .Values.global.postgresql.fullnameOverride -}}
{{- end -}}
{{/*
Create a default fully qualified app name for PostgreSQL Primary objects
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "postgresql.v1.primary.fullname" -}}
{{- $fullname := default (include "common.names.fullname" .) .Values.global.postgresql.fullnameOverride -}}
{{- $fullname := include "postgresql.v1.chart.fullname" . -}}
{{- ternary (printf "%s-%s" $fullname .Values.primary.name | trunc 63 | trimSuffix "-") $fullname (eq .Values.architecture "replication") -}}
{{- end -}}
@@ -19,7 +27,7 @@ Create a default fully qualified app name for PostgreSQL read-only replicas obje
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "postgresql.v1.readReplica.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) .Values.readReplicas.name | trunc 63 | trimSuffix "-" -}}
{{- printf "%s-%s" (include "postgresql.v1.chart.fullname" .) .Values.readReplicas.name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
@@ -97,7 +105,7 @@ Get the password secret.
{{- else if .Values.auth.existingSecret -}}
{{- printf "%s" (tpl .Values.auth.existingSecret $) -}}
{{- else -}}
{{- printf "%s" (include "common.names.fullname" .) -}}
{{- printf "%s" (include "postgresql.v1.chart.fullname" .) -}}
{{- end -}}
{{- end -}}
@@ -157,7 +165,7 @@ Return true if a secret object should be created
*/}}
{{- define "postgresql.v1.createSecret" -}}
{{- $customUser := include "postgresql.v1.username" . -}}
{{- $postgresPassword := include "common.secrets.lookup" (dict "secret" (include "common.names.fullname" .) "key" .Values.auth.secretKeys.adminPasswordKey "defaultValue" (ternary (coalesce .Values.global.postgresql.auth.postgresPassword .Values.auth.postgresPassword .Values.global.postgresql.auth.password .Values.auth.password) (coalesce .Values.global.postgresql.auth.postgresPassword .Values.auth.postgresPassword) (or (empty $customUser) (eq $customUser "postgres"))) "context" $) -}}
{{- $postgresPassword := include "common.secrets.lookup" (dict "secret" (include "postgresql.v1.chart.fullname" .) "key" .Values.auth.secretKeys.adminPasswordKey "defaultValue" (ternary (coalesce .Values.global.postgresql.auth.postgresPassword .Values.auth.postgresPassword .Values.global.postgresql.auth.password .Values.auth.password) (coalesce .Values.global.postgresql.auth.postgresPassword .Values.auth.postgresPassword) (or (empty $customUser) (eq $customUser "postgres"))) "context" $) -}}
{{- if and (not (or .Values.global.postgresql.auth.existingSecret .Values.auth.existingSecret)) (or $postgresPassword .Values.auth.enablePostgresUser (and (not (empty $customUser)) (ne $customUser "postgres")) (eq .Values.architecture "replication") (and .Values.ldap.enabled (or .Values.ldap.bind_password .Values.ldap.bindpw))) -}}
{{- true -}}
{{- end -}}
@@ -181,10 +189,10 @@ Return the secret with previous PostgreSQL credentials
{{- tpl .Values.passwordUpdateJob.previousPasswords.existingSecret $ -}}
{{- else if .Values.passwordUpdateJob.previousPasswords.postgresPassword -}}
{{- /* The secret with the new password is managed externally */ -}}
{{- printf "%s-previous-secret" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- printf "%s-previous-secret" (include "postgresql.v1.chart.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- /* The secret with the new password is managed by the helm chart. We use the current secret name as it has the old password */ -}}
{{- include "common.names.fullname" . -}}
{{- include "postgresql.v1.chart.fullname" . -}}
{{- end -}}
{{- end -}}
@@ -194,7 +202,7 @@ Return the secret with new PostgreSQL credentials
{{- define "postgresql.v1.update-job.newSecretName" -}}
{{- if and (not .Values.passwordUpdateJob.previousPasswords.existingSecret) (not .Values.passwordUpdateJob.previousPasswords.postgresPassword) -}}
{{- /* The secret with the new password is managed by the helm chart. We create a new secret as the current one has the old password */ -}}
{{- printf "%s-new-secret" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- printf "%s-new-secret" (include "postgresql.v1.chart.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- /* The secret with the new password is managed externally */ -}}
{{- include "postgresql.v1.secretName" . -}}
@@ -287,7 +295,7 @@ Return true if a configmap object should be created for PostgreSQL read replica
*/}}
{{- define "postgresql.v1.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
{{ default (include "postgresql.v1.chart.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
@@ -445,7 +453,7 @@ Return the path to the CA cert file.
*/}}
{{- define "postgresql.v1.tlsSecretName" -}}
{{- if .Values.tls.autoGenerated -}}
{{- printf "%s-crt" (include "common.names.fullname" .) -}}
{{- printf "%s-crt" (include "postgresql.v1.chart.fullname" .) -}}
{{- else -}}
{{ tpl (required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret) . }}
{{- end -}}

View File

@@ -7,7 +7,7 @@ SPDX-License-Identifier: APACHE-2.0
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "common.names.fullname" . }}
name: {{ include "postgresql.v1.chart.fullname" . }}
namespace: {{ coalesce .Values.metrics.prometheusRule.namespace (include "common.names.namespace" .) | quote }}
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics.prometheusRule.labels .Values.commonLabels ) "context" . ) }}
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
@@ -17,6 +17,6 @@ metadata:
{{- end }}
spec:
groups:
- name: {{ include "common.names.fullname" . }}
- name: {{ include "postgresql.v1.chart.fullname" . }}
rules: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.prometheusRule.rules "context" $ ) | nindent 8 }}
{{- end }}

View File

@@ -7,7 +7,7 @@ SPDX-License-Identifier: APACHE-2.0
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: {{ include "common.names.fullname" . }}
name: {{ include "postgresql.v1.chart.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}

View File

@@ -7,7 +7,7 @@ SPDX-License-Identifier: APACHE-2.0
kind: Role
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ include "common.names.fullname" . }}
name: {{ include "postgresql.v1.chart.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
@@ -23,7 +23,7 @@ rules:
verbs:
- 'use'
resourceNames:
- {{ include "common.names.fullname" . }}
- {{ include "postgresql.v1.chart.fullname" . }}
{{- end }}
{{- if .Values.rbac.rules }}
{{- include "common.tplvalues.render" ( dict "value" .Values.rbac.rules "context" $ ) | nindent 2 }}

View File

@@ -7,7 +7,7 @@ SPDX-License-Identifier: APACHE-2.0
kind: RoleBinding
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
name: {{ include "common.names.fullname" . }}
name: {{ include "postgresql.v1.chart.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if .Values.commonAnnotations }}
@@ -15,7 +15,7 @@ metadata:
{{- end }}
roleRef:
kind: Role
name: {{ include "common.names.fullname" . }}
name: {{ include "postgresql.v1.chart.fullname" . }}
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount

View File

@@ -30,7 +30,7 @@ SPDX-License-Identifier: APACHE-2.0
apiVersion: v1
kind: Secret
metadata:
name: {{ include "common.names.fullname" . }}
name: {{ include "postgresql.v1.chart.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.secretAnnotations .Values.commonAnnotations }}
@@ -64,7 +64,7 @@ data:
apiVersion: v1
kind: Secret
metadata:
name: {{ include "common.names.fullname" . }}-svcbind-postgres
name: {{ include "postgresql.v1.chart.fullname" . }}-svcbind-postgres
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.secretAnnotations .Values.commonAnnotations }}
@@ -92,7 +92,7 @@ data:
apiVersion: v1
kind: Secret
metadata:
name: {{ include "common.names.fullname" . }}-svcbind-custom-user
name: {{ include "postgresql.v1.chart.fullname" . }}-svcbind-custom-user
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- if or .Values.secretAnnotations .Values.commonAnnotations }}

View File

@@ -4,9 +4,9 @@ SPDX-License-Identifier: APACHE-2.0
*/}}
{{- if (include "postgresql.v1.createTlsSecret" . ) }}
{{- $secretName := printf "%s-crt" (include "common.names.fullname" .) }}
{{- $secretName := printf "%s-crt" (include "postgresql.v1.chart.fullname" .) }}
{{- $ca := genCA "postgresql-ca" 365 }}
{{- $fullname := include "common.names.fullname" . }}
{{- $fullname := include "postgresql.v1.chart.fullname" . }}
{{- $releaseNamespace := include "common.names.namespace" . }}
{{- $clusterDomain := .Values.clusterDomain }}
{{- $primaryHeadlessServiceName := include "postgresql.v1.primary.svc.headless" . }}

View File

@@ -7,7 +7,7 @@ SPDX-License-Identifier: APACHE-2.0
apiVersion: batch/v1
kind: Job
metadata:
name: {{ printf "%s-password-update" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
name: {{ printf "%s-password-update" (include "postgresql.v1.chart.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: postgresql

View File

@@ -11,7 +11,7 @@ SPDX-License-Identifier: APACHE-2.0
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-new-secret" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
name: {{ printf "%s-new-secret" (include "postgresql.v1.chart.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: postgresql

View File

@@ -11,7 +11,7 @@ SPDX-License-Identifier: APACHE-2.0
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-previous-secret" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
name: {{ printf "%s-previous-secret" (include "postgresql.v1.chart.fullname" .) | trunc 63 | trimSuffix "-" }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
app.kubernetes.io/part-of: postgresql

View File

@@ -1922,12 +1922,12 @@ metrics:
## Make sure to constraint the rules to the current postgresql service.
## rules:
## - alert: HugeReplicationLag
## expr: pg_replication_lag{service="{{ printf "%s-metrics" (include "common.names.fullname" .) }}"} / 3600 > 1
## expr: pg_replication_lag{service="{{ printf "%s-metrics" (include "postgresql.v1.chart.fullname" .) }}"} / 3600 > 1
## for: 1m
## labels:
## severity: critical
## annotations:
## description: replication for {{ include "common.names.fullname" . }} PostgreSQL is lagging by {{ "{{ $value }}" }} hour(s).
## description: replication for {{ include "postgresql.v1.chart.fullname" . }} PostgreSQL is lagging by {{ "{{ $value }}" }} hour(s).
## summary: PostgreSQL replication is lagging by {{ "{{ $value }}" }} hour(s).
##
rules: []