apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nano-gpu-agent
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: nano-gpu-agent
  template:
    metadata:
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ""
      labels:
        app: nano-gpu-agent
    spec:
      serviceAccount: nano-gpu
      hostNetwork: true
      nodeSelector:
        nvidia-device-enable: "enable"
      containers:
        - image: nano-gpu-agent
          command: ["/usr/bin/nano-gpu-agent", "--nodename=$(NODE_NAME)", "--dbfile=/host/var/lib/nanogpu/meta.db"]
          name: nano-gpu-agent
          resources:
            limits:
              memory: "300Mi"
              cpu: "1"
            requests:
              memory: "300Mi"
              cpu: "1"
          env:
            - name: KUBECONFIG
              value: /etc/kubernetes/kubelet.conf
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          securityContext:
            privileged: true
          volumeMounts:
            - name: device-plugin
              mountPath: /var/lib/kubelet/device-plugins
            - name: pod-resources
              mountPath: /var/lib/kubelet/pod-resources
            - name: host-var
              mountPath: /host/var
            - name: host-dev
              mountPath: /host/dev
      volumes:
        - name: device-plugin
          hostPath:
            path: /var/lib/kubelet/device-plugins
        - name: pod-resources
          hostPath:
            path: /var/lib/kubelet/pod-resources
        - name: host-var
          hostPath:
            type: Directory
            path: /var
        - name: host-dev
          hostPath:
            type: Directory
            path: /dev
        - name: host-root
          hostPath:
            type: Directory
            path: /