bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.94k stars 9.18k forks source link

[bitnami/postgresql-ha] Add serviceLabels errors #11451

Closed bastienbosser closed 2 years ago

bastienbosser commented 2 years ago

Name and Version

bitnami/postgresql-ha 9.2.5

What steps will reproduce the bug?

  1. In kubernetes environment v1.21.4
  2. With standart config and the additional values provided below
  3. Run 'helm install my-postgresql-ha postgresql-ha-9.2.5.tgz -f postgres-ha/values.yml'
  4. See error 'Error: YAML parse error on postgresql-ha/templates/postgresql/service.yaml: error converting YAML to JSON: yaml: line 12: mapping values are not allowed in this context'

Are you using any custom parameters or values?

cat values.yaml
...
1488   ## @param service.serviceLabels Labels for PostgreSQL service
1489   ##
1490   serviceLabels: { "app.kubernetes.io/part-of": "my-postgresql-ha" }

What is the expected behavior?

helm install my-postgresql-ha postgresql-ha-9.2.5.tgz -f postgres-ha/values.yml
NAME: my-postgresql-ha
LAST DEPLOYED: Mon Aug  1 13:42:54 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql-ha
CHART VERSION: 9.2.5
APP VERSION: 14.4.0
** Please be patient while the chart is being deployed **
PostgreSQL can be accessed through Pgpool via port 5432 on the following DNS name from within your cluster:

    my-postgresql-ha-pgpool.default.svc.kube.local

Pgpool acts as a load balancer for PostgreSQL and forward read/write connections to the primary node while read-only connections are forwarded to standby nodes.

To get the password for "postgres" run:

    export POSTGRES_PASSWORD=$(kubectl get secret --namespace default my-postgresql-ha-postgresql -o jsonpath="{.data.postgresql-password}" | base64 -d)

To get the password for "repmgr" run:

    export REPMGR_PASSWORD=$(kubectl get secret --namespace default my-postgresql-ha-postgresql -o jsonpath="{.data.repmgr-password}" | base64 -d)

To connect to your database run the following command:

    kubectl run my-postgresql-ha-client --rm --tty -i --restart='Never' --namespace default --image registry.regionadmin.svc.kube.local:5000/atos/postgresql-repmgr:14.4.0-debian-11-r13 --env="PGPASSWORD=$POSTGRES_PASSWORD"  \
        --command -- psql -h my-postgresql-ha-pgpool -p 5432 -U postgres -d quay

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/my-postgresql-ha-pgpool 5432:5432 &
    psql -h 127.0.0.1 -p 5432 -U postgres -d quay

What do you see instead?

helm install my-postgresql-ha postgresql-ha-9.2.5.tgz -f postgres-ha/values.yml
Error: YAML parse error on postgresql-ha/templates/postgresql/service.yaml: error converting YAML to JSON: yaml: line 12: mapping values are not allowed in this context

Additional information

I think the problem is in this section:

cat bitnami/charts/postgres-ha/templates/postgres/service.yaml
...
11    {{- if .Values.service.serviceLabels }}
12    {{ toYaml .Values.service.serviceLabels | indent 4 }}
13    {{- end }}

Maybe this correction would be appropriate:

cat bitnami/charts/postgres-ha/templates/postgres/service.yaml
...
11    {{- if .Values.service.serviceLabels }}
12    {{- include "common.tplvalues.render" ( dict "value" .Values.service.serviceLabels "context" $ ) | nindent 4 }}
13    {{- end }}
javsalgar commented 2 years ago

Hi,

Thank you so much for reporting. I agree that the solution should be the one you mentioned. Would you like to submit a PR with the fix?

bastienbosser commented 2 years ago

Hi,

I am willing to submit a PR with the patch.

javsalgar commented 2 years ago

Thank you so much for the PR! The team will take a look