apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: contrail-configdb
  namespace: kube-system
  labels:
    app: contrail-configdb
spec:
  selector:
    matchLabels:
      app: contrail-configdb
  template:
    metadata:
      labels:
        app: contrail-configdb
    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

      containers:
        - name: contrail-configdb
          image: "hub.juniper.net/contrail/contrail-external-cassandra:2011.138"
          imagePullPolicy: IfNotPresent
          env:
            - name: NODE_TYPE
              value: config-database
          envFrom:
            - configMapRef:
                name: contrail-configdb-config
          volumeMounts:
            - mountPath: /var/lib/cassandra
              name: configdb-data
            - mountPath: /var/log/cassandra
              name: configdb-logs

        - name: contrail-config-database-nodemgr
          image: "hub.juniper.net/contrail/contrail-nodemgr:2011.138"
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: env
            - configMapRef:
                name: nodemgr-config
            - configMapRef:
                name: contrail-configdb-config
          env:
            - name: NODE_TYPE
              value: config-database
            - name: CONFIG_DATABASE_NODEMGR__DEFAULTS__minimum_diskGB
              value: "2"
          volumeMounts:
            - mountPath: /var/log/contrail
              name: configdb-logs
            - mountPath: /mnt
              name: docker-unix-socket
            # todo: there is type Socket in new kubernetes, it is possible to use full
            # path:
            # hostPath:
            #   path: /var/run/docker.sock and
            #   type: Socket

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

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