I am trying to create a minimal postgres deployment with helm with the admin user called postgres and a user called user. I am hardcoding the passwords for now, the pod is being created correctly but i can't access to the database!
Here's my terraform code:
resource "helm_release" "postgres" {
name = "pg-${var.namespace}"
namespace = var.namespace
chart = "postgresql"
repository = "https://charts.bitnami.com/bitnami"
version = "13.4.4"
values = [templatefile("manifests/postgres-values.yaml", {
fullnameOverride = "pg-${var.namespace}"
pg_spot = var.pg_spot
pg_affinity = var.pg_affinity
pg_nodeSelector = var.pg_nodeSelector
pg_tolerations = var.pg_tolerations
db_pass = "postgres"
})]
set_sensitive {
name = "db_pass"
value = "postgres"
}
}
and here's how my manifests/postgres-values.yaml looks like:
fullnameOverride: ${fullnameOverride}
global:
storageClass: managed-csi
postgresql:
auth:
postgresPassword: "postgresadmin"
username: "user"
password: "postgres"
service:
ports:
postgresql: 5432
primary:
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 100m
memory: 256Mi
persistence:
enabled: true
size: 1Gi
labels:
purpose: pg
persistentVolumeClaimRetentionPolicy:
enabled: true
whenDeleted: Retain
${indent(2, pg_nodeSelector)}
${indent(2, pg_tolerations)}
architecture: standalone
I get my helm chart deployed correctly and my pod is running but when I execute:
psql -h localhost -p 5432 -U postgres
and provide postgresadmin as password, i get this error:
psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "postgres"
As if the user is not being created !!
Any ideas?
The postgresPassword is stored within the persistent volume and only set on first deployment. You may have deployed the postgres chart already before with another (or unset) postgresPassword. Due to enabled persistency you have to remove the PVC manually and then deploy the helmchart again.