service.yaml 2.22 KB
Newer Older
1
{{- if .Values.service.enabled -}}
Jack Zampolin's avatar
Jack Zampolin committed
2 3 4
apiVersion: v1
kind: Service
metadata:
5
  name: {{ include "telegraf.fullname" . }}
Jack Zampolin's avatar
Jack Zampolin committed
6
  labels:
7
    {{- include "telegraf.labels" . | nindent 4 }}
8 9 10 11
  {{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
  {{- end }}
Jack Zampolin's avatar
Jack Zampolin committed
12
spec:
13
  type: {{ .Values.service.type }}
Jack Zampolin's avatar
Jack Zampolin committed
14
  ports:
15 16
  - port: 8888
    targetPort: 8888
17
    name: "health"
18 19 20
  {{- range $objectKey, $objectValue := .Values.config.inputs }}
  {{- range $key, $value := . -}}
    {{- $tp := typeOf $value -}}
joesteffee's avatar
joesteffee committed
21 22 23 24 25
    {{- if eq $key "http_listener" }}
  - port: {{ trimPrefix ":" $value.service_address | int64 }}
    targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
    name: "http-listener"
    {{- end }}
26
    {{- if eq $key "http_listener_v2" }}
Jack Zampolin's avatar
Jack Zampolin committed
27 28
  - port: {{ trimPrefix ":" $value.service_address | int64 }}
    targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
joesteffee's avatar
joesteffee committed
29
    name: "http-listener-v2"
Jack Zampolin's avatar
Jack Zampolin committed
30 31 32 33
    {{- end }}
    {{- if eq $key "statsd" }}
  - port: {{ trimPrefix ":" $value.service_address | int64 }}
    targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
34
    protocol: "UDP"
Jack Zampolin's avatar
Jack Zampolin committed
35 36
    name: "statsd"
    {{- end }}
37
    {{- if eq $key "tcp_listener" }}
Jack Zampolin's avatar
Jack Zampolin committed
38 39
  - port: {{ trimPrefix ":" $value.service_address | int64 }}
    targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
40
    name: "tcp-listener"
Jack Zampolin's avatar
Jack Zampolin committed
41
    {{- end }}
42
    {{- if eq $key "udp_listener" }}
Jack Zampolin's avatar
Jack Zampolin committed
43 44
  - port: {{ trimPrefix ":" $value.service_address | int64 }}
    targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
45
    protocol: "UDP"
46
    name: "udp-listener"
Jack Zampolin's avatar
Jack Zampolin committed
47 48 49 50 51 52
    {{- end }}
    {{- if eq $key "webhooks" }}
  - port: {{ trimPrefix ":" $value.service_address | int64 }}
    targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
    name: "webhooks"
    {{- end }}
53
  {{- end -}}
Jack Zampolin's avatar
Jack Zampolin committed
54
  {{- end }}
55 56 57 58 59 60 61 62 63 64
  {{- range $objectKey, $objectValue := .Values.config.outputs }}
  {{- range $key, $value := . -}}
    {{- $tp := typeOf $value -}}
    {{- if eq $key "prometheus_client" }}
  - port: {{ trimPrefix ":" $value.listen | int64 }}
    targetPort: {{ trimPrefix ":" $value.listen | int64 }}
    name: "prometheus-client"
    {{- end }}
  {{- end -}}
  {{- end }}
Jack Zampolin's avatar
Jack Zampolin committed
65
  selector:
66
    {{- include "telegraf.selectorLabels" . | nindent 4 }}
67
{{- end -}}