From 840b7286e17818456a4767694d20d9582e183bdb Mon Sep 17 00:00:00 2001 From: friedrich goerz Date: Thu, 2 Mar 2023 19:55:16 +0100 Subject: [PATCH] DEV-898: fixing s3-backup + prometheus-scraping --- Chart.yaml | 2 +- .../netpol_ingress-prometheus2all-in-NS.yaml | 17 +++++++++++++++++ .../postgres/configmap_backup_monitoring.yaml | 2 +- .../prometheusrule_monitoring_basebackup.yaml | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 templates/netpol_ingress-prometheus2all-in-NS.yaml diff --git a/Chart.yaml b/Chart.yaml index d509981..d91bd9d 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.2 +version: 0.1.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/templates/netpol_ingress-prometheus2all-in-NS.yaml b/templates/netpol_ingress-prometheus2all-in-NS.yaml new file mode 100644 index 0000000..2c6acec --- /dev/null +++ b/templates/netpol_ingress-prometheus2all-in-NS.yaml @@ -0,0 +1,17 @@ +--- +kind: NetworkPolicy +apiVersion: networking.k8s.io/v1 +metadata: + name: ingress-prometheus2all +spec: + ingress: + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: monitoring + podSelector: + matchLabels: + prometheus: kube-prometheus-stack-prometheus + podSelector: {} + policyTypes: + - Ingress diff --git a/templates/postgres/configmap_backup_monitoring.yaml b/templates/postgres/configmap_backup_monitoring.yaml index 6a3780e..96972c0 100644 --- a/templates/postgres/configmap_backup_monitoring.yaml +++ b/templates/postgres/configmap_backup_monitoring.yaml @@ -14,5 +14,5 @@ data: LAST_BKP_DATE_IN_UNIXSEC=$(date -d ${LAST_BKP} +"%s") - STAGE={{ .Release.Name }} + STAGE={{ .Release.Name | lower | replace "-" "_" }} echo "pg_basebackup_successful_timestamp_${STAGE} ${LAST_BKP_DATE_IN_UNIXSEC}" | curl --data-binary @- "{{ .Values.postgres.monitoring.prometheusPushgatewayURL }}" diff --git a/templates/postgres/prometheusrule_monitoring_basebackup.yaml b/templates/postgres/prometheusrule_monitoring_basebackup.yaml index 6435bff..c4a66c1 100644 --- a/templates/postgres/prometheusrule_monitoring_basebackup.yaml +++ b/templates/postgres/prometheusrule_monitoring_basebackup.yaml @@ -15,6 +15,6 @@ spec: labels: team: {{ .Values.postgres.monitoring.alerts.postgres.basebackup.teamLabel | quote }} severity: critical - expr: absent(pg_basebackup_successful_timestamp_{{ .Release.Name }}) or (time() - pg_basebackup_successful_timestamp_{{ .Release.Name }} > {{ .Values.postgres.monitoring.alerts.postgres.basebackup.timeThreshold }}) + expr: absent(pg_basebackup_successful_timestamp_{{ .Release.Name | lower | replace "-" "_" }}) or (time() - pg_basebackup_successful_timestamp_{{ .Release.Name | lower | replace "-" "_" }} > {{ .Values.postgres.monitoring.alerts.postgres.basebackup.timeThreshold }}) annotations: message: last postgres backup found older than {{ .Values.postgres.monitoring.alerts.postgres.basebackup.timeThreshold }}