apiVersion: apps/v1
kind: Deployment
metadata:
    name: postgres
spec:
    replicas: 1
    selector:
        matchLabels:
            app: postgres
    template:
        metadata:
            labels:
                app: postgres
        spec:
            volumes:
                -   name: postgres-pv-storage
                    persistentVolumeClaim:
                        claimName: postgres-pv-claim
            containers:
                -   name: postgres
                    image: postgres:11
                    imagePullPolicy: IfNotPresent
                    ports:
                        -   containerPort: 5432
                    env:
                        -   name: POSTGRES_PASSWORD
                            valueFrom:
                                secretKeyRef:
                                    name: postgres-secret-config
                                    key: password
                        -   name: PGDATA
                            value: /var/lib/postgresql/data/pgdata
                    volumeMounts:
                        -   mountPath: /var/lib/postgresql/data
                            name: postgres-pv-storage
