I just can't figure out why it is working the way it is. If I
- use POSTGRES_PASSWORD with hardcoded value in environment it works
- use POSTGRES_PASSWORD from a secret with valueFrom: secretKeyRef: it works
- use POSTGRES_USER OR POSTGRES_DB with hardcoded values in environment it works
But if I try to use POSTGRES_USER OR POSTGRES_DB from secret it won't work no matter what I do. And yes after each try I cleared the PV so the pod would be regenerated from scratch.
I want my PostgreSQL Deployment to look something like this:
containers:
- name: postgresql
image: postgres
imagePullPolicy: "IfNotPresent"
# ports:
# - containerPort: 5432
env:
- name: POSTGRES_DB
value: whatever
- name: POSTGRES_USER
# value: login
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: username
- name: POSTGRES_PASSWORD
# value: pass
valueFrom:
secretKeyRef:
name: postgresql-credentials
key: password
The secret looks like this:
apiVersion: v1
kind: Secret
data:
username: dXNlcgo=
password: cGFzcwo=
metadata:
name: postgresql-credentials