apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: contrail-analytics-alarm
  namespace: kube-system
  labels:
    app: contrail-analytics-alarm
spec:
  selector:
    matchLabels:
      app: contrail-analytics-alarm
  template:
    metadata:
      labels:
        app: contrail-analytics-alarm
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: "node-role.kubernetes.io/master"
                    operator: Exists
      tolerations:
        - key: node-role.kubernetes.io/master
          operator: Exists
          effect: NoSchedule
        - key: node.kubernetes.io/not-ready
          operator: Exists
          effect: NoSchedule
      hostNetwork: true

      initContainers:
        - name: contrail-node-init
          image: "hub.juniper.net/contrail/contrail-node-init:2011.138"
          imagePullPolicy: IfNotPresent
          env:
            - name: NODE_TYPE
              value: "analytics-alarm"
            - name: CONTRAIL_STATUS_IMAGE
              value: "hub.juniper.net/contrail/contrail-status:2011.138"
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: contrail-analyticsdb-config
          securityContext:
            privileged: true
          volumeMounts:
            - mountPath: /host/usr/bin
              name: host-usr-bin
            - mountPath: /host/var/lib
              name: host-var-lib

      containers:
        - name: kafka
          image: "hub.juniper.net/contrail/contrail-external-kafka:2011.138"
          imagePullPolicy: "IfNotPresent"
          securityContext:
            privileged: true
          env:
            - name: NODE_TYPE
              value: analytics-alarm
            - name: KAFKA_NODES
              value: 10.0.0.3
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv

        - name: contrail-analytics-alarm-gen
          image: "hub.juniper.net/contrail/contrail-analytics-alarm-gen:2011.138"
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
          volumeMounts:
            - mountPath: /var/log/contrail
              name: analytics-alarm-logs
          env:
            - name: NODE_TYPE
              value: analytics-alarm

        - name: contrail-analytics-alarm-nodemgr
          image: "hub.juniper.net/contrail/contrail-nodemgr:2011.138"
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: contrail-analyticsdb-config
            - configMapRef:
                name: nodemgr-config
          env:
            - name: NODE_TYPE
              value: analytics-alarm
          volumeMounts:
            - mountPath: /var/log/contrail
              name: analytics-alarm-logs
            - mountPath: /mnt
              name: docker-unix-socket

        - name: contrail-analytics-alarm-provisioner
          image: "hub.juniper.net/contrail/contrail-provisioner:2011.138"
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: defaults-env
            - configMapRef:
                name: contrail-analyticsdb-config
            - configMapRef:
                name: nodemgr-config
          env:
            - name: NODE_TYPE
              value: analytics-alarm
          volumeMounts:
            - mountPath: /var/log/contrail
              name: analytics-alarm-logs

      imagePullSecrets:
        - name: contrail-registry
      volumes:
        - name: analytics-alarm-logs
          hostPath:
            path: /var/log/contrail/analytics-alarm
        - name: host-var-lib
          hostPath:
            path: /var/lib
        - name: docker-unix-socket
          hostPath:
            path: /var/run
        - name: host-usr-bin
          hostPath:
            path: /usr/bin
