apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: contrail-controller-config
  namespace: kube-system
  labels:
    app: contrail-controller-config
spec:
  selector:
    matchLabels:
      app: contrail-controller-config
  template:
    metadata:
      labels:
        app: contrail-controller-config
    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
          securityContext:
            privileged: true
          env:
            - name: CONTRAIL_STATUS_IMAGE
              value: "hub.juniper.net/contrail/contrail-status:2011.138"
          envFrom:
            - configMapRef:
                name: env
          volumeMounts:
            - mountPath: /host/usr/bin
              name: host-usr-bin

      containers:
        - name: contrail-controller-config-api
          image: "hub.juniper.net/contrail/contrail-controller-config-api:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs

        - name: contrail-controller-config-devicemgr
          image: "hub.juniper.net/contrail/contrail-controller-config-devicemgr:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs
            - name: tftp
              mountPath: /var/lib/tftp
            - name: dnsmasq
              mountPath: /var/lib/dnsmasq
          securityContext:
            capabilities:
              add:
                - SYS_PTRACE

        - name: contrail-controller-config-dnsmasq
          image: "hub.juniper.net/contrail/contrail-controller-config-dnsmasq:2011.L1.297"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs
            - name: tftp
              mountPath: /etc/tftp
            - name: dnsmasq
              mountPath: /var/lib/dnsmasq
          securityContext:
            capabilities:
              add:
                - NET_ADMIN
                - NET_RAW
          command: ["/bin/sh"]
          args: ["-c", "mkdir /etc/dnsmasq && /entrypoint.sh dnsmasq -k -p0"]
          #        command: ["mkdir /etc/dnsmasq && /entrypoint.sh"]
          #        args: ["dnsmasq", "-k", "-p0"]

        - name: contrail-controller-config-schema
          image: "hub.juniper.net/contrail/contrail-controller-config-schema:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs

        - name: contrail-controller-config-svcmonitor
          image: "hub.juniper.net/contrail/contrail-controller-config-svcmonitor:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs

        - name: contrail-controller-config-nodemgr
          image: "hub.juniper.net/contrail/contrail-nodemgr:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: configzookeeperenv
            - configMapRef:
                name: nodemgr-config
          env:
            - name: NODE_TYPE
              value: config
            - name: CASSANDRA_CQL_PORT
              value: "9041"
            - name: CASSANDRA_JMX_LOCAL_PORT
              value: "7201"
            - name: CONFIG_NODEMGR__DEFAULTS__minimum_diskGB
              value: "2"
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs
            - mountPath: /mnt
              name: docker-unix-socket

        - name: contrail-controller-config-provisioner
          image: "hub.juniper.net/contrail/contrail-provisioner:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: defaults-env
            - configMapRef:
                name: configzookeeperenv
            - configMapRef:
                name: nodemgr-config
          env:
            - name: NODE_TYPE
              value: config
            - name: CONFIG_NODEMGR__DEFAULTS__minimum_diskGB
              value: "2"
          volumeMounts:
            - mountPath: /var/log/contrail
              name: config-logs

      imagePullSecrets:
        - name: contrail-registry
      volumes:
        - name: config-logs
          hostPath:
            path: /var/log/contrail/config
        - name: docker-unix-socket
          hostPath:
            path: /var/run
        - name: host-usr-bin
          hostPath:
            path: /usr/bin
        - name: tftp
          emptyDir: {}
        - name: dnsmasq
          emptyDir: {}
