apiVersion: apps/v1
kind: Deployment
metadata:
  name: survey-data-svc
  annotations:
    monitor: monitor
    waitForDb: waitForDb
    javaDebug: javaDebug
    pullSecrets: pullSecrets
spec:
  replicas: 1
  selector:
    matchLabels:
      app: survey-data-svc
  template:
    metadata:
      labels:
        app: survey-data-svc
    spec:
      containers:
      - image: survey-data-service
        name: spring-boot-service-container
        imagePullPolicy: IfNotPresent
        livenessProbe:
          httpGet:
            path: /monitoring/health
            port: 8080
          initialDelaySeconds: 100
          periodSeconds: 31
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /monitoring/health
            port: 8080
          initialDelaySeconds: 100
          periodSeconds: 5
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 1
        env:
          - name: SPRING_DATASOURCE_URL
            valueFrom:
              configMapKeyRef:
                name: survey-data-service-config
                key: DB_URL
          - name: SPRING_FLYWAY_URL
            valueFrom:
              configMapKeyRef:
                name: survey-data-service-config
                key: DB_URL
          - name: SPRING_DATASOURCE_USERNAME
            valueFrom:
              configMapKeyRef:
                name: survey-data-service-config
                key: DB_USER
          - name: SPRING_FLYWAY_USER
            valueFrom:
              configMapKeyRef:
                name: survey-data-service-config
                key: DB_USER
          - name: SPRING_DATASOURCE_PASSWORD
            valueFrom:
              configMapKeyRef:
                name: survey-data-service-config
                key: DB_PASS
          - name: SPRING_FLYWAY_PASSWORD
            valueFrom:
              configMapKeyRef:
                name: survey-data-service-config
                key: DB_PASS
          - name: SPRING_DATASOURCE_TOMCAT_MAX_ACTIVE
            valueFrom:
              configMapKeyRef:
                name: data-service-config
                key: SPRING_DATASOURCE_TOMCAT_MAX_ACTIVE
          - name: NEW_RELIC_LOG
            valueFrom:
              configMapKeyRef:
                name: new-relic-config
                key: NEW_RELIC_LOG
          - name: NEW_RELIC_LICENSE_KEY
            valueFrom:
              configMapKeyRef:
                name: new-relic-config
                key: NEW_RELIC_LICENSE_KEY
          - name: IFS_WEB_SYSTEM_USER_UID
            valueFrom:
              configMapKeyRef:
                name: web-config
                key: IFS_WEB_SYSTEM_USER_UID
          - name: JAVA_OPTS
            value: -Xms800m -Xmx800m -javaagent:/newrelic.jar
          - name: NEW_RELIC_APP_NAME
            value: "ifs-survey-data-service (${openshiftEnv})"
        ports:
          - containerPort: 8080
        resources:
          limits:
            cpu: 500m
          requests:
            cpu: 100m
            memory: 400M

