apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: contrail-configdb
  namespace: contrail-system
  labels:
    app: contrail-configdb
spec:
  template:
    metadata:
      labels:
        app: contrail-configdb
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: "node-role.kubernetes.io/infra"
                operator: Exists
      hostNetwork: true
      initContainers:
      - name: contrail-node-init
        image: "{{ contrail_registry }}/contrail-node-init:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        env:
{% if os_firewall_use_firewalld is defined and os_firewall_use_firewalld.lower() == 'true' %}
        - name: CONFIGURE_FIREWALLD
          value: "true"
        - name: FIREWALL_ZONE
          value: "{{firewall_zone}}"
{% else %}
        - name: CONFIGURE_IPTABLES
          value: "true"
        - name: IPTABLES_CHAIN
          value: "OS_FIREWALL_ALLOW"
{% endif %}
        - name: NODE_TYPE
          value: "config-database"
        - name: CONTRAIL_STATUS_IMAGE
          value: "{{ contrail_registry }}/contrail-status:{{ contrail_container_tag }}"
        envFrom:
        - configMapRef:
            name: env
        - configMapRef:
            name: contrail-configdb-config
        volumeMounts:
        - mountPath: /host/usr/bin
          name: host-usr-bin
      containers:
      - name: contrail-config-database-nodemgr
        image: "{{contrail_registry}}/contrail-nodemgr:{{contrail_container_tag}}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        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
        - mountPath: /etc/localtime
          name: localtime
      - name: config-zookeeper
        image: "{{ contrail_registry }}/contrail-external-zookeeper:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        env:
        - name: NODE_TYPE
          value: config-database
        envFrom:
        - configMapRef:
            name: configzookeeperenv
        volumeMounts:
        - mountPath: /var/lib/zookeeper
          name: zookeeper-data
        - mountPath: /var/log/zookeeper
          name: zookeeper-logs
      - name: rabbitmq
        image: "{{ contrail_registry }}/contrail-external-rabbitmq:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        env:
        - name: NODE_TYPE
          value: config-database
        envFrom:
        - configMapRef:
            name: env
        - configMapRef:
            name: rabbitmq-config
        - configMapRef:
            name: configzookeeperenv
        volumeMounts:
        - mountPath: /var/lib/rabbitmq
          name: rabbitmq-data
        - mountPath: /var/log/rabbitmq
          name: rabbitmq-logs
      - name: contrail-configdb
        image: "{{ contrail_registry }}/contrail-external-cassandra:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        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-log
      volumes:
      - name: host-usr-bin
        hostPath:
          path: /usr/bin
      - name: configdb-data
        hostPath:
          path: /var/lib/contrail/configdb
      - name: configdb-log
        hostPath:
          path: /var/log/contrail/configdb
      - name: docker-unix-socket
        hostPath:
          path: /var/run
      - name: configdb-logs
        hostPath:
          path: /var/log/contrail/configdb
      - name: localtime
        hostPath:
          path: /etc/localtime
      - name: zookeeper-data
        hostPath:
          path: /var/lib/contrail/config-zookeeper
      - name: zookeeper-logs
        hostPath:
          path: /var/log/contrail/config-zookeeper
      - name: rabbitmq-data
        hostPath:
          path: /var/lib/contrail/rabbitmq
      - name: rabbitmq-logs
        hostPath:
          path: /var/log/contrail/rabbitmq
{% if contrail_registry_username is defined and contrail_registry_password %}
      imagePullSecrets:
      - name: contrail-registry-secret
{% endif %}
---
