Commit 3a099155 authored by Nicolas Steinmetz's avatar Nicolas Steinmetz Committed by David McKay

Add telegraf-ds (imported and updated from old tick-stack charts)

parent b06d7572
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
apiVersion: v1
name: telegraf-ds
version: 1.7.0
appVersion: 1.13
deprecated: false
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
keywords:
- telegraf
- collector
- timeseries
- influxdata
home: https://www.influxdata.com/time-series-platform/telegraf/
maintainers:
- name: David McKay
email: rawkode@influxdata.com
- name: Giacomo Tirabassi
email: giacomo@influxdata.com
- name: naseemkullah
email: naseemkullah@gmail.com
engine: gotpl
# Telegraf-DS (DaemonSet)
[Telegraf](https://github.com/influxdata/telegraf) is a plugin-driven server agent written by the folks over at [InfluxData](https://influxdata.com) for collecting & reporting metrics. This chart runs a DaemonSet of Telegraf instances to collect host level metrics for your cluster. If you need to poll individual instances of infrastructure or APIs there is a `telegraf` chart that is more suited to that usecase.
## TL;DR
```console
$ helm repo add influxdata https://influxdata.github.io/helm-charts
$ helm install influxdata/telegraf-ds
```
## Introduction
This chart bootstraps a `telegraf-ds` daemonset on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
## Prerequisites
- Kubernetes 1.4+ with Beta APIs enabled
## Installing the Chart
To install the chart with the release name `my-release`:
```console
$ helm install --name my-release influxdata/telegraf-ds
```
The command deploys a Telegraf daemonset on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section as well as the [values.yaml](/values.yaml) file lists the parameters that can be configured during installation.
> **Tip**: List all releases using `helm list`
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```console
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The default configuration parameters are listed in `values.yaml`. To change the defaults, specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
$ helm install --name my-release \
--set config.outputs.influxdb.url=http://foo.bar:8086 \
influxdata/telegraf-ds
```
The above command allows the chart to deploy by setting the InfluxDB URL for telegraf to write to.
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
$ helm install --name my-release -f values.yaml influxdata/telegraf-ds
```
## Telegraf Configuration
This chart deploys the following by default:
- `telegraf` (`telegraf-ds`) running in a daemonset with the following plugins enabled
* [`cpu`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/cpu)
* [`disk`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/disk)
* [`diskio`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/diskio)
* [`docker`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/docker)
* [`kernel`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/kernel)
* [`kubernetes`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/kubernetes)
* [`mem`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/mem)
* [`processes`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/processes)
* [`swap`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/swap)
* [`system`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/system)
To open a shell session in the container running Telegraf run the following:
- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "telegraf.name" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh
To tail the logs for a Telegraf pod in the Daemonset run the following:
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "telegraf.name" . }} -o jsonpath='{ .items[0].metadata.name }')
To list the running Telegraf instances run the following:
- kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "telegraf.name" . }} -w
\ No newline at end of file
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "telegraf.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "telegraf.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "telegraf.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
CUSTOM TEMPLATES: This section contains templates that make up the different parts of the telegraf configuration file.
- global_tags section
- agent section
*/}}
{{- define "global_tags" -}}
{{- if . -}}
[global_tags]
{{- range $key, $val := . }}
{{ $key }} = {{ $val | quote }}
{{- end }}
{{- end }}
{{- end -}}
{{- define "agent" -}}
[agent]
{{- range $key, $value := . -}}
{{- $tp := typeOf $value }}
{{- if eq $tp "string"}}
{{ $key }} = {{ $value | quote }}
{{- end }}
{{- if eq $tp "float64"}}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "int"}}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "bool"}}
{{ $key }} = {{ $value }}
{{- end }}
{{- end }}
{{- end -}}
{{- define "outputs" -}}
{{- range $outputIdx, $configObject := . -}}
{{- range $output, $config := . -}}
[[outputs.{{- $output }}]]
{{- if $config -}}
{{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "string" }}
{{ $key }} = {{ $value | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "int" }}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "bool" }}
{{ $key }} = {{ $value }}
{{- end }}
{{- if eq $tp "[]interface {}" }}
{{ $key }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $value }}
{{- $i := int64 $b }}
{{- $tp := typeOf $val }}
{{- if eq $i $numOut }}
{{- if eq $tp "string" }}
{{ $val | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $val | int64 }}
{{- end }}
{{- else }}
{{- if eq $tp "string" }}
{{ $val | quote }},
{{- end}}
{{- if eq $tp "float64" }}
{{ $val | int64 }},
{{- end }}
{{- end }}
{{- end }}
]
{{- end }}
{{- end }}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "map[string]interface {}" }}
[[outputs.{{ $output }}.{{ $key }}]]
{{- range $k, $v := $value }}
{{- $tps := typeOf $v }}
{{- if eq $tps "string" }}
{{ $k }} = {{ $v | quote }}
{{- end }}
{{- if eq $tps "float64" }}
{{ $k }} = {{ $v | int64 }}.0
{{- end }}
{{- if eq $tps "int64" }}
{{ $k }} = {{ $v | int64 }}
{{- end }}
{{- if eq $tps "bool" }}
{{ $k }} = {{ $v }}
{{- end }}
{{- if eq $tps "[]interface {}"}}
{{ $k }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $v }}
{{- $i := int64 $b }}
{{- if eq $i $numOut }}
{{ $val | quote }}
{{- else }}
{{ $val | quote }},
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tps "map[string]interface {}"}}
[[outputs.{{ $output }}.{{ $key }}.{{ $k }}]]
{{- range $foo, $bar := $v }}
{{ $foo }} = {{ $bar | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}
{{- end -}}
{{- define "inputs" -}}
{{- range $inputIdx, $configObject := . -}}
{{- range $input, $config := . -}}
[[inputs.{{- $input }}]]
{{- if $config -}}
{{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "string" }}
{{ $key }} = {{ $value | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "int" }}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "bool" }}
{{ $key }} = {{ $value }}
{{- end }}
{{- if eq $tp "[]interface {}" }}
{{ $key }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $value }}
{{- $i := int64 $b }}
{{- $tp := typeOf $val }}
{{- if eq $i $numOut }}
{{- if eq $tp "string" }}
{{ $val | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $val | int64 }}
{{- end }}
{{- else }}
{{- if eq $tp "string" }}
{{ $val | quote }},
{{- end}}
{{- if eq $tp "float64" }}
{{ $val | int64 }},
{{- end }}
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tp "map[string]interface {}" }}
[[inputs.{{ $input }}.{{ $key }}]]
{{- range $k, $v := $value }}
{{- $tps := typeOf $v }}
{{- if eq $tps "string" }}
{{ $k }} = {{ $v }}
{{- end }}
{{- if eq $tps "[]interface {}"}}
{{ $k }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $v }}
{{- $i := int64 $b }}
{{- if eq $i $numOut }}
{{ $val | quote }}
{{- else }}
{{ $val | quote }},
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tps "map[string]interface {}"}}
[[inputs.{{ $input }}.{{ $key }}.{{ $k }}]]
{{- range $foo, $bar := $v }}
{{ $foo }} = {{ $bar | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}
{{- end -}}
{{- define "processors" -}}
{{- range $processorIdx, $configObject := . -}}
{{- range $processor, $config := . -}}
[[processors.{{- $processor }}]]
{{- if $config -}}
{{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "string" }}
{{ $key }} = {{ $value | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "int" }}
{{ $key }} = {{ $value | int64 }}
{{- end }}
{{- if eq $tp "bool" }}
{{ $key }} = {{ $value }}
{{- end }}
{{- if eq $tp "[]interface {}" }}
{{ $key }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $value }}
{{- $i := int64 $b }}
{{- $tp := typeOf $val }}
{{- if eq $i $numOut }}
{{- if eq $tp "string" }}
{{ $val | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $val | int64 }}
{{- end }}
{{- else }}
{{- if eq $tp "string" }}
{{ $val | quote }},
{{- end}}
{{- if eq $tp "float64" }}
{{ $val | int64 }},
{{- end }}
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tp "map[string]interface {}" }}
[[processors.{{ $processor }}.{{ $key }}]]
{{- range $k, $v := $value }}
{{- $tps := typeOf $v }}
{{- if eq $tps "string" }}
{{ $k }} = {{ $v | quote }}
{{- end }}
{{- if eq $tps "[]interface {}"}}
{{ $k }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $v }}
{{- $i := int64 $b }}
{{- if eq $i $numOut }}
{{ $val | quote }}
{{- else }}
{{ $val | quote }},
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tps "map[string]interface {}"}}
[processors.{{ $processor }}.{{ $key }}.{{ $k }}]
{{- range $foo, $bar := $v }}
{{- $tp := typeOf $bar -}}
{{- if eq $tp "string" }}
{{ $foo }} = {{ $bar | quote }}
{{- end }}
{{- if eq $tp "int" }}
{{ $foo }} = {{ $bar }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $foo }} = {{ int64 $bar }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "telegraf.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "telegraf.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "telegraf.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "telegraf.name" . }}
helm.sh/chart: {{ include "telegraf.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
telegraf.conf: |+
{{ template "global_tags" .Values.config.global_tags }}
{{ template "agent" .Values.config.agent }}
{{ template "processors" .Values.config.processors }}
{{ template "outputs" .Values.config.outputs }}
{{ template "inputs" .Values.config.inputs -}}
\ No newline at end of file
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "telegraf.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "telegraf.name" . }}
helm.sh/chart: {{ include "telegraf.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "telegraf.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "telegraf.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
annotations:
# Include a hash of the configmap in the pod template
# This means that if the configmap changes, the deployment will be rolled
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
serviceAccountName: {{ template "telegraf.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ default "" .Values.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.resources | indent 10 }}
env:
{{ toYaml .Values.env | indent 8 }}
volumeMounts:
- name: varrunutmpro
mountPath: /var/run/utmp
readOnly: true
- name: sysro
mountPath: /rootfs/sys
readOnly: true
- name: procro
mountPath: /rootfs/proc
readOnly: true
- name: docker-socket
mountPath: /var/run/docker.sock
- name: config
mountPath: /etc/telegraf
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
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: {{ include "telegraf.fullname" . }}
{{- if .Values.rbac.create }}
# Allow to define extra custom rules
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: influx:telegraf:custom
labels:
rbac.authorization.k8s.io/aggregate-view-telegraf-custom: "true"
rules:
{{ toYaml .Values.rbac.rules | indent 2 }}
---
# kubernetes_plugin: Give access to stats endpoints
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: influx:stats:viewer
labels:
rbac.authorization.k8s.io/aggregate-view-telegraf-stats: "true"
rules:
- apiGroups: [""]
resources: ["nodes/proxy"]
verbs: ["get", "watch", "list"]
---
# Define global role with the default system:aggregate-to-view cluster role and the two rules we just created
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: influx:telegraf
aggregationRule:
clusterRoleSelectors:
- matchLabels:
rbac.authorization.k8s.io/aggregate-view-telegraf-custom: "true"
- matchLabels:
rbac.authorization.k8s.io/aggregate-view-telegraf-stats: "true"
- matchLabels:
rbac.authorization.k8s.io/aggregate-to-view: "true"
rules: [] # Rules are automatically filled in by the controller manager.
{{- end }}
\ No newline at end of file
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: influx:telegraf:viewer
subjects:
- kind: ServiceAccount
name: {{ include "telegraf.fullname" . }}
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: influx:telegraf
{{- end }}
\ No newline at end of file
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "telegraf.serviceAccountName" . }}
labels:
app: {{ include "telegraf.name" . }}
chart: {{ include "telegraf.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end }}
## Default values.yaml for Telegraf
## This is a YAML-formatted file.
## ref: https://hub.docker.com/r/library/telegraf/tags/
image:
repo: "telegraf"
tag: "1.13-alpine"
pullPolicy: IfNotPresent
## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
resources:
requests:
memory: 256Mi
cpu: 0.1
limits:
memory: 2Gi
cpu: 1
env:
# This pulls HOSTNAME from the node, not the pod.
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# In test clusters where hostnames are resolved in /etc/hosts on each node,
# the HOSTNAME is not resolvable from inside containers
# So inject the host IP as well
- name: HOSTIP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: "HOST_PROC"
value: "/rootfs/proc"
- name: "HOST_SYS"
value: "/rootfs/sys"
## Tolerations for pod assignment
## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []
rbac:
# Specifies whether RBAC resources should be created
create: true
# Rules for the created rule
rules: []
# When using the prometheus input to scrape all pods you need extra rules set to the ClusterRole to be
# able to scan the pods for scraping labels. The following rules have been taken from:
# https://github.com/helm/charts/blob/master/stable/prometheus/templates/server-clusterrole.yaml#L8-L46
# - apiGroups:
# - ""
# resources:
# - nodes
# - nodes/proxy
# - nodes/metrics
# - services
# - endpoints
# - pods
# - ingresses
# - configmaps
# verbs:
# - get
# - list
# - watch
# - apiGroups:
# - "extensions"
# resources:
# - ingresses/status
# - ingresses
# verbs:
# - get
# - list
# - watch
# - nonResourceURLs:
# - "/metrics"
# verbs:
# - get
serviceAccount:
# Specifies whether a ServiceAccount should be created
create: true
# The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template
name:
## Exposed telegraf configuration
## ref: https://docs.influxdata.com/telegraf/v1.8/administration/configuration/
config:
# global_tags:
# cluster: "mycluster"
agent:
interval: "10s"
round_interval: true
metric_batch_size: 1000
metric_buffer_limit: 10000
collection_jitter: "0s"
flush_interval: "10s"
flush_jitter: "0s"
precision: ""
debug: false
quiet: false
logfile: ""
hostname: "$HOSTNAME"
omit_hostname: false
outputs:
- influxdb:
urls:
- "http://data-influxdb.tick:8086"
database: "telegraf"
retention_policy: ""
timeout: "5s"
username: ""
password: ""
user_agent: "telegraf"
insecure_skip_verify: false
inputs:
- cpu:
percpu: true
totalcpu: true
collect_cpu_time: false
report_active: false
- disk:
ignore_fs: ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
- diskio:
- docker:
endpoint: "unix:///var/run/docker.sock"
timeout: "5s"
perdevice: true
total: false
docker_label_exclude:
- "annotation.kubernetes.io/*"
- kernel:
- kubernetes:
url: "https://kubernetes.default.svc.cluster.local/api/v1/nodes/$NODE_NAME/proxy"
bearer_token: "/run/secrets/kubernetes.io/serviceaccount/token"
insecure_skip_verify: true
- mem:
- processes:
- swap:
- system:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment