diff --git a/charts/base-cluster/ci/artifacthub-values.yaml b/charts/base-cluster/ci/artifacthub-values.yaml index 6e49c52ca..10a1211af 100644 --- a/charts/base-cluster/ci/artifacthub-values.yaml +++ b/charts/base-cluster/ci/artifacthub-values.yaml @@ -22,6 +22,7 @@ storage: enabled: true global: clusterName: test + baseDomain: example.com serviceLevelAgreement: None monitoring: grafana: diff --git a/charts/base-cluster/ci/deadmansswitch-values.yaml b/charts/base-cluster/ci/deadmansswitch-values.yaml index 5865bfdbc..b68d6b4ca 100644 --- a/charts/base-cluster/ci/deadmansswitch-values.yaml +++ b/charts/base-cluster/ci/deadmansswitch-values.yaml @@ -3,3 +3,5 @@ monitoring: enabled: true pingKey: PING_KEY apiKey: API_KEY +global: + baseDomain: example.com diff --git a/charts/base-cluster/templates/NOTES.txt b/charts/base-cluster/templates/NOTES.txt index 1e840829a..f4a9b9cbb 100644 --- a/charts/base-cluster/templates/NOTES.txt +++ b/charts/base-cluster/templates/NOTES.txt @@ -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 }} diff --git a/charts/base-cluster/templates/monitoring/deadMansSwitch/registration.yaml b/charts/base-cluster/templates/monitoring/deadMansSwitch/registration.yaml index 42dd92f6c..4c1d97b38 100644 --- a/charts/base-cluster/templates/monitoring/deadMansSwitch/registration.yaml +++ b/charts/base-cluster/templates/monitoring/deadMansSwitch/registration.yaml @@ -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 @@ -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 }} diff --git a/charts/base-cluster/templates/monitoring/deadMansSwitch/validation.tpl b/charts/base-cluster/templates/monitoring/deadMansSwitch/validation.tpl new file mode 100644 index 000000000..51067be6d --- /dev/null +++ b/charts/base-cluster/templates/monitoring/deadMansSwitch/validation.tpl @@ -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 -}} diff --git a/charts/base-cluster/templates/monitoring/kube-prometheus-stack/_alertmanager-config.yaml b/charts/base-cluster/templates/monitoring/kube-prometheus-stack/_alertmanager-config.yaml index 28394f314..ddd782204 100644 --- a/charts/base-cluster/templates/monitoring/kube-prometheus-stack/_alertmanager-config.yaml +++ b/charts/base-cluster/templates/monitoring/kube-prometheus-stack/_alertmanager-config.yaml @@ -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 ) )