apiVersion: apps/v1
kind: Deployment
metadata:
  name: idp
  annotations:
    pullSecrets: pullSecrets
spec:
  replicas: 1
  selector:
    matchLabels:
      app: idp
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: idp
    spec:
      hostname: idp
      volumes:
        - name: idp-keys-volume
          secret:
            secretName: idp-keys-secrets
        - name: shibboleth-volume
          secret:
            secretName: sp-secrets
      containers:
        - image: docker-ifs.devops.innovateuk.org/snapshots/idp-service:dea84d1
          name: idp
          workingDir: /usr/local/bin
          volumeMounts:
            - name: idp-keys-volume
              mountPath: /var/certs
            - name: shibboleth-volume
              mountPath: /var/shibboleth
          livenessProbe:
            httpGet:
              path: /idp/status
              port: 9443
              scheme: HTTPS
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 10
            failureThreshold: 5
          readinessProbe:
            httpGet:
              path: /idp/status
              port: 9443
              scheme: HTTPS
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 10
            failureThreshold: 5
          imagePullPolicy: IfNotPresent
          env:
            - name: SP_DOMAIN
              valueFrom:
                configMapKeyRef:
                  name: shibboleth-config
                  key: SP_DOMAIN
            - name: IDP_DOMAIN
              valueFrom:
                configMapKeyRef:
                  name: shibboleth-config
                  key: IDP_DOMAIN
            - name: NEW_RELIC_LICENSE_KEY
              valueFrom:
                configMapKeyRef:
                  name: new-relic-config
                  key: NEW_RELIC_LICENSE_KEY
            - name: NEW_RELIC_LOG
              valueFrom:
                configMapKeyRef:
                  name: new-relic-config
                  key: NEW_RELIC_LOG
            - name: JAVA_OPTS
              value: -Xms384M -Xmx768M -javaagent:/newrelic.jar
            - name: NEW_RELIC_APP_NAME
              value: "ifs-idp-service (${openshiftEnv})"
            - name: HTTPS_PORT
              value: "9443"
            - name: HTTP_PORT
              value: "9080"
            - name: MEMCACHE_ENDPOINT
              valueFrom:
                configMapKeyRef:
                  name: shibboleth-config
                  key: MEMCACHE_ENDPOINT
            - name: LDAP_URL
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_URL
            - name: LDAP_PORT
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: IDP_LDAP_PORT
            - name: LDAP_USESTARTTLS
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_USESTARTTLS
            - name: LDAP_USESSL
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_USESSL
            - name: LDAP_BASEDN
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_BASEDN
            - name: LDAP_BINDDN
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_BINDDN
            - name: LDAP_BINDDNCREDENTIAL
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_PASSWORD
            - name: LDAP_USERFILTER
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_USERFILTER
            - name: LDAP_ATTRIBUTE_SEARCHFILTER
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_ATTRIBUTE_SEARCHFILTER
            - name: LDAP_RETURNATTRIBUTES
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_RETURNATTRIBUTES
            - name: LDAP_AUTHENTICATOR
              valueFrom:
                configMapKeyRef:
                  name: ldap-config
                  key: LDAP_AUTHENTICATOR
            - name: IFS_WEB_GOOGLEANALYTICS_TRACKINGID
              valueFrom:
                configMapKeyRef:
                  name: web-config
                  key: IFS_WEB_GOOGLEANALYTICS_TRACKINGID
            - name: RESOURCE_DOMAIN
              valueFrom:
                configMapKeyRef:
                  name: idp-config
                  key: RESOURCE_DOMAIN
          ports:
            - containerPort: 9443
            - containerPort: 9080
          resources:
            requests:
              memory: 500M
            limits:
              memory: 2048M
