Skip to content

Commit

Permalink
[prometheus] Add readiness/liveness/startup probes to config-reloader…
Browse files Browse the repository at this point in the history
… container (#4696)

* Added readiness/liveness/startup probe to reload container in Prometheus pod

Signed-off-by: Luigi Bitonti <[email protected]>

* Changed chart version

Signed-off-by: Luigi Bitonti <[email protected]>

* Improved code and modified sts

Signed-off-by: Luigi Bitonti <[email protected]>

* Add code improvement

Signed-off-by: Luigi Bitonti <[email protected]>

* Removed variable

Signed-off-by: Luigi Bitonti <[email protected]>

* Removed space after metrics word

Signed-off-by: Luigi Bitonti <[email protected]>

* Enabled startup probe in ci pipeline

Signed-off-by: Luigi Bitonti <[email protected]>

---------

Signed-off-by: Luigi Bitonti <[email protected]>
Signed-off-by: MH <[email protected]>
Co-authored-by: MH <[email protected]>
  • Loading branch information
luigi-bitonti and zanhsieh authored Jul 8, 2024
1 parent 094734b commit b320323
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: prometheus
appVersion: v2.53.0
version: 25.22.1
version: 25.23.0
kubeVersion: ">=1.19.0-0"
description: Prometheus is a monitoring system and time series database.
home: https://prometheus.io/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ configmapReload:
log-level: debug
watch-interval: 1m

startupProbe:
enabled: true

server:
statefulSet:
enabled: false
3 changes: 3 additions & 0 deletions charts/prometheus/ci/03-config-reloader-sts-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ configmapReload:
log-level: debug
watch-interval: 1m

startupProbe:
enabled: true

server:
statefulSet:
enabled: true
19 changes: 19 additions & 0 deletions charts/prometheus/templates/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ spec:
{{- $default_url := "http://127.0.0.1:9090/-/reload" }}
{{- with .Values.server.prefixURL }}
{{- $default_url = printf "http://127.0.0.1:9090%s/-/reload" . }}
{{- end }}
{{- if .Values.configmapReload.prometheus.containerPort }}
- --listen-address=0.0.0.0:{{ .Values.configmapReload.prometheus.containerPort }}
{{- end }}
- --reload-url={{ default $default_url .Values.configmapReload.reloadUrl }}
{{- range $key, $value := .Values.configmapReload.prometheus.extraArgs }}
Expand All @@ -91,6 +94,22 @@ spec:
{{- if .Values.configmapReload.prometheus.containerPort }}
ports:
- containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
{{- if .Values.configmapReload.prometheus.containerPortName }}
name: {{ .Values.configmapReload.prometheus.containerPortName }}
{{- end }}
{{- end }}
{{- with .Values.configmapReload.prometheus.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.configmapReload.prometheus.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.configmapReload.prometheus.startupProbe.enabled }}
{{- $startupProbe := omit .Values.configmapReload.prometheus.startupProbe "enabled" }}
startupProbe:
{{- toYaml $startupProbe | nindent 12 }}
{{- end }}
{{- with .Values.configmapReload.prometheus.resources }}
resources:
Expand Down
19 changes: 19 additions & 0 deletions charts/prometheus/templates/sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ spec:
{{- $default_url := "http://127.0.0.1:9090/-/reload" }}
{{- with .Values.server.prefixURL }}
{{- $default_url = printf "http://127.0.0.1:9090%s/-/reload" . }}
{{- end }}
{{- if .Values.configmapReload.prometheus.containerPort }}
- --listen-address=0.0.0.0:{{ .Values.configmapReload.prometheus.containerPort }}
{{- end }}
- --reload-url={{ default $default_url .Values.configmapReload.reloadUrl }}
{{- range $key, $value := .Values.configmapReload.prometheus.extraArgs }}
Expand All @@ -96,6 +99,22 @@ spec:
{{- if .Values.configmapReload.prometheus.containerPort }}
ports:
- containerPort: {{ .Values.configmapReload.prometheus.containerPort }}
{{- if .Values.configmapReload.prometheus.containerPortName }}
name: {{ .Values.configmapReload.prometheus.containerPortName }}
{{- end }}
{{- end }}
{{- with .Values.configmapReload.prometheus.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.configmapReload.prometheus.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.configmapReload.prometheus.startupProbe }}
{{- $startupProbe := omit .Values.configmapReload.prometheus.startupProbe "enabled" }}
startupProbe:
{{- toYaml $startupProbe | nindent 12 }}
{{- end }}
{{- with .Values.configmapReload.prometheus.resources }}
resources:
Expand Down
31 changes: 30 additions & 1 deletion charts/prometheus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ configmapReload:
digest: ""
pullPolicy: IfNotPresent

# containerPort: 9533
## config-reloader's container port and port name for probes and metrics
containerPort: 8080
containerPortName: metrics

## Additional configmap-reload container arguments
## Set to null for argumentless flags
Expand All @@ -92,6 +94,33 @@ configmapReload:
## Security context to be added to configmap-reload container
containerSecurityContext: {}

## Settings for Prometheus reloader's readiness, liveness and startup probes
## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
##

livenessProbe:
httpGet:
path: /healthz
port: metrics
scheme: HTTP
periodSeconds: 10
initialDelaySeconds: 2

readinessProbe:
httpGet:
path: /healthz
port: metrics
scheme: HTTP
periodSeconds: 10

startupProbe:
enabled: false
httpGet:
path: /healthz
port: metrics
scheme: HTTP
periodSeconds: 10

## configmap-reload resource requests and limits
## Ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
Expand Down

0 comments on commit b320323

Please sign in to comment.