apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  namespace: default
  labels:
    app: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres
        imagePullPolicy: Always
        ports:
        - containerPort: 5432
        env:
          - name: POSTGRES_PASSWORD
            value: "password"
        volumeMounts:
          - mountPath: /var/lib/postgres/data
            name: postgres
      restartPolicy: Always
      volumes:
        - name: postgres
          persistentVolumeClaim:
            claimName: postgres