diff --git a/charts/telegraf-ds/.helmignore b/charts/telegraf-ds/.helmignore new file mode 100644 index 00000000..f0c13194 --- /dev/null +++ b/charts/telegraf-ds/.helmignore @@ -0,0 +1,21 @@ +# 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 diff --git a/charts/telegraf-ds/Chart.yaml b/charts/telegraf-ds/Chart.yaml new file mode 100644 index 00000000..8b3d0c74 --- /dev/null +++ b/charts/telegraf-ds/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +name: telegraf-ds +version: 1.0.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: rawkode + email: rawkode@influxdata.com +- name: gitirabassi + email: giacomo@influxdata.com +- name: naseemkullah + email: naseemkullah@gmail.com +- name: nsteinmetz + email: contact@cerenit.fr +engine: gotpl diff --git a/charts/telegraf-ds/OWNER b/charts/telegraf-ds/OWNER new file mode 100644 index 00000000..4bd81df7 --- /dev/null +++ b/charts/telegraf-ds/OWNER @@ -0,0 +1,8 @@ +approvers: +- rawkode +- gitirabassi +- naseemkullah +reviewers: +- rawkode +- gitirabassi +- naseemkullah \ No newline at end of file diff --git a/charts/telegraf-ds/README.md b/charts/telegraf-ds/README.md new file mode 100644 index 00000000..650b74cf --- /dev/null +++ b/charts/telegraf-ds/README.md @@ -0,0 +1,76 @@ +# 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. + +Telegraf input cannot be customised as it aims to provide an opinionated configuration to monitor kubernetes nodes and global kubernetes monitoring. + +## TL;DR + +```console +helm repo add influxdata https://helm.influxdata.com/ +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.11+ 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) diff --git a/charts/telegraf-ds/templates/NOTES.txt b/charts/telegraf-ds/templates/NOTES.txt new file mode 100644 index 00000000..1d2a04ee --- /dev/null +++ b/charts/telegraf-ds/templates/NOTES.txt @@ -0,0 +1,11 @@ +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 diff --git a/charts/telegraf-ds/templates/_helpers.tpl b/charts/telegraf-ds/templates/_helpers.tpl new file mode 100644 index 00000000..920893bb --- /dev/null +++ b/charts/telegraf-ds/templates/_helpers.tpl @@ -0,0 +1,389 @@ +{{/* 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 "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 -}} + +{{- define "aggregators" -}} +{{- range $aggregatorIdx, $configObject := . -}} + {{- range $aggregator, $config := . -}} + + [[aggregators.{{- $aggregator }}]] + {{- 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 {}" }} + [[aggregators.{{ $aggregator }}.{{ $key }}]] + {{- range $k, $v := $value }} + {{- $tps := typeOf $v }} + {{- if eq $tps "string" }} + {{ $k }} = {{ $v | quote }} + {{- end }} + {{- if eq $tps "[]interface {}"}} + {{ $k }} = [ + {{- $numOut := len $v }} + {{- $numOut := sub $numOut 1 }} + {{- range $b, $val := $v }} + {{- $i := int64 $b }} + {{- $tv := typeOf $val -}} + {{- if eq $i $numOut }} + {{- if eq $tv "string" }} + {{ $val | quote }} + {{- end }} + {{- if eq $tv "float64" }} + {{- $xval := float64 (int64 $val) -}} + {{- if eq $val $xval -}} + {{ $val | float64 }}.0 + {{- else -}} + {{ $val | float64 }} + {{- end -}} + {{- end }} + {{- if eq $tv "int64" }} + {{ $val | int64 }} + {{- end }} + {{- else }} + {{- if eq $tv "string" }} + {{ $val | quote }}, + {{- end }} + {{- if eq $tv "float64" }} + {{- $xval := float64 (int64 $val) -}} + {{- if eq $val $xval -}} + {{ $val | float64 }}.0, + {{- else -}} + {{ $val | float64 }}, + {{- end -}} + {{- end }} + {{- if eq $tv "int64" }} + {{ $val | int64 }}, + {{- end }} + {{- end }} + {{- end }} + ] + {{- end }} + {{- end }} + {{- range $k, $v := $value }} + {{- $tps := typeOf $v }} + {{- if eq $tps "map[string]interface {}"}} + [aggregators.{{ $aggregator }}.{{ $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 -}} diff --git a/charts/telegraf-ds/templates/configmap.yaml b/charts/telegraf-ds/templates/configmap.yaml new file mode 100644 index 00000000..0a482956 --- /dev/null +++ b/charts/telegraf-ds/templates/configmap.yaml @@ -0,0 +1,40 @@ +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 "aggregators" .Values.config.aggregators }} + {{ template "outputs" .Values.config.outputs }} + + [[inputs.diskio]] + [[inputs.kernel]] + [[inputs.mem]] + [[inputs.processes]] + [[inputs.swap]] + [[inputs.system]] + + [[inputs.cpu]] + percpu = true + totalcpu = true + collect_cpu_time = false + report_active = false + + [[inputs.disk]] + ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] + + [[inputs.docker]] + endpoint = "unix:///var/run/docker.sock" + + [[inputs.kubernetes]] + url = "https://$HOSTIP:10250" + bearer_token = "/run/secrets/kubernetes.io/serviceaccount/token" + insecure_skip_verify = true diff --git a/charts/telegraf-ds/templates/daemonset.yaml b/charts/telegraf-ds/templates/daemonset.yaml new file mode 100644 index 00000000..58a92e45 --- /dev/null +++ b/charts/telegraf-ds/templates/daemonset.yaml @@ -0,0 +1,70 @@ +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: + - name: HOSTIP + valueFrom: + fieldRef: + fieldPath: status.hostIP +{{ 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" . }} diff --git a/charts/telegraf-ds/templates/role.yaml b/charts/telegraf-ds/templates/role.yaml new file mode 100644 index 00000000..863128aa --- /dev/null +++ b/charts/telegraf-ds/templates/role.yaml @@ -0,0 +1,29 @@ +{{- if .Values.rbac.create }} +# 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: ["metrics.k8s.io"] + resources: ["pods"] + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["nodes/stats"] + 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-stats: "true" + - matchLabels: + rbac.authorization.k8s.io/aggregate-to-view: "true" +rules: [] # Rules are automatically filled in by the controller manager. +{{- end }} diff --git a/charts/telegraf-ds/templates/rolebinding.yaml b/charts/telegraf-ds/templates/rolebinding.yaml new file mode 100644 index 00000000..aaa8603d --- /dev/null +++ b/charts/telegraf-ds/templates/rolebinding.yaml @@ -0,0 +1,14 @@ +{{- 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 diff --git a/charts/telegraf-ds/templates/serviceaccount.yaml b/charts/telegraf-ds/templates/serviceaccount.yaml new file mode 100644 index 00000000..6687b7e4 --- /dev/null +++ b/charts/telegraf-ds/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- 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 }} diff --git a/charts/telegraf-ds/values.yaml b/charts/telegraf-ds/values.yaml new file mode 100644 index 00000000..751ebca9 --- /dev/null +++ b/charts/telegraf-ds/values.yaml @@ -0,0 +1,83 @@ +## 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: "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 + +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.13/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://influxdb.monitoring.svc:8086" + database: "telegraf" + retention_policy: "" + timeout: "5s" + username: "" + password: "" + user_agent: "telegraf" + insecure_skip_verify: false