apiVersion: apps/v1
kind: Deployment
metadata:
  name: data-service
  annotations:
    monitor: monitor
    waitForDb: waitForDb
    javaDebug: javaDebug
    pullSecrets: pullSecrets
spec:
  replicas: 1
  selector:
    matchLabels:
      app: data-service
  template:
    metadata:
      labels:
        app: data-service
    spec:
      containers:
      - name: spring-boot-service-container
        image: data-service
        imagePullPolicy: IfNotPresent
        livenessProbe:
          httpGet:
            path: /monitoring/health
            port: 8080
          initialDelaySeconds: 120
          periodSeconds: 31
          timeoutSeconds: 25
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /monitoring/health
            port: 8080
          initialDelaySeconds: 120
          periodSeconds: 5
          timeoutSeconds: 25
          successThreshold: 1
          failureThreshold: 3
        env:
        - name: IFS_NEW_ORGANISATION_SEARCH_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_NEW_ORGANISATION_SEARCH_ENABLED
        - name: IFS_KTP_FEC_FINANCE_MODEL_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_KTP_FEC_FINANCE_MODEL_ENABLED
        - name: IFS_MONITORINGOFFICER_JOURNEY_UPDATE_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_MONITORINGOFFICER_JOURNEY_UPDATE_ENABLED
        - name: SPRING_DATASOURCE_URL
          valueFrom:
            configMapKeyRef:
              name: db-config
              key: DB_URL
        - name: SPRING_FLYWAY_URL
          valueFrom:
            configMapKeyRef:
              name: db-config
              key: DB_URL
        - name: SPRING_DATASOURCE_USERNAME
          valueFrom:
            configMapKeyRef:
              name: db-config
              key: DB_USER
        - name: SPRING_FLYWAY_USER
          valueFrom:
            configMapKeyRef:
              name: db-config
              key: DB_USER
        - name: SPRING_DATASOURCE_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: db-config
              key: DB_PASS
        - name: SPRING_FLYWAY_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: db-config
              key: DB_PASS
        - name: SPRING_FLYWAY_LOCATIONS
          valueFrom:
            configMapKeyRef:
              name: flyway-config
              key: FLYWAY_LOCATIONS
        - name: SPRING_CACHE_TYPE
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_CACHE_TYPE
        - name: SPRING_REDIS_HOST
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_REDIS_STANDALONE_HOST
        - name: SPRING_REDIS_PORT
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_REDIS_STANDALONE_PORT
        - name: SPRING_CACHE_REDIS_KEY_PREFIX
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_CACHE_PREFIX
        - name: SPRING_REDIS_SSL
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_REDIS_SSL
        - name: SPRING_REDIS_PASSWORD
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_REDIS_PASSWORD
        - name: SPRING_REDIS_CLUSTER_NODES
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_REDIS_CLUSTER_NODES
        - name: SPRING_CACHE_REDIS_TIME_TO_LIVE
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_CACHE_TTL
        - name: SPRING_REDIS_LETTUCE_POOL_MAX_ACTIVE
          valueFrom:
            configMapKeyRef:
              name: cache-config
              key: IFS_DATA_SERVICE_REDIS_MAX_ACTIVE
        - name: IFS_WEB_BASEURL
          valueFrom:
            configMapKeyRef:
              name: web-config
              key: IFS_WEB_BASEURL
        - name: IDP_REST_BASEURL
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IDP_REST_BASEURL
        - 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: SPRING_DATASOURCE_TOMCAT_MAX_ACTIVE
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: SPRING_DATASOURCE_TOMCAT_MAX_ACTIVE
        - name: IFS_EARLY_METRICS_URL
          valueFrom:
            configMapKeyRef:
              name: web-config
              key: IFS_EARLY_METRICS_URL
        - name: IFS_DATA_SERVICE_FILE_GRANT_SEND_DELAY_MILLIS
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_DATA_SERVICE_FILE_GRANT_SEND_DELAY_MILLIS
        - name: IFS_FINANCE_TOTALS_ENABLED
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_FINANCE_TOTALS_ENABLED
        - name: IFS_FINANCE-TOTALS_AUTHSECRETKEY
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_FINANCE-TOTALS_AUTHSECRETKEY
        - name: SIL_REST_BASEURL
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: SIL_REST_BASEURL
        - name: IFS_DATA_POSTCODE_LOOKUP_KEY
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_DATA_POSTCODE_LOOKUP_KEY
        - name: IFS_DATA_COMPANIES_HOUSE_LOOKUP_ENABLED
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_DATA_COMPANIES_HOUSE_LOOKUP_ENABLED
        - name: IFS_DATA_COMPANIES_HOUSE_KEY
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_DATA_COMPANIES_HOUSE_KEY
        - name: IFS_DATA_SERVICE_FILE_STORAGE_BASE
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_DATA_SERVICE_FILE_STORAGE_BASE
        - name: IFS_SYSTEM_INTERNAL_USER_EMAIL_DOMAINS
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_SYSTEM_INTERNAL_USER_EMAIL_DOMAINS
        - name: IFS_SYSTEM_KTA_USER_EMAIL_DOMAIN
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_SYSTEM_KTA_USER_EMAIL_DOMAIN
        - name: IFS_SLACK_AUTH_KEY
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_SLACK_AUTH_KEY
        - name: IFS_EMAIL_WHITELIST
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_EMAIL_WHITELIST
        - name: IFS_EMAIL_BLACKLIST
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_EMAIL_BLACKLIST
        - name: IFS_SYSTEM_EMAIL_ADDRESS
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_SYSTEM_EMAIL_ADDRESS
        - name: IFS_DATA_SERVICE_FILE_STORAGE_VIRUS_SCANNING_ENABLED
          valueFrom:
            configMapKeyRef:
              name: data-service-config
              key: IFS_DATA_SERVICE_FILE_STORAGE_VIRUS_SCANNING_ENABLED
        - name: IFS_DOCUSIGN_API_ACCOUNT
          valueFrom:
            configMapKeyRef:
              name: docusign-config
              key: IFS_DOCUSIGN_API_ACCOUNT
        - name: IFS_DOCUSIGN_API_BASE
          valueFrom:
            configMapKeyRef:
              name: docusign-config
              key: IFS_DOCUSIGN_API_BASE
        - name: IFS_DOCUSIGN_AUTH_BASE
          valueFrom:
            configMapKeyRef:
              name: docusign-config
              key: IFS_DOCUSIGN_AUTH_BASE
        - name: IFS_DOCUSIGN_AUTH_USER
          valueFrom:
            configMapKeyRef:
              name: docusign-config
              key: IFS_DOCUSIGN_AUTH_USER
        - name: IFS_DOCUSIGN_AUTH_CLIENT
          valueFrom:
            configMapKeyRef:
              name: docusign-config
              key: IFS_DOCUSIGN_AUTH_CLIENT
        - name: IFS_DOCUSIGN_AUTH_KEY
          valueFrom:
            configMapKeyRef:
              name: docusign-config
              key: IFS_DOCUSIGN_AUTH_KEY
        - name: IFS_LOAN_SURVEY_QUESTION_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_LOAN_SURVEY_QUESTION_ENABLED
        - name: IFS_PROCUREMENT_MILESTONES_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_PROCUREMENT_MILESTONES_ENABLED
        - name: SPRING_PROFILES_ACTIVE
          valueFrom:
            configMapKeyRef:
              name: spring-config
              key: SPRING_PROFILES_ACTIVE
        - name: IFS_SUBSIDY_CONTROL_NORTHERN_IRELAND_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_SUBSIDY_CONTROL_NORTHERN_IRELAND_ENABLED
        - name: IFS_LOAN_PARTB_ENABLED
          valueFrom:
            configMapKeyRef:
              name: feature-toggle-config
              key: IFS_LOAN_PARTB_ENABLED
        - name: JAVA_OPTS
          value: -Xms1500m -Xmx1500m -javaagent:/newrelic.jar
        - name: NEW_RELIC_APP_NAME
          value: "ifs-data-service (${openshiftEnv})"
        ports:
          - containerPort: 8080
        resources:
          limits:
            cpu: 2000m
          requests:
            cpu: 400m
            memory: 1500M
#          volumeMounts:
#            - mountPath: /mnt/ifs_storage
#              name: dir-1
#      volumes:
#        - name: dir-1
#          persistentVolumeClaim:
#            claimName: file-upload-claim
