{{- if .Values.multus.enabled }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: kube-multus-ds
  namespace: kube-system
  labels:
    {{- include "kubezero-lib.labels" . | nindent 4 }}
spec:
  selector:
    matchLabels:
      {{- include "kubezero-lib.selectorLabels" . | nindent 6 }}
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        {{- include "kubezero-lib.labels" . | nindent 8 }}
    spec:
      hostNetwork: true
      tolerations:
      - operator: Exists
        effect: NoSchedule
      - operator: Exists
        effect: NoExecute
      serviceAccountName: multus
      priorityClassName: system-node-critical
      containers:
      - name: kube-multus
        image: {{ .Values.multus.image.repository }}:{{ .Values.multus.image.tag }}
        # Always used cached images
        imagePullPolicy: {{ .Values.multus.image.pullPolicy }}
        #command: ["/entrypoint.sh"]
        command: ["/thin_entrypoint"]
        args:
        - "--multus-conf-file=/tmp/multus-conf/00-multus.conf"
        - "--rename-conf-file=false"
        - "--cni-bin-dir=/host/usr/libexec/cni"
        - "--cni-version=0.3.1"
        resources:
          requests:
            cpu: "10m"
            memory: "32Mi"
          limits:
            # cpu: "100m"
            memory: "64Mi"
        securityContext:
          privileged: true
          capabilities:
            add: ["SYS_ADMIN"]
        terminationMessagePolicy: FallbackToLogsOnError
        volumeMounts:
        - name: run
          mountPath: /run
        - name: cni
          mountPath: /host/etc/cni/net.d
        - name: cnibin
          mountPath: /host/usr/libexec/cni
        - name: multus-cfg
          mountPath: /tmp/multus-conf
      terminationGracePeriodSeconds: 10
      volumes:
        - name: run
          hostPath:
            path: /run
        - name: cni
          hostPath:
            path: /etc/cni/net.d
        - name: cnibin
          hostPath:
            path: /usr/libexec/cni
        - name: multus-cfg
          configMap:
            name: multus-cni-config
            items:
            - key: cni-conf.json
              path: 00-multus.conf
{{- end }}
