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

Revamping telegraf chart (#11312)

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