Commit bca82279 authored by Naseem's avatar Naseem Committed by Kubernetes Prow Robot

Revamping telegraf chart (#11312)

parent 0c3ff06a
name: telegraf
version: 0.3.3
appVersion: 1.5
deprecated: true
version: 1.0.0
appVersion: 1.9
deprecated: false
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
keywords:
- telegraf
......@@ -10,6 +10,6 @@ keywords:
- influxdata
home: https://www.influxdata.com/time-series-platform/telegraf/
maintainers:
- name: Jack Zampolin
email: jack@influxdb.com
- name: naseemkullah
email: naseemkullah@gmail.com
engine: gotpl
approvers:
- naseemkullah
reviewers:
- naseemkullah
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={{ template "fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh
- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "telegraf.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh
To tail the logs for a Telegraf pod in the Daemonset run the following:
To tail the logs for a Telegraf pod, run the following:
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "fullname" . }}-ds -o jsonpath='{ .items[0].metadata.name }')
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "telegraf.fullname" . }} -o jsonpath='{ .items[0].metadata.name }')
{{- if eq .Values.single.service.type "LoadBalancer" }}
{{- if eq .Values.service.type "LoadBalancer" }}
To watch for the LoadBalancer IP run the following
- kubectl get svc -w --namespace {{ .Release.Namespace }} -l app={{ template "fullname" . }}
{{- end }}
{{- if empty .Values.single.config.outputs.influxdb.urls }}
{{- if empty .Values.daemonset.config.outputs.influxdb.urls }}
Need to set an InfluxDB url for either single or daemonset to deploy this instance:
.Values.daemonset.config.outputs.influxdb.urls
.Values.single.config.outputs.influxdb.urls
{{- end }}
- kubectl get svc -w --namespace {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "telegraf.fullname" . }}
{{- end }}
\ No newline at end of file
......@@ -2,17 +2,33 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
{{- define "telegraf.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
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 "fullname" -}}
{{- define "telegraf.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 24 -}}
{{- 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 -}}
{{/*
......@@ -50,9 +66,12 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- 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"}}
......@@ -83,13 +102,19 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
{{- define "inputs" -}}
{{- range $input, $config := . -}}
{{- range $inputIdx, $configObject := . -}}
{{- range $input, $config := . -}}
[[inputs.{{- $input }}]]
{{- if $config -}}
{{- if $config -}}
{{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "string" }}
......@@ -158,7 +183,9 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end -}}
\ No newline at end of file
{{- end }}
{{- end -}}
{{- if gt (len .Values.daemonset.config.outputs.influxdb.urls) 0 }}
{{- if .Values.daemonset.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fullname" . }}-ds
labels:
app: {{ template "fullname" . }}-ds
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
telegraf.conf: |+
{{ template "global_tags" .Values.daemonset.config.global_tags }}
{{ template "agent" .Values.daemonset.config.agent }}
{{ template "outputs" .Values.daemonset.config.outputs }}
{{ template "inputs" .Values.daemonset.config.inputs -}}
{{- end -}}
{{- end -}}
\ No newline at end of file
{{- if gt (len .Values.single.config.outputs.influxdb.urls) 0 }}
{{- if .Values.single.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fullname" . }}-s
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
telegraf.conf: |+
{{ template "global_tags" .Values.single.config.global_tags }}
{{ template "agent" .Values.single.config.agent }}
{{ template "outputs" .Values.single.config.outputs }}
{{ template "inputs" .Values.single.config.inputs -}}
{{- end -}}
{{- end -}}
\ No newline at end of file
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 "outputs" .Values.config.outputs }}
{{ template "inputs" .Values.config.inputs -}}
{{- 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 -}}
\ No newline at end of file
{{- if gt (len .Values.single.config.outputs.influxdb.urls) 0 }}
{{- if .Values.single.enabled -}}
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "fullname" . }}-s
name: {{ include "telegraf.fullname" . }}
labels:
app: {{ template "fullname" . }}-s
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
app.kubernetes.io/name: {{ include "telegraf.name" . }}
helm.sh/chart: {{ include "telegraf.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
replicas: 1
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "telegraf.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "fullname" . }}-s
app.kubernetes.io/name: {{ include "telegraf.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ template "fullname" . }}
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ default "" .Values.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.single.resources | indent 10 }}
{{ toYaml .Values.resources | indent 10 }}
env:
- name: HOSTNAME
value: "telegraf-polling-service"
volumeMounts:
- name: config
mountPath: /etc/telegraf
volumes:
- name: config
configMap:
name: {{ template "fullname" . }}-s
{{- end -}}
{{- end -}}
\ No newline at end of file
name: {{ include "telegraf.fullname" . }}
{{- if .Values.single.enabled -}}
{{- if .Values.single.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}-s
name: {{ include "telegraf.fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
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 }}
spec:
type: {{ .Values.single.service.type }}
type: {{ .Values.service.type }}
ports:
{{- range $key, $value := .Values.single.config.inputs }}
{{- range $objectKey, $objectValue := .Values.config.inputs }}
{{- range $key, $value := . -}}
{{- $tp := typeOf $value -}}
{{- if eq $key "http_listener" }}
- port: {{ trimPrefix ":" $value.service_address | int64 }}
targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
......@@ -18,6 +21,7 @@ spec:
{{- if eq $key "statsd" }}
- port: {{ trimPrefix ":" $value.service_address | int64 }}
targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
protocol: "UDP"
name: "statsd"
{{- end }}
{{- if eq $key "tcp-listener" }}
......@@ -28,6 +32,7 @@ spec:
{{- if eq $key "udp-listener" }}
- port: {{ trimPrefix ":" $value.service_address | int64 }}
targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
protocol: "UDP"
name: "udp_listener"
{{- end }}
{{- if eq $key "webhooks" }}
......@@ -35,8 +40,8 @@ spec:
targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
name: "webhooks"
{{- end }}
{{- end -}}
{{- end }}
selector:
app: {{ template "fullname" . }}-s
{{- end -}}
{{- end -}}
\ No newline at end of file
app.kubernetes.io/name: {{ include "telegraf.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
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