# Section: Daemonset
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: telegraf
  namespace: diffuser
  labels:
    name: telegraf
    environment: minikube
spec:
  selector:
    matchLabels:
      name: telegraf
  template:
    metadata:
      labels:
        name: telegraf
    spec:
      containers:
      - name: telegraf
        image: docker.io/telegraf:1.5.2
        resources:
          limits:
            memory: 500Mi
          requests:
            cpu: 500m
            memory: 500Mi
        env:
        - name: HOSTNAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: HOST_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        - name: "HOST_PROC"
          value: "/rootfs/proc"
        - name: "HOST_SYS"
          value: "/rootfs/sys"
        #- name: ENV
        #  valueFrom:
        #    secretKeyRef:
        #      name: telegraf
        #      key: env
        #- name: MONITOR_USERNAME
        #  valueFrom:
        #    secretKeyRef:
        #      name: telegraf
        #      key: monitor_username
        #- name: MONITOR_PASSWORD
        #  valueFrom:
        #    secretKeyRef:
        #      name: telegraf
        #      key: monitor_password
        #- name: MONITOR_HOST
        #  valueFrom:
        #    secretKeyRef:
        #      name: telegraf
        #      key: monitor_host
        #- name: MONITOR_DATABASE
        #  valueFrom:
        #    secretKeyRef:
        #      name: telegraf
        #      key: monitor_database
        volumeMounts:
        - name: sys
          mountPath: /rootfs/sys
          readOnly: true
        - name: proc
          mountPath: /rootfs/proc
          readOnly: true
        - name: docker-socket
          mountPath: /var/run/docker.sock
        - name: utmp
          mountPath: /var/run/utmp
          readOnly: true
        - name: config
          mountPath: /etc/telegraf
      terminationGracePeriodSeconds: 30
      volumes:
      - name: sys
        hostPath:
          path: /sys
      - name: docker-socket
        hostPath:
          path: /var/run/docker.sock
      - name: proc
        hostPath:
          path: /proc
      - name: utmp
        hostPath:
          path: /var/run/utmp
      - name: config
        configMap:
          name: telegraf
