apiVersion: apps/v1
kind: Deployment
metadata:
  name: noti-server
  namespace: imxc
spec:
  selector:
    matchLabels:
      app: noti
  replicas: 1
  template:
    metadata:
      labels:
        app: noti
    spec:
      containers:
      - name: noti-server
        image: {{ .Values.global.IMXC_IN_REGISTRY }}/notification-server:{{ .Values.global.NOTI_SERVER_VERSION }}
        imagePullPolicy: IfNotPresent
        command: ["sh", "-c", {{ .Files.Get "scripts/init-noti-server.sh" | quote }}]
        env:
        # spring profile
        - name: SPRING_PROFILES_ACTIVE
          value: prd

        # keycloak configuration
        - name: KEYCLOAK_AUTH-SERVER-URL
          value: {{ .Values.global.KEYCLOAK_AUTH_SERVER_URL }}
        - name: KEYCLOAK_REALM
          value: exem

        # eureka configuration
        - name: EUREKA_CLIENT_SERVICE-URL_DEFAULTZONE
          value: http://eureka:8761/eureka

        # postgres configuration
        - name: SPRING_DATASOURCE_URL
          value: jdbc:log4jdbc:postgresql://postgres:5432/postgresdb

        # redis configuration
        - name: SPRING_REDIS_HOST
          value: redis-master
        - name: SPRING_REDIS_PORT
          value: "6379"
        - name: SPRING_REDIS_PASSWORD
          value: dkagh1234!

        # elasticsearch configuration
        - name: SPRING_ELASTIC_URLS
          value: elasticsearch
        - name: SPRING_ELASTIC_PORT
          value: "9200"

        # file I/O configuration
        - name: IMXC_ALERT_NOTIFICATION_FILE_USE
          value: "true"
        - name: IMXC_ALERT_NOTIFICATION_FILE_FILE-LIMIT-SIZE-MB
          value: "10"
        - name: IMXC_ALERT_NOTIFICATION_FILE_PATH
          value: /cloudmoa_noti
        - name: IMXC_ALERT_NOTIFICATION_FILE_NAME
          value: cloudmoa_alert.log
        - name: IMXC_ALERT_NOTIFICATION_FILE_FORMAT
          value: $[name]/($[level])/$[data]/$[message]
        - name: IMXC_ALERT_NOTIFICATION_FILE_LEVELCONTRACT
          value: "true"

        # rabbitmq configuration
        - name: IMXC_RABBITMQ_HOST
          value: base-rabbitmq
        - name: IMXC_RABBITMQ_PORT
          value: "61613"
        - name: IMXC_RABBITMQ_CLIENT_ID
          value: "user"
        - name: IMXC_RABBITMQ_CLIENT_PASSWORD
          value: "eorbahrhkswp"
        - name: IMXC_RABBITMQ_SYSTEM_ID
          value: "user"
        - name: IMXC_RABBITMQ_SYSTEM_PASSWORD
          value: "eorbahrhkswp"

        # api-server configuration
        - name: IMXC_API-SERVER-URL
          value: "http://imxc-api-service:8080"

        # cortex integration
        - name: SPRING_CORTEX_URLS
          value: base-cortex-configs
        - name: SPRING_CORTEX_PORT
          value: "8080"

        # alert webhook
        - name: IMXC_ALERT_WEBHOOK_URLS
          value: http://noti-server-service:8080/alert

        # etc configuration
        - name: IMXC_PROMETHEUS_NAMESPACE
          value: {{ .Values.global.IMXC_NAMESPACE }}
        - name: IMXC_ALERT_KUBERNETES_NAMESPACE
          value: {{ .Values.global.IMXC_NAMESPACE }}

        # log4j
        - name: LOG4J_FORMAT_MSG_NO_LOOKUPS
          value: "true"

        # service-now
        - name: IMXC_ALERT_NOTIFICATION_SERVICE-NOW_ENABLED
          value: "false"
        - name: IMXC_ALERT_NOTIFICATION_SERVICE-NOW_KEY
          value: ""
        - name: IMXC_ALERT_NOTIFICATION_SERVICE-NOW_AUTH_ID
          value: ""
        - name: IMXC_ALERT_NOTIFICATION_SERVICE-NOW_AUTH_PASSWORD
          value: ""

        resources:
          requests:
            memory: "100Mi"
            cpu: "50m"
---
apiVersion: v1
kind: Service
metadata:
  name: noti-server-service
  namespace: imxc
spec:
  type: NodePort
  selector:
    app: noti
  ports:
    - protocol: TCP
      port: 8080
      nodePort: 31083
