apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: netchecker-agent
  name: netchecker-agent
  namespace: {{ netcheck_namespace }}
spec:
  selector:
    matchLabels:
      app: netchecker-agent
  template:
    metadata:
      name: netchecker-agent
      labels:
        app: netchecker-agent
    spec:
      priorityClassName: {% if netcheck_namespace == 'kube-system' %}system-node-critical{% else %}k8s-cluster-critical{% endif %}{{ '' }}
      tolerations:
        - effect: NoSchedule
          operator: Exists
      nodeSelector:
        kubernetes.io/os: linux
      containers:
        - name: netchecker-agent
          image: "{{ netcheck_agent_image_repo }}:{{ netcheck_agent_image_tag }}"
          imagePullPolicy: {{ k8s_image_pull_policy }}
          env:
            - name: MY_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: MY_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          args:
            - "-v=5"
            - "-alsologtostderr=true"
            - "-serverendpoint=netchecker-service:8081"
            - "-reportinterval={{ agent_report_interval }}"
          resources:
            limits:
              cpu: {{ netchecker_agent_cpu_limit }}
              memory: {{ netchecker_agent_memory_limit }}
            requests:
              cpu: {{ netchecker_agent_cpu_requests }}
              memory: {{ netchecker_agent_memory_requests }}
          securityContext:
            runAsUser: {{ netchecker_agent_user | default('0') }}
            runAsGroup: {{ netchecker_agent_group | default('0') }}
      serviceAccountName: netchecker-agent
  updateStrategy:
    rollingUpdate:
      maxUnavailable: 100%
    type: RollingUpdate
