apiVersion: apps/v1
kind: Deployment
metadata:
 name: pgadmin
 namespace: postgres
spec:
 replicas: 1
 selector:
   matchLabels:
     app: pgadmin
 template:
   metadata:
     labels:
       app: pgadmin
   spec:
     initContainers:
       - name: pgadmin-init
         image: alpine
         args: [ "sh", "-c", "chown 5050:5050 /var/lib/pgadmin " ]
         volumeMounts:
         - name: pgadmin-data
           mountPath: /var/lib/pgadmin
     containers:
       - name: pgadmin
         image: dpage/pgadmin4:5.5
         imagePullPolicy: Always
         env:
         - name: PGADMIN_DEFAULT_EMAIL
           value: celestino.rey@gmail.com
         - name: PGADMIN_DEFAULT_PASSWORD
           valueFrom:
             secretKeyRef:
               name: pgadmin
               key: pgadmin-password
         volumeMounts:
         - name: pgadmin-config
           mountPath: /pgadmin4/servers.json
           subPath: servers.json
           readOnly: true
         - name: pgadmin-data
           mountPath: /var/lib/pgadmin
     volumes:
     - name: pgadmin-config
       configMap:
         name: pgadmin-config
     - name: pgadmin-data
       persistentVolumeClaim:
         claimName: pgadmin-pv-claim
