apiVersion: apps/v1
kind: Deployment
metadata:
  name: sip-db
  namespace: default
spec:
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  replicas: 5
  selector:
    matchLabels:
      app: sip-db # identifier
  template:
    metadata:
      labels:
        app: sip-db # identifier
    spec:
      containers:
        - name: sip-db # container name
          image: postgres:alpine
          resources:
            requests:
              cpu: "1"
              memory: "1Gi"
            limits:
              cpu: "1"
              memory: "5Gi"
          ports:
            - containerPort: 5432
          env:
            - name: PGDATA
              value: /var/lib/postgresql/data/pgdata
          envFrom:
            - configMapRef:
                name: sip-db-configmap # Must match with ConfigMap identifier
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              # identifier
              name: postgredb
      volumes:
        - name: postgredb # Must match volumeMounts identifier
          persistentVolumeClaim:
            claimName: sip-postgres-pvc # Must match withc PVC identifier

            # kubectl exec -it <pod_name> /bin/bash
            # psql -U sip -p 5432 sip