{{$Image := DefaultParam .Image "registry.k8s.io/pause:3.1"}}

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: {{.Name}}
  labels:
    group: load
spec:
  updateStrategy:
    rollingUpdate:
      maxUnavailable: {{MaxInt 10 (DivideInt .Nodes 20)}} # 5% of nodes, but not less than 10
  selector:
    matchLabels:
      name: {{.Name}}
  template:
    metadata:
      labels:
        group: load
        name: {{.Name}}
    spec:
      containers:
      - name: {{.Name}}
        image: {{$Image}}
        resources:
          requests:
            cpu: 10m
            memory: "10M"
      priorityClassName: daemonset-priorityclass-0 # Name is autogenerated, hence the -0 prefix.
      terminationGracePeriodSeconds: 1
      # Add not-ready/unreachable tolerations for 15 minutes so that node
      # failure doesn't trigger pod deletion.
      tolerations:
      - key: "node.kubernetes.io/not-ready"
        operator: "Exists"
        effect: "NoExecute"
        tolerationSeconds: 900
      - key: "node.kubernetes.io/unreachable"
        operator: "Exists"
        effect: "NoExecute"
        tolerationSeconds: 900
