apiVersion: apps/v1
kind: Deployment
metadata:
  name: notification
  namespace: xl-demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: notification
      version: "1.0"
  template:
    metadata:
      labels:
        app: notification
        version: "1.0"
    spec:
      initContainers:
        - name: init-ds
          image: busybox
          command:
            - '/bin/sh'
            - '-c'
            - |
                while true
                do
                  rt=$(nc -z -w 1 notification-mongodb 27017)
                  if [ $? -eq 0 ]; then
                    echo "DB is UP"
                    break
                  fi
                  echo "DB is not yet reachable;sleep for 10s before retry"
                  sleep 10
                done
      containers:
      - name: notification-app
        image: stubbornrobot/ecommerce-notification:@IMAGE_TAG@
        imagePullPolicy: Always
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: "prod,swagger"
        - name: SPRING_CLOUD_CONFIG_URI
          value: http://admin:${jhipster.registry.password}@jhipster-registry.xl-demo.svc.cluster.local:8761/config
        - name: JHIPSTER_REGISTRY_PASSWORD
          valueFrom:
            secretKeyRef:
              name: registry-secret
              key: registry-admin-password
        - name: EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE
          value: http://admin:${jhipster.registry.password}@jhipster-registry.xl-demo.svc.cluster.local:8761/eureka/
        - name: SPRING_DATA_MONGODB_DATABASE
          value: notification
        - name: SPRING_DATA_MONGODB_URI
          value: "mongodb://notification-mongodb.xl-demo.svc.cluster.local:27017"
        - name: JHIPSTER_METRICS_LOGS_ENABLED
          value: 'true'
        - name: JHIPSTER_LOGGING_LOGSTASH_ENABLED
          value: 'true'
        - name: JHIPSTER_LOGGING_LOGSTASH_HOST
          value: jhipster-logstash
        - name: SPRING_ZIPKIN_ENABLED
          value: "true"
        - name: SPRING_ZIPKIN_BASE_URL
          value: http://jhipster-zipkin
        - name: SPRING_SLEUTH_PROPAGATION_KEYS
          value: "x-request-id,x-ot-span-context"
        - name: JAVA_OPTS
          value: " -Xmx256m -Xms256m"
        resources:
          requests:
            memory: "256Mi"
            cpu: "500m"
          limits:
            memory: "512Mi"
            cpu: "1"
        ports:
        - name: http
          containerPort: 8082
        readinessProbe:
          httpGet:
            path: /management/health
            port: http
          initialDelaySeconds: 20
          periodSeconds: 15
          failureThreshold: 6
        livenessProbe:
          httpGet:
            path: /management/health
            port: http
          initialDelaySeconds: 120
