---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: microgateway
  labels:
    app: microgateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: microgateway
  template:
    metadata:
      labels:
        app: microgateway
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "9102"
    spec:
      imagePullSecrets:
        - name: dockerregcred
      initContainers:
        - name: configbuilder
          image: docker.io/ergon/airlock-microgateway-configbuilder:3.1
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: config
              mountPath: /config/config.yaml
              subPath: config.yaml
              readOnly: true
            - name: passphrase-secret
              mountPath: /secret/passphrase
              subPath: passphrase
              readOnly: true
            - name: license-secret
              mountPath: /secret/license
              subPath: license
              readOnly: true
            - name: config-files
              mountPath: /resources-gen
          env:
            - name: TZ
              value: "Europe/Zurich"
      containers:
        - name: microgateway
          image: docker.io/ergon/airlock-microgateway:3.1
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: config-files
              mountPath: /config/
          env:
            - name: TZ
              value: "Europe/Zurich"
          ports:
            - name: http
              containerPort: 8080
            - name: https
              containerPort: 8443
            - name: probes
              containerPort: 9090
            - name: metrics
              containerPort: 9102
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthy
              port: probes
            initialDelaySeconds: 10
          livenessProbe:
            failureThreshold: 9
            timeoutSeconds: 5
            httpGet:
              path: /alive
              port: probes
            initialDelaySeconds: 90
          lifecycle:
            preStop:
              exec:
                command:
                  - /usr/bin/sleep
                  - "10"
          resources:
            requests:
              memory: 256Mi
              cpu: 30m
            limits:
              memory: 4048Mi
      volumes:
        - name: passphrase-secret
          secret:
            secretName: microgateway-passphrase
        - name: license-secret
          secret:
            secretName: microgateway-license
        - name: config
          configMap:
            name: microgateway-config
        - name: config-files
          emptyDir: {}
