# generamos un deployment para levantar replicas de contenedores postgres
# comparten un volumen ... para persistir /data
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  #replicas: 2
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:12
        ports:
        - containerPort: 5432
        env:
        - name: POSTGRES_DB
          value: postgres
        - name: POSTGRES_USER
          value: postgres
        - name: POSTGRES_PASSWORD
          value: postgres
        volumeMounts:
          - mountPath: /var/lib/postgresql/data
            name: postgres-pv-claim
      volumes:
      - name: postgres-pv-claim
        persistentVolumeClaim:
          claimName: postgres-pv-claim