{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: apps/v1
{{- else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Deployment
metadata:
  name: postgres
  namespace: imxc
spec:
{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
  selector:
    matchLabels:
      app: postgres
{{- end }}
  replicas: 1
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
        - name: postgres
          image: {{ .Values.global.IMXC_IN_REGISTRY }}/postgres:{{ .Values.global.POSTGRES_VERSION }}
          resources:
            requests:
              cpu: 150m
              memory: 1000Mi
            limits:
              cpu: 300m
              memory: 2000Mi
          imagePullPolicy: "IfNotPresent"
          ports:
          - containerPort: 5432
          args: ["-c","max_connections=1000","-c","shared_buffers=512MB","-c","deadlock_timeout=5s","-c","statement_timeout=15s","-c","idle_in_transaction_session_timeout=60s"] 
          envFrom:
          - configMapRef:
              name: postgres-config
          volumeMounts:
          - mountPath: /var/lib/postgresql/data
            name: postgredb
      volumes:
      - name: postgredb
        persistentVolumeClaim:
          claimName: postgres-pv-claim
