apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-primary
  namespace: k8s-demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
      role: primary
      tier: backend
  template:
    metadata:
      labels:
        app: postgres
        role: primary
        tier: backend
    spec:
      containers:
        - name: postgres
          image: postgres:13.2
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
          ports:
            - containerPort: 5432
          envFrom:
            - configMapRef:
                name: postgres-config
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgredb
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pv-claim
