apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
spec:
  selector:
    matchLabels:
      app: postgres
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: postgres:13
          imagePullPolicy: Always
          ports:
            - containerPort: 5432
              protocol: TCP
          env:
            - name: POSTGRES_USER
              value: user
            - name: POSTGRES_PASSWORD
              value: password
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-data
              subPath: data
      volumes:
        - name: postgres-data
          persistentVolumeClaim:
            claimName: postgres-data-disk
