Postgresql container in kubernetes doesn't use POSTGRES_PASSWORD env

Asking for help? Comment out what you need so we can get more information to help you!

Hi
I’ve got a problem with creating container with postgresql image. Down below is yaml
I successfully create container with this configuration and I can enter this DB, BUT env POSTGRES_PASSWORD doesn’t work. It means it is possible to enter this Database with NO Password.
But I set password by using
- name: POSTGRES_PASSWORD
** value: user**

Why so? There are a lot of tutorials, but all containers, created using these tutorials, don’t implement Password info

In details I’m trying something like this:
kubectl exec POD_NAME – psql -h localhost -U user --password -p 5432 postgres - And no need to enter password, but i want to enter the Database only with Password

Cluster information:

Kubernetes version: v4.5.7
Cloud being used: (put bare-metal if not on a public cloud)
Installation method:
Host OS: Windows 10
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to rea

apiVersion: apps/v1
kind: Deployment
metadata:
name: example-postgres
labels:
app: example-app
spec:
replicas: 1
selector:
matchLabels:
app: example-app
tier: postgres
template:
metadata:
labels:
app: example-app
tier: postgres
spec:
containers:
- image: postgres
name: postgres
env:
- name: POSTGRES_DB
value: postgres
- name: POSTGRES_USER
value: user
- name: POSTGRES_PASSWORD
value: user
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
- containerPort: 5432
name: postgres

apiVersion: v1
kind: Service
metadata:
name: example-postgres
labels:
app: example-app
spec:
ports:
- port: 5432
type: LoadBalancer
selector:
app: example-app
tier: postgres