apiVersion: apps/v1
kind: Deployment
metadata:
  name: pgadmin
  namespace: postgres
  labels:
    app: pgadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pgadmin
  template:
    metadata:
      labels:
        app: pgadmin
    spec:
      containers:
      - name: pgadmin
        image: dpage/pgadmin4
        ports:
          - containerPort: 80
        env:
        - name: PGADMIN_DEFAULT_EMAIL
          value: admin@alldcs.nl
        - name: PGADMIN_DEFAULT_PASSWORD
          value: Pgadmin01@
        volumeMounts:
        - mountPath: /var/lib/pgadmin
          name: pgadmin
      volumes:
      - name: pgadmin
        persistentVolumeClaim:
          claimName: pgadmin-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: pgadmin
  namespace: postgres
  labels:
    name: pgadmin
spec:
  type: ClusterIP
  ports:
    - port: 80
      name: http
  selector:
    app: pgadmin
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: pgadmin-odroid-alldcs
  namespace: postgres
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`pgadmin-odroid.allarddcs.nl`)
    kind: Rule
    services:
    - name: pgadmin
      port: 80
  tls:
    certResolver: letsencrypt
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pgadmin-pv
spec:
  storageClassName: ""
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    server: 192.168.2.110
    path: /mnt/nfs_share/pgadmin/odroid
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pgadmin-pvc
  namespace: postgres
spec:
  storageClassName: ""
  volumeName: pgadmin-pv
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi

