# This file contains the contrail config components.
# It will be installed as DaemonSets on the infra node
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: contrail-controller-config
  namespace: contrail-system
  labels:
    app: contrail-controller-config
spec:
  template:
    metadata:
      labels:
        app: contrail-controller-config
    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"
        - name: CONTRAIL_STATUS_IMAGE
          value: "{{ contrail_registry }}/contrail-status:{{ contrail_container_tag }}"
        envFrom:
        - configMapRef:
            name: env
        volumeMounts:
        - mountPath: /host/usr/bin
          name: host-usr-bin
      containers:
      - name: contrail-controller-config-api
        image: "{{ contrail_registry }}/contrail-controller-config-api:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        envFrom:
        - configMapRef:
            name: env
        - configMapRef:
            name: configzookeeperenv
        volumeMounts:
        - mountPath: /var/log/contrail
          name: config-logs
        - mountPath: /etc/localtime
          name: localtime
      - name: contrail-controller-config-devicemgr
        image: "{{ contrail_registry }}/contrail-controller-config-devicemgr:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        envFrom:
        - configMapRef:
            name: env
        - configMapRef:
            name: configzookeeperenv
        volumeMounts:
        - mountPath: /var/log/contrail
          name: config-logs
        - mountPath: /etc/localtime
          name: localtime
      - name: contrail-controller-config-schema
        image: "{{ contrail_registry }}/contrail-controller-config-schema:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        envFrom:
        - configMapRef:
            name: env
        - configMapRef:
            name: configzookeeperenv
        volumeMounts:
        - mountPath: /var/log/contrail
          name: config-logs
        - mountPath: /etc/localtime
          name: localtime
      - name: contrail-controller-config-svcmonitor
        image: "{{ contrail_registry }}/contrail-controller-config-svcmonitor:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        envFrom:
        - configMapRef:
            name: env
        - configMapRef:
            name: configzookeeperenv
        volumeMounts:
        - mountPath: /var/log/contrail
          name: config-logs
        - mountPath: /etc/localtime
          name: localtime
      - name: contrail-controller-config-nodemgr
        image: "{{ contrail_registry }}/contrail-nodemgr:{{ contrail_container_tag }}"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        envFrom:
        - configMapRef:
            name: env
        - 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_diskG
          value: "2"
# todo: there is type Socket in new kubernetes, it is possible to use full
# path:
# hostPath:
#   path: /var/run/docker.sock and
#   type: Socket
        volumeMounts:
        - mountPath: /var/log/contrail
          name: config-logs
        - mountPath: /mnt
          name: docker-unix-socket
        - mountPath: /etc/localtime
          name: localtime
      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: pod-secret
        secret:
          secretName: contrail-kubernetes-token
      - name: localtime
        hostPath:
          path: /etc/localtime
{% if contrail_registry_username is defined and contrail_registry_password %}
      imagePullSecrets:
      - name: contrail-registry-secret
{% endif %}
---
