apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: admin
  name:  admin
  namespace: notification-canada-ca
spec:
  replicas: 1
  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: ALLOW_HTML_SERVICE_IDS
              value: '$(ALLOW_HTML_SERVICE_IDS)'
            - name: API_HOST_NAME
              value: http://api.notification-canada-ca.svc.cluster.local:6011
            - name: ASSET_UPLOAD_BUCKET_NAME
              value: '$(ASSET_UPLOAD_BUCKET_NAME)'
            - name: ASSET_DOMAIN
              value: '$(ASSET_DOMAIN)'
            - name: AWS_REGION
              value: '$(AWS_REGION)'
            - name: BULK_SEND_AWS_BUCKET
              value: '$(BULK_SEND_AWS_BUCKET)'
            - name: BULK_SEND_TEST_SERVICE_ID
              value: '$(BULK_SEND_TEST_SERVICE_ID)'
            - name: CONTACT_EMAIL
              value: '$(CONTACT_EMAIL)'
            - name: CSV_UPLOAD_BUCKET_NAME
              value: '$(CSV_UPLOAD_BUCKET_NAME)'
            - name: DANGEROUS_SALT
              value: '$(DANGEROUS_SALT)'
            - name: DOCUMENTATION_DOMAIN
              value: 'documentation.$(BASE_DOMAIN)'
            - name: HC_EN_SERVICE_ID
              value: '$(HC_EN_SERVICE_ID)'
            - name: HC_FR_SERVICE_ID
              value: '$(HC_FR_SERVICE_ID)'
            - name: FLASK_APP
              value: 'application.py'
            - name: NOTIFY_ENVIRONMENT
              value: '$(ENVIRONMENT)'
            - name: SENDING_DOMAIN
              value: '$(BASE_DOMAIN)'
            - name: SQLALCHEMY_DATABASE_URI
              value: '$(POSTGRES_SQL)'
            - name: STATSD_HOST
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: REDIS_URL
              value: '$(REDIS_URL)'
            - name: REDIS_ENABLED
              value: "1"
            - name: SECRET_KEY
              value: '$(SECRET_KEY)'
            - name: SENTRY_URL
              value: '$(SENTRY_URL)'
            - name: SHOW_STYLEGUIDE
              value: 'true'
            - name: NEW_RELIC_APP_NAME
              value: 'notification-admin-$(ENVIRONMENT)'
            - name: NEW_RELIC_DISTRIBUTED_TRACING_ENABLED
              value: 'true'
            - name: NEW_RELIC_LICENSE_KEY
              value: '$(NEW_RELIC_LICENSE_KEY)'
            - name: NEW_RELIC_MONITOR_MODE
              value: '$(NEW_RELIC_MONITOR_MODE)'
            - name: IP_GEOLOCATE_SERVICE
              value: '$(IP_GEOLOCATE_SERVICE)'
          resources:
            requests:
              cpu: "500m"
              memory: "700Mi"
            limits:
              cpu: "1200m"
              memory: "900Mi"
          ports:
            - containerPort: 6012
          readinessProbe:
            httpGet:
              path: /_status?simple=true
              port: 6012
            initialDelaySeconds: 10
            periodSeconds: 3
            timeoutSeconds: 1
            successThreshold: 3
            failureThreshold: 10
          livenessProbe:
            httpGet:
              path: "/_status?simple=true"
              port: 6012
            initialDelaySeconds: 30
            periodSeconds: 3
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 3
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status: {}
