The simplest PostgreSQL K8s deployment

Below a postgres deployment, no suitable for any prod (even do not have persistence).

apiVersion: v1
kind: ConfigMap
metadata:
  name: rdbms
  labels:
    app: rdbms
    component: database
data:
  POSTGRES_DB: database
  POSTGRES_USER: user
  POSTGRES_PASSWORD: admin123

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rdbms
  labels:
    app: rdbms
    component: database
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rdbms
      component: database
  template:
    metadata:
      labels:
        app: rdbms
        component: database
    spec:
      containers:
        - name: postgres
          image: postgres:13.5-bullseye
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 5432
          envFrom:
            - configMapRef:
                name: rdbms
---

apiVersion: v1
kind: Service
metadata:
  name: rdbms
  labels:
    app: rdbms
    component: database
spec:
  ports:
    - port: 5432
  selector:
    app: rdbms
    component: database

Running a postgresql client

kubectl run postgresql-client --rm --tty -i --restart='Never' --image postgres:14.1-bullseye --command -- psql  -h rdbms -U user -p 5432 database