apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: redis
  namespace: contrail-system
  labels:
    app: redis
spec:
  template:
    metadata:
      labels:
        app: redis
    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:
        - 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: redis
        image: "docker.io/redis:4.0.2"
        imagePullPolicy: "IfNotPresent"
        securityContext:
          privileged: true
        envFrom:
        - configMapRef:
            name: env
        volumeMounts:
        - mountPath: /var/lib/redis
          name: redis-data
        - mountPath: /var/log/redis
          name: redis-logs
      volumes:
      - name: redis-data
        hostPath:
          path: /var/lib/contrail/redis
      - name: redis-logs
        hostPath:
          path: /var/log/contrail/redis
      - name: host-usr-bin
        hostPath:
          path: /usr/bin
{% if contrail_registry_username is defined and contrail_registry_password %}
      imagePullSecrets:
      - name: contrail-registry-secret
{% endif %}
---
