apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: admin
  name:  admin
  namespace: notification-canada-ca
spec:
  replicas: 2
  revisionHistoryLimit: 5
  selector:
    matchLabels:
      app: admin
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: admin
    spec:
      initContainers:
        - name: init-postgres
          image: alpine
          command:
            [
              "sh",
              "-c",
              "until nslookup api.notification-canada-ca.svc.cluster.local; do echo waiting for postgres; sleep 2; done;",
            ]
      containers:
        - image: admin
          imagePullPolicy: Always
          name: admin
          env:
            - name: ADMIN_BASE_URL
              value: https://$(BASE_DOMAIN)
            - name: ADMIN_CLIENT_SECRET
              value: '$(ADMIN_CLIENT_SECRET)'
            - name: API_HOST_NAME
              value: http://api.notification-canada-ca.svc.cluster.local:6011
            - name: AWS_REGION
              value: '$(AWS_REGION)'
            - name: AWS_ACCESS_KEY_ID
              value: '$(AWS_ACCESS_KEY_ID)'
            - name: AWS_SECRET_ACCESS_KEY
              value: '$(AWS_SECRET_ACCESS_KEY)'
            - name: BULK_SEND_AWS_ACCESS_KEY
              value: '$(BULK_SEND_AWS_ACCESS_KEY)'
            - name: BULK_SEND_AWS_BUCKET
              value: '$(BULK_SEND_AWS_BUCKET)'
            - name: BULK_SEND_AWS_SECRET_KEY
              value: '$(BULK_SEND_AWS_SECRET_KEY)'
            - name: BULK_SEND_AWS_REGION
              value: '$(BULK_SEND_AWS_REGION)'
            - name: BULK_SEND_TEST_SERVICE_ID
              value: '$(BULK_SEND_TEST_SERVICE_ID)'
            - name: DANGEROUS_SALT
              value: '$(DANGEROUS_SALT)'
            - name: FLASK_APP
              value: 'application.py'
            - name: HC_EN_SERVICE_ID
              value: '$(HC_EN_SERVICE_ID)'
            - name: HC_FR_SERVICE_ID
              value: '$(HC_FR_SERVICE_ID)'
            - name: NEW_RELIC_LICENSE_KEY
              value: '$(NEW_RELIC_LICENSE_KEY)'
            - name: NEW_RELIC_APP_NAME
              value: 'notification-admin-production'
            - name: NEW_RELIC_DISTRIBUTED_TRACING_ENABLED
              value: 'true'
            - name: NOTIFY_ENVIRONMENT
              value: '$(ENVIRONMENT)'
            - name: SQLALCHEMY_DATABASE_URI
              value: '$(POSTGRES_SQL)'
            - name: REDIS_URL
              value: redis://redis.notification-canada-ca.svc.cluster.local:6379
            - name: REDIS_ENABLED
              value: "1"
            - name: SECRET_KEY
              value: '$(SECRET_KEY)'
          resources:
            requests:
              cpu: "200m"
              memory: "350Mi"
            limits:
              cpu: "400m"
              memory: "500Mi"
          ports:
            - containerPort: 6012
          readinessProbe:
            httpGet:
              path: /_status
              port: 6012
            initialDelaySeconds: 10
            periodSeconds: 3
            timeoutSeconds: 1
            successThreshold: 3
            failureThreshold: 10
          livenessProbe:
            httpGet:
              path: /_status
              port: 6012
            initialDelaySeconds: 30
            periodSeconds: 3
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 3
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status: {}
