-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(base-cluster/monitoring): add pagerduty alertmanager receiver (#653
- Loading branch information
Showing
15 changed files
with
397 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
monitoring: | ||
deadMansSwitch: | ||
enabled: true | ||
pingKey: PING_KEY | ||
apiKey: API_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
monitoring: | ||
prometheus: | ||
alertmanager: | ||
receivers: | ||
pagerduty: | ||
enabled: true | ||
integrationKey: INTEGRATION_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
charts/base-cluster/templates/monitoring/deadMansSwitch/ciliumNetworkPolicy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{- if eq (include "common.networkPolicy.type" .) "cilium" }} | ||
apiVersion: cilium.io/v2 | ||
kind: CiliumNetworkPolicy | ||
metadata: | ||
name: dead-mans-switch | ||
namespace: monitoring | ||
labels: {{- include "common.labels.standard" $ | nindent 4 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
spec: | ||
endpointSelector: | ||
matchLabels: {{- include "common.labels.matchLabels" $ | nindent 6 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
ingress: | ||
- { } | ||
egress: | ||
- toFQDNs: | ||
- matchName: hc-ping.com | ||
- matchName: healthchecks.io | ||
toPorts: | ||
- ports: | ||
- port: "443" | ||
protocol: TCP | ||
- toServices: | ||
- k8sServiceSelector: | ||
selector: | ||
matchLabels: | ||
k8s-app: kube-dns | ||
namespace: kube-system | ||
toPorts: | ||
- ports: | ||
- port: "53" | ||
protocol: UDP | ||
rules: | ||
dns: | ||
- matchName: hc-ping.com | ||
- matchName: healthchecks.io | ||
{{- end }} |
69 changes: 69 additions & 0 deletions
69
charts/base-cluster/templates/monitoring/deadMansSwitch/cronjob.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{{- if .Values.monitoring.deadMansSwitch.enabled }} | ||
{{- if false }} | ||
apiVersion: batch/v1 | ||
{{- else }} | ||
apiVersion: {{ include "common.capabilities.cronjob.apiVersion" . }} | ||
{{- end }} | ||
kind: CronJob | ||
metadata: | ||
name: dead-mans-switch | ||
namespace: monitoring | ||
labels: {{- include "common.labels.standard" $ | nindent 4 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
spec: | ||
concurrencyPolicy: Forbid | ||
startingDeadlineSeconds: 50 | ||
schedule: "* * * * *" # Every minute | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
labels: {{- include "common.labels.standard" $ | nindent 12 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
spec: | ||
securityContext: | ||
runAsGroup: 1000 | ||
runAsUser: 1000 | ||
runAsNonRoot: true | ||
fsGroup: 1000 | ||
automountServiceAccountToken: false | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: watchdog | ||
image: {{ template "base-cluster.curl.image" . }} | ||
{{- if .Values.global.kubectl.image.digest }} | ||
imagePullPolicy: IfNotPresent | ||
{{- else }} | ||
imagePullPolicy: Always | ||
{{- end }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
env: | ||
- name: PING_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: dead-mans-switch | ||
key: pingKey | ||
command: | ||
- curl | ||
- --silent | ||
- --show-error | ||
- --fail | ||
- --retry | ||
- '5' | ||
- --max-time | ||
- '30' | ||
- {{ printf "https://hc-ping.com/$(PING_KEY)/k8s-cluster-%s-%s-scheduling" (.Values.global.baseDomain | replace "." "-") .Values.global.clusterName }} | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 16Mi | ||
limits: | ||
cpu: 100m | ||
memory: 16Mi | ||
{{- end }} |
15 changes: 15 additions & 0 deletions
15
charts/base-cluster/templates/monitoring/deadMansSwitch/hook-secret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{- if .Values.monitoring.deadMansSwitch.enabled -}} | ||
{{- $secret := include (print .Template.BasePath "/monitoring/deadMansSwitch/secret.yaml") . | fromYaml -}} | ||
{{- $secret = mustMerge ( | ||
dict "metadata" ( | ||
dict "annotations" (dict | ||
"helm.sh/hook" "pre-install,pre-upgrade,pre-delete" | ||
"helm.sh/hook-delete-policy" "before-hook-creation,hook-succeeded,hook-failed" | ||
) | ||
"namespace" .Release.Namespace | ||
) | ||
) | ||
$secret | ||
-}} | ||
{{- $secret | toYaml -}} | ||
{{- end -}} |
69 changes: 69 additions & 0 deletions
69
charts/base-cluster/templates/monitoring/deadMansSwitch/registration.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{{- if .Values.monitoring.deadMansSwitch.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: dead-mans-switch-registration | ||
namespace: {{ $.Release.Namespace }} | ||
labels: {{- include "common.labels.standard" $ | nindent 4 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
annotations: | ||
helm.sh/hook: pre-install,pre-upgrade | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed | ||
spec: | ||
template: | ||
spec: | ||
securityContext: | ||
runAsGroup: 1000 | ||
runAsUser: 1000 | ||
runAsNonRoot: true | ||
fsGroup: 1000 | ||
automountServiceAccountToken: false | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: register | ||
image: {{ include "base-cluster.curl.image" . }} | ||
{{- if .Values.global.kubectl.image.digest }} | ||
imagePullPolicy: IfNotPresent | ||
{{- else }} | ||
imagePullPolicy: Always | ||
{{- end }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
env: | ||
- name: PING_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: dead-mans-switch | ||
key: pingKey | ||
- name: API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: dead-mans-switch | ||
key: apiKey | ||
command: | ||
- ash | ||
- -e | ||
- -c | ||
- | | ||
set -o pipefail | ||
set -x | ||
function createCheck() { | ||
local checkName="$1" | ||
local data='{"name": "'"$checkName"'", "slug": "'"$checkName"'", "tags": "k8s {{ .Values.global.clusterName -}}", "timeout": 120, "grace": 60, "channels": "{{- .Values.global.clusterName -}}", "unique": ["name"]}' | ||
curl --silent --show-error --fail --retry 5 --max-time 30 --header "X-Api-Key: $API_KEY" https://healthchecks.io/api/v3/checks/ --data "$data" | ||
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 }} | ||
{{- if .Values.monitoring.prometheus.enabled }} | ||
createCheck "$checkName-monitoring" | ||
{{- end }} | ||
createCheck "$checkName-scheduling" | ||
{{- end }} |
13 changes: 13 additions & 0 deletions
13
charts/base-cluster/templates/monitoring/deadMansSwitch/secret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{- if .Values.monitoring.deadMansSwitch.enabled -}} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: dead-mans-switch | ||
namespace: monitoring | ||
labels: {{- include "common.labels.standard" $ | nindent 4 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
type: Opaque | ||
stringData: | ||
apiKey: {{ .Values.monitoring.deadMansSwitch.apiKey | required "You need to provide the `.Values.monitoring.deadMansSwitch.apiKey`" | quote }} | ||
pingKey: {{ .Values.monitoring.deadMansSwitch.pingKey | required "You need to provide the `.Values.monitoring.deadMansSwitch.pingKey`" | quote }} | ||
{{- end -}} |
67 changes: 67 additions & 0 deletions
67
charts/base-cluster/templates/monitoring/deadMansSwitch/unregister.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{{- if lookup "v1" "Secret" "monitoring" "dead-mans-switch" }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: dead-mans-switch-unregister | ||
namespace: {{ $.Release.Namespace }} | ||
labels: {{- include "common.labels.standard" $ | nindent 4 }} | ||
app.kubernetes.io/component: dead-mans-switch | ||
annotations: | ||
helm.sh/hook: pre-delete | ||
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded,hook-failed | ||
spec: | ||
template: | ||
spec: | ||
securityContext: | ||
runAsGroup: 1000 | ||
runAsUser: 1000 | ||
runAsNonRoot: true | ||
fsGroup: 1000 | ||
automountServiceAccountToken: false | ||
restartPolicy: OnFailure | ||
containers: | ||
- name: unregister | ||
image: {{ include "base-cluster.curl.image" . }} | ||
{{- if .Values.global.kubectl.image.digest }} | ||
imagePullPolicy: IfNotPresent | ||
{{- else }} | ||
imagePullPolicy: Always | ||
{{- end }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
env: | ||
- name: API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: dead-mans-switch | ||
key: apiKey | ||
command: | ||
- ash | ||
- -e | ||
- -c | ||
- | | ||
set -o pipefail | ||
set -x | ||
function deleteCheck() { | ||
local checkName="$1" | ||
local existingChecks | ||
local existingCheckUUID | ||
existingCheckUUID="$(curl --silent --fail --retry 5 --max-time 30 --header "X-Api-Key: $apiKey" "https://healthchecks.io/api/v3/checks/?slug=$checkName" | sed -r 's#^.*ping_url":\s*"[^"]+/([^"]+)".*$#\1#')" | ||
if curl --silent --show-error --fail --retry 5 --max-time 30 --header "X-Api-Key: $API_KEY" "https://healthchecks.io/api/v3/checks/$existingCheckUUID" > /dev/null; then | ||
curl --silent --show-error --fail --retry 5 --max-time 30 --header "X-Api-Key: $API_KEY" "https://healthchecks.io/api/v3/checks/$existingCheckUUID" --request DELETE | ||
fi | ||
} | ||
checkName={{- printf "k8s-cluster-%s-%s" (.Values.global.baseDomain | replace "." "-") .Values.global.clusterName | quote }} | ||
{{- if .Values.monitoring.prometheus.enabled }} | ||
deleteCheck "$checkName-monitoring" | ||
{{- end }} | ||
deleteCheck "$checkName-scheduling" | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.