Skip to content

Instantly share code, notes, and snippets.

@ShakataGaNai
Last active September 8, 2021 08:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShakataGaNai/88dba05201e4c8f7def66440922a1bc3 to your computer and use it in GitHub Desktop.
Save ShakataGaNai/88dba05201e4c8f7def66440922a1bc3 to your computer and use it in GitHub Desktop.
more up to date telegraf daemonset example (to InfluxDB 2.0)
apiVersion: v1
kind: ConfigMap
metadata:
name: telegraf
namespace: kube-system
labels:
k8s-app: telegraf
data:
telegraf.conf: |+
[agent]
hostname = "$KUBELET_HOST"
[[outputs.influxdb_v2]]
urls = ["http://YOUR-INFLUXDB-INSTALL-HERE"]
token = "$INFLUX_TOKEN"
organization = "YOUR-ORGANIZATION-HERE"
bucket = "YOUR-BUCKET-HERE"
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
[[inputs.kubernetes]]
url = "http://$KUBELET_HOST:10255"
---
# Section: Daemonset
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: telegraf
namespace: kube-system
labels:
k8s-app: telegraf
spec:
selector:
matchLabels:
name: telegraf
template:
metadata:
labels:
name: telegraf
spec:
containers:
- name: telegraf
image: docker.io/telegraf:1.10.4-alpine
resources:
limits:
memory: 500Mi
requests:
cpu: 500m
memory: 500Mi
env:
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: "HOST_PROC"
value: "/rootfs/proc"
- name: "HOST_SYS"
value: "/rootfs/sys"
- name: INFLUX_TOKEN
valueFrom:
secretKeyRef:
name: telegraf
key: INFLUX_TOKEN
- name: KUBELET_HOST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: sys
mountPath: /rootfs/sys
readOnly: true
- name: proc
mountPath: /rootfs/proc
readOnly: true
- name: docker-socket
mountPath: /var/run/docker.sock
readOnly: true
- 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
@ShakataGaNai
Copy link
Author

You'll also need to create the secret INFLUX_TOKEN, optionally with another YAML:

apiVersion: v1
kind: Secret
metadata:
  name: telegraf
  namespace: kube-system
data:
  # printf "somevar" | base64
  INFLUX_TOKEN: aGEgaGEsIG5pY2UgdHJ5LiBObyBzZWNyZXQgZm9yIHlvdS4=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment