apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: azure-npm-deamon
  namespace: kube-system
  labels:
    app: azure-npm
    component: daemon
    addonmanager.kubernetes.io/mode: EnsureExists
spec:
  selector:
    matchLabels:
      k8s-app: azure-npm
      component: daemon
  template:
    metadata:
      labels:
        k8s-app: azure-npm
        component: daemon
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ''
        azure.npm/scrapeable: ''
    spec:
      priorityClassName: system-node-critical
      tolerations:
      - operator: "Exists"
        effect: NoExecute
      - operator: "Exists"
        effect: NoSchedule
      - key: CriticalAddonsOnly
        operator: Exists
      containers:
        - name: azure-npm
          ports:
          - name: metrics
            containerPort: 10091
          image: azure-npm:v1.4.1
          command: ["azure-npm"]
          args: ["start", "daemon"]
          resources:
            limits:
              cpu: 250m
              memory: 300Mi
            requests:
              cpu: 250m
          securityContext:
            privileged: true
          env:
            - name: HOSTNAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
            - name: NPM_CONFIG
              value: /etc/azure-npm/azure-npm.json
            - name: DEAMON_POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: DEAMON_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          volumeMounts:
          - name: log
            mountPath: /var/log
          - name: xtables-lock
            mountPath: /run/xtables.lock
          - name: protocols
            mountPath: /etc/protocols
          - name: azure-npm-config
            mountPath: /etc/azure-npm
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      volumes:
      - name: log
        hostPath:
          path: /var/log
          type: Directory
      - name: xtables-lock
        hostPath:
          path: /run/xtables.lock
          type: File
      - name: protocols
        hostPath:
          path: /etc/protocols
          type: File
      - name: azure-npm-config
        configMap:
          name: azure-npm-config
      serviceAccountName: azure-npm
