Commit d594cfb7 authored by Cees-Jan Kiewiet's avatar Cees-Jan Kiewiet Committed by Kubernetes Prow Robot

[stable/telegraf] Add health output and probes (#19607)

parent 40aac55f
apiVersion: v1 apiVersion: v1
name: telegraf name: telegraf
version: 1.3.0 version: 1.4.0
appVersion: 1.12 appVersion: 1.12
deprecated: false 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.
......
...@@ -67,23 +67,24 @@ Create chart name and version as used by the chart label. ...@@ -67,23 +67,24 @@ Create chart name and version as used by the chart label.
{{- define "outputs" -}} {{- define "outputs" -}}
{{- range $outputIdx, $configObject := . -}} {{- range $outputIdx, $configObject := . -}}
{{- range $output, $config := . }} {{- range $output, $config := . -}}
[[outputs.{{ $output }}]]
{{- if $config }} [[outputs.{{- $output }}]]
{{- if $config -}}
{{- $tp := typeOf $config -}} {{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}} {{- 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" }}
{{ $key }} = {{ $value | quote }} {{ $key }} = {{ $value | quote }}
{{- end }} {{- end }}
{{- if eq $tp "float64"}} {{- if eq $tp "float64" }}
{{ $key }} = {{ $value | int64 }} {{ $key }} = {{ $value | int64 }}
{{- end }} {{- end }}
{{- if eq $tp "int"}} {{- if eq $tp "int" }}
{{ $key }} = {{ $value | int64 }} {{ $key }} = {{ $value | int64 }}
{{- end }} {{- end }}
{{- if eq $tp "bool"}} {{- if eq $tp "bool" }}
{{ $key }} = {{ $value }} {{ $key }} = {{ $value }}
{{- end }} {{- end }}
{{- if eq $tp "[]interface {}" }} {{- if eq $tp "[]interface {}" }}
...@@ -92,18 +93,70 @@ Create chart name and version as used by the chart label. ...@@ -92,18 +93,70 @@ Create chart name and version as used by the chart label.
{{- $numOut := sub $numOut 1 }} {{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $value }} {{- range $b, $val := $value }}
{{- $i := int64 $b }} {{- $i := int64 $b }}
{{- $tp := typeOf $val }}
{{- if eq $i $numOut }} {{- if eq $i $numOut }}
{{- if eq $tp "string" }}
{{ $val | quote }} {{ $val | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $val | int64 }}
{{- end }}
{{- else }} {{- else }}
{{- if eq $tp "string" }}
{{ $val | quote }}, {{ $val | quote }},
{{- end}}
{{- if eq $tp "float64" }}
{{ $val | int64 }},
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- 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 }}
{{ end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
......
...@@ -38,6 +38,21 @@ spec: ...@@ -38,6 +38,21 @@ spec:
- name: {{ .name }} - name: {{ .name }}
mountPath: {{ .mountPath }} mountPath: {{ .mountPath }}
{{- end }} {{- end }}
{{- range $objectKey, $objectValue := .Values.config.outputs }}
{{- range $key, $value := . -}}
{{- $tp := typeOf $value -}}
{{- if eq $key "health" }}
livenessProbe:
httpGet:
path: /
port: {{ trimPrefix "http://:" $value.service_address | int64 }}
readinessProbe:
httpGet:
path: /
port: {{ trimPrefix "http://:" $value.service_address | int64 }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.imagePullSecrets }} {{- if .Values.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }} {{ toYaml .Values.imagePullSecrets | indent 8 }}
......
...@@ -15,6 +15,16 @@ metadata: ...@@ -15,6 +15,16 @@ metadata:
spec: spec:
type: {{ .Values.service.type }} type: {{ .Values.service.type }}
ports: ports:
{{- range $objectKey, $objectValue := .Values.config.outputs }}
{{- range $key, $value := . -}}
{{- $tp := typeOf $value -}}
{{- if eq $key "health" }}
- port: {{ trimPrefix "http://:" $value.service_address | int64 }}
targetPort: {{ trimPrefix "http://:" $value.service_address | int64 }}
name: "health"
{{- end }}
{{- end }}
{{- end }}
{{- range $objectKey, $objectValue := .Values.config.inputs }} {{- range $objectKey, $objectValue := .Values.config.inputs }}
{{- range $key, $value := . -}} {{- range $key, $value := . -}}
{{- $tp := typeOf $value -}} {{- $tp := typeOf $value -}}
......
...@@ -60,6 +60,13 @@ config: ...@@ -60,6 +60,13 @@ config:
problem: 2 problem: 2
critical: 3 critical: 3
outputs: outputs:
- health:
service_address: "http://:8888"
compares:
field: buffer_size
lt: 5000.0
contains:
field: buffer_size
- influxdb: - influxdb:
urls: urls:
- "http://influxdb.monitoring.svc:8086" - "http://influxdb.monitoring.svc:8086"
......
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