{{- if eq .Values.global.deploymentMode "development" }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Chart.Name }}-deployment
  labels:
    app: {{ .Chart.Name }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .Chart.Name }}
  template:
    metadata:
      labels:
        app: {{ .Chart.Name }}
        collect.logs: "plain-text"
    spec:
      serviceAccountName: {{ .Release.Name }}
      containers:
        - name: {{ .Values.name }}
          image: {{ .Values.pgadmin.image }}
          imagePullPolicy: Always
          ports:
            - containerPort: 5050
              protocol: TCP
          resources:
            requests:
              memory: 500Mi
          env:
            - name: PGADMIN_DEFAULT_EMAIL
              valueFrom:
                secretKeyRef:
                  key: login
                  name: pgadmin-secret
            - name: PGADMIN_DEFAULT_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: pgadmin-secret
            - name: PGADMIN_LISTEN_PORT
              value: "5050"
            - name: PGADMIN_LISTEN_ADDRESS
              value: 0.0.0.0
          volumeMounts:
            - mountPath: /pgadmin4/config_local.py
              name: {{ .Chart.Name }}-config
              subPath: config_local.py
            - mountPath: /pgadmin4/servers.json
              name: {{ .Chart.Name }}-config
              subPath: servers.json
            - mountPath: /var/lib/pgadmin
              name: pgadmin-data
      volumes:
        - name: {{ .Chart.Name }}-config
          configMap:
            name: {{ .Chart.Name }}-config
            defaultMode: 0664
        - name: pgadmin-data
          emptyDir: {}
{{- end }}
