Skip to content

Commit

Permalink
fix(base-cluster/kube-prometheus-stack): only register healthcheck if…
Browse files Browse the repository at this point in the history
… enabled on both sides (#1052)
  • Loading branch information
cwrau authored Jan 28, 2025
1 parent f3ce73e commit 21e966d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions charts/base-cluster/ci/artifacthub-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ storage:
enabled: true
global:
clusterName: test
baseDomain: example.com
serviceLevelAgreement: None
monitoring:
grafana:
Expand Down
2 changes: 2 additions & 0 deletions charts/base-cluster/ci/deadmansswitch-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ monitoring:
enabled: true
pingKey: PING_KEY
apiKey: API_KEY
global:
baseDomain: example.com
2 changes: 1 addition & 1 deletion charts/base-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
===
You can access your grafana instance via

{{- if and .Values.certManager.email .Values.monitoring.grafana.ingress.enabled .Values.global.baseDomain }}
{{- if and .Values.certManager.email .Values.monitoring.grafana.ingress.enabled }}
{{- printf "https://%s" (include "base-cluster.grafana.host" $) | nindent 2 }}
{{- else }}
{{- printf "$ kubectl -n monitoring port-forward svc/kube-prometheus-stack-grafana 3000:http-web" | nindent 2 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{{- define "base-cluster.deadMansSwitch.checkName" -}}
{{- printf "k8s-cluster-%s-%s" (.Values.global.baseDomain | replace "." "-") .Values.global.clusterName }}
{{- end -}}

{{- if .Values.monitoring.deadMansSwitch.enabled }}
apiVersion: batch/v1
kind: Job
Expand Down Expand Up @@ -59,7 +63,7 @@ spec:
curl --silent --show-error --fail --retry 5 --max-time 30 "https://hc-ping.com/$PING_KEY/$checkName"
}
checkName={{- printf "k8s-cluster-%s-%s" (.Values.global.baseDomain | replace "." "-") .Values.global.clusterName | quote }}
checkName={{- include "base-cluster.deadMansSwitch.checkName" . | quote }}
{{- if .Values.monitoring.prometheus.enabled }}
createCheck "$checkName-monitoring"
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- if .Values.monitoring.deadMansSwitch.enabled -}}
{{- if not .Values.global.baseDomain -}}
{{- fail "You need to provide a `.Values.global.baseDomain` when enabling the dead mans switch" -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ config:
{{- $receivers = set $receivers "healthchecks.io" (dict
"webhook_configs" (list
(dict
"url" (printf "https://hc-ping.com/%s/k8s-cluster-%s-%s-monitoring" .Values.monitoring.deadMansSwitch.pingKey (.Values.global.baseDomain | replace "." "-") .Values.global.clusterName)
"url" (printf "https://hc-ping.com/%s/%s" .Values.monitoring.deadMansSwitch.pingKey (include "base-cluster.deadMansSwitch.checkName" .))
"send_resolved" false
)
)
Expand Down

0 comments on commit 21e966d

Please sign in to comment.