---
kind: DaemonSet
apiVersion: apps/v1
metadata:
  name: sriov-network-config-daemon
  namespace: {{.Namespace}}
  annotations:
    release.openshift.io/version: "{{.ReleaseVersion}}"
spec:
  selector:
    matchLabels:
      app: sriov-network-config-daemon
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 33%
  template:
    metadata:
      annotations:
        target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
      labels:
        app: sriov-network-config-daemon
        component: network
        type: infra
        openshift.io/component: network
    spec:
      hostNetwork: true
      hostPID: true
      nodeSelector:
        beta.kubernetes.io/os: linux
        node-role.kubernetes.io/worker:
      tolerations:
      - operator: Exists
      serviceAccountName: sriov-network-config-daemon
      priorityClassName: "system-node-critical"
      containers:
      - name: sriov-cni
        image: {{.SRIOVCNIImage}}
        securityContext:
          privileged: true
        resources:
          requests:
            cpu: 10m
            memory: 10Mi
        volumeMounts:
        - name: cnibin
          mountPath: /host/opt/cni/bin
      - name: sriov-infiniband-cni
        image: {{.SRIOVInfiniBandCNIImage}}
        securityContext:
          privileged: true
        resources:
          requests:
            cpu: 10m
            memory: 10Mi
        volumeMounts:
        - name: cnibin
          mountPath: /host/opt/cni/bin
      - name: sriov-network-config-daemon
        image: {{.Image}}
        command:
          - sriov-network-config-daemon
        imagePullPolicy: IfNotPresent
        securityContext:
          privileged: true
        args:
          - "start"
        env:
          - name: NODE_NAME
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
          - name: NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: CLUSTER_TYPE
            value: "{{.ClusterType}}"
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: host
          mountPath: /host
        lifecycle:
          preStop:
            exec:
              command: ["/bindata/scripts/clean-k8s-services.sh"]
      volumes:
      - name: host
        hostPath:
          path: /
      - name: cnibin
        hostPath:
          path: {{.CNIBinPath}}
