From 3f15aebe766a15b3300e53df85a3739ea0bb9da3 Mon Sep 17 00:00:00 2001 From: Robert Kubik Date: Tue, 28 Apr 2026 16:03:54 +0200 Subject: [PATCH] Added service annotations option to values, added services to expose built-in servers --- cloudprober/templates/configmap.yaml | 23 ++++++++++++++- cloudprober/templates/deployment.yaml | 10 +++++++ .../templates/service-builtin-http.yaml | 21 ++++++++++++++ .../templates/service-builtin-udp.yaml | 21 ++++++++++++++ cloudprober/templates/service.yaml | 4 +++ cloudprober/values.yaml | 29 +++++++++++++++++++ 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 cloudprober/templates/service-builtin-http.yaml create mode 100644 cloudprober/templates/service-builtin-udp.yaml diff --git a/cloudprober/templates/configmap.yaml b/cloudprober/templates/configmap.yaml index 0074e2a..4cc067b 100644 --- a/cloudprober/templates/configmap.yaml +++ b/cloudprober/templates/configmap.yaml @@ -5,7 +5,28 @@ metadata: name: {{ include "cloudprober.fullname" . }} data: {{ .Values.configFileName }}.{{- .Values.configFormat }}: | - {{- .Values.config | nindent 4}} + {{- .Values.config | nindent 4 }} + {{- if eq .Values.configFormat "cfg" }} + {{- if .Values.builtinServers.http.enabled }} + + server { + type: HTTP + http_server { + port: {{ .Values.builtinServers.http.port }} + } + } + {{- end }} + {{- if .Values.builtinServers.udp.enabled }} + + server { + type: UDP + udp_server { + port: {{ .Values.builtinServers.udp.port }} + type: {{ .Values.builtinServers.udp.mode }} + } + } + {{- end }} + {{- end }} {{ range .Values.additionalConfigs }} {{.name }}: | {{- .value | nindent 4}} diff --git a/cloudprober/templates/deployment.yaml b/cloudprober/templates/deployment.yaml index 7cefab5..9482c22 100644 --- a/cloudprober/templates/deployment.yaml +++ b/cloudprober/templates/deployment.yaml @@ -120,6 +120,16 @@ spec: - name: http containerPort: 9313 protocol: TCP + {{- if .Values.builtinServers.http.enabled }} + - name: builtin-http + containerPort: {{ .Values.builtinServers.http.port }} + protocol: TCP + {{- end }} + {{- if .Values.builtinServers.udp.enabled }} + - name: builtin-udp + containerPort: {{ .Values.builtinServers.udp.port }} + protocol: UDP + {{- end }} livenessProbe: httpGet: path: /health diff --git a/cloudprober/templates/service-builtin-http.yaml b/cloudprober/templates/service-builtin-http.yaml new file mode 100644 index 0000000..4b5fbe0 --- /dev/null +++ b/cloudprober/templates/service-builtin-http.yaml @@ -0,0 +1,21 @@ +{{- if .Values.builtinServers.http.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cloudprober.fullname" . }}-builtin-http + labels: + {{- include "cloudprober.labels" . | nindent 4 }} + {{- with .Values.builtinServers.http.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.builtinServers.http.service.type }} + ports: + - port: {{ .Values.builtinServers.http.service.port }} + targetPort: builtin-http + protocol: TCP + name: builtin-http + selector: + {{- include "cloudprober.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/cloudprober/templates/service-builtin-udp.yaml b/cloudprober/templates/service-builtin-udp.yaml new file mode 100644 index 0000000..e598975 --- /dev/null +++ b/cloudprober/templates/service-builtin-udp.yaml @@ -0,0 +1,21 @@ +{{- if .Values.builtinServers.udp.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cloudprober.fullname" . }}-builtin-udp + labels: + {{- include "cloudprober.labels" . | nindent 4 }} + {{- with .Values.builtinServers.udp.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.builtinServers.udp.service.type }} + ports: + - port: {{ .Values.builtinServers.udp.service.port }} + targetPort: builtin-udp + protocol: UDP + name: builtin-udp + selector: + {{- include "cloudprober.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/cloudprober/templates/service.yaml b/cloudprober/templates/service.yaml index 11f50b2..92cfac4 100644 --- a/cloudprober/templates/service.yaml +++ b/cloudprober/templates/service.yaml @@ -4,6 +4,10 @@ metadata: name: {{ include "cloudprober.fullname" . }} labels: {{- include "cloudprober.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: type: {{ .Values.service.type }} ports: diff --git a/cloudprober/values.yaml b/cloudprober/values.yaml index ed279db..643ad17 100644 --- a/cloudprober/values.yaml +++ b/cloudprober/values.yaml @@ -143,6 +143,35 @@ shareProcessNamespace: true service: type: ClusterIP port: 8080 + annotations: {} + +# Built-in cloudprober servers (https://cloudprober.org/docs/how-to/built-in-servers/). +# When enabled, the chart appends a corresponding `server { ... }` block to +# the rendered cloudprober config, opens the container port on the pod, and +# creates a dedicated Kubernetes Service that exposes it. +# +# Note: automatic config injection only works with the default `cfg` +# (protobuf text) configFormat. If you are using `yaml`/`json`, declare the +# server blocks manually in `config` and just use this section to expose +# the ports. +builtinServers: + http: + enabled: false + port: 3141 + service: + type: ClusterIP + port: 3141 + annotations: {} + udp: + enabled: false + port: 31415 + # UDP server mode: ECHO bounces packets back to the sender, DISCARD drops + # them silently. + mode: ECHO + service: + type: ClusterIP + port: 31415 + annotations: {} serviceMonitor: enabled: true