apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend-chat-plugin
  labels:
    app: frontend-chat-plugin
    type: frontend
    core.airy.co/managed: "true"
    core.airy.co/mandatory: "{{ .Values.mandatory }}"
    core.airy.co/component: "{{ .Values.component }}"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend-chat-plugin
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: frontend-chat-plugin
    spec:
      containers:
      - name: app
        image: "{{ .Values.global.containerRegistry}}/{{ .Values.frontend.image }}:{{ default .Chart.Version .Values.global.appImageTag }}"
        imagePullPolicy: Always
        env:
          - name: API_HOST
            valueFrom:
              configMapKeyRef:
                name: core-config
                key: API_HOST
        livenessProbe:
          httpGet:
            path: /health
            port: 80
            httpHeaders:
            - name: Health-Check
              value: health-check
          initialDelaySeconds: 30
          periodSeconds: 10
          failureThreshold: 3
      initContainers:
      - name: wait
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh", "/opt/provisioning/wait-for-service.sh"]
        env:
        - name: SERVICE_NAME
          value: sources-chatplugin
        - name: SERVICE_PORT
          value: "80"
        volumeMounts:
        - name: provisioning-scripts
          mountPath: /opt/provisioning
      volumes:
        - name: provisioning-scripts
          configMap:
            name: provisioning-scripts
