{{- if gt (len .Values.daemonset.config.outputs.influxdb.urls) 0 }}
{{- if .Values.daemonset.enabled -}}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: {{ template "fullname" . }}-ds
  labels:
    app: {{ template "fullname" . }}-ds
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
spec:
  template:
    metadata:
      labels:
        app: {{ template "fullname" . }}-ds
    spec:
      containers:
      - name: {{ template "fullname" . }}
        image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ default "" .Values.image.pullPolicy | quote }}
        resources:
{{ toYaml .Values.daemonset.resources | indent 10 }}
        env:
        - name: HOSTNAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: "HOST_PROC"
          value: "/rootfs/proc"
        - name: "HOST_SYS"
          value: "/rootfs/sys"
        volumeMounts:
        - name: sysro
          mountPath: /rootfs/sys
          readOnly: true
        - name: procro
          mountPath: /rootfs/proc
          readOnly: true
        - name: docker-socket
          mountPath: /var/run/docker.sock
          # readOnly: true
        - name: varrunutmpro
          mountPath: /var/run/utmp
          readOnly: true
        - name: config
          mountPath: /etc/telegraf
      volumes:
      - name: sysro
        hostPath:
          path: /sys
      - name: docker-socket
        hostPath:
          path: /var/run/docker.sock
      - name: procro
        hostPath:
          path: /proc
      - name: varrunutmpro
        hostPath:
          path: /var/run/utmp
      - name: config
        configMap:
          name: {{ template "fullname" . }}-ds
{{- end -}}
{{- end -}}