{{if .RenderDHCP}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: dhcp-daemon
  namespace: openshift-multus
  annotations:
    kubernetes.io/description: |
      This daemon set launches the containernetworking plugins DHCP daemon on each node.
    release.openshift.io/version: "{{.ReleaseVersion}}"
spec:
  selector:
    matchLabels:
      app: dhcp-daemon
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: dhcp-daemon
        component: network
        type: infra
        openshift.io/component: network
    spec:
      hostNetwork: true
      nodeSelector:
        kubernetes.io/os: linux
      tolerations:
      - operator: Exists
      initContainers:
      - name: dhcp-daemon-initialization
        image: {{.CNIPluginsImage}}
        command: ["/bin/sh"]
        args: ["-c", "rm -f /host/run/cni/dhcp.sock"]
        volumeMounts:
        - name: socketpath
          mountPath: /host/run/cni
      containers:
      - name: dhcp-daemon
        # Based on: https://github.com/s1061123/cni-dhcp-daemon/blob/master/Dockerfile
        image: {{.CNIPluginsImage}}
        imagePullPolicy: Always
        command: ["/usr/src/plugins/bin/dhcp"]
        args:
        - "daemon"
        - "-hostprefix"
        - "/host"
        securityContext:
          privileged: true
        volumeMounts:
        - name: socketpath
          mountPath: /host/run/cni
        - name: procpath
          mountPath: /host/proc
        - name: netnspath
          mountPath: /host/var/run/netns
          mountPropagation: HostToContainer
      volumes:
        - name: socketpath
          hostPath:
            path: /run/cni
        - name: procpath
          hostPath:
            path: /proc
        - name: netnspath
          hostPath:
            path: /run/netns

{{- end}}
