From da7051e16dbf93a3e539304092a4fc5a9fdd1248 Mon Sep 17 00:00:00 2001 From: Guido Iaquinti Date: Mon, 15 Aug 2022 19:00:58 +0100 Subject: [PATCH 1/2] Helm: add Grafana anotations --- .../grafana-annotation-post.job.yaml | 29 +++++++++++++++++++ .../templates/grafana-annotation-pre.job.yaml | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 charts/posthog/templates/grafana-annotation-post.job.yaml create mode 100644 charts/posthog/templates/grafana-annotation-pre.job.yaml diff --git a/charts/posthog/templates/grafana-annotation-post.job.yaml b/charts/posthog/templates/grafana-annotation-post.job.yaml new file mode 100644 index 000000000..5e45f92c0 --- /dev/null +++ b/charts/posthog/templates/grafana-annotation-post.job.yaml @@ -0,0 +1,29 @@ +# This job gets installed only if Grafana, Loki and Promtail are enabled. +# +# It's an ephemeral container running at the start and end of each Helm +# deploy and it's used to log at stdout the Helm revision we are +# installing / we finished installing. +# +# This datapoint is useful and can be very helpful as annotation +# in Grafana dashboard. +# +{{- if and .Values.grafana.enabled (and .Values.loki.enabled .Values.promtail.enabled) -}} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ printf "%s-grafana-annotation-job-post" .Release.Name }} + annotations: + "helm.sh/hook": "post-install,post-upgrade,post-rollback" +spec: + template: + spec: + containers: + - name: grafana-annotation-job-post + image: {{ .Values.busybox.image }} + imagePullPolicy: {{ .Values.busybox.pullPolicy }} + command: + - /bin/sh + - -c + - | + echo '{"operation_stage": "end", "helm_revision": "{{ .Release.Revision }}"}' +{{- end }} diff --git a/charts/posthog/templates/grafana-annotation-pre.job.yaml b/charts/posthog/templates/grafana-annotation-pre.job.yaml new file mode 100644 index 000000000..835f1cf31 --- /dev/null +++ b/charts/posthog/templates/grafana-annotation-pre.job.yaml @@ -0,0 +1,29 @@ +# This job gets installed only if Grafana, Loki and Promtail are enabled. +# +# It's an ephemeral container running at the start and end of each Helm +# deploy and it's used to log at stdout the Helm revision we are +# installing / we finished installing. +# +# This datapoint is useful and can be very helpful as annotation +# in Grafana dashboard. +# +{{- if and .Values.grafana.enabled (and .Values.loki.enabled .Values.promtail.enabled) -}} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ printf "%s-grafana-annotation-job-pre" .Release.Name }} + annotations: + "helm.sh/hook": "pre-install,pre-upgrade,pre-rollback" +spec: + template: + spec: + containers: + - name: grafana-annotation-job-pre + image: {{ .Values.busybox.image }} + imagePullPolicy: {{ .Values.busybox.pullPolicy }} + command: + - /bin/sh + - -c + - | + echo '{"operation_stage": "start", "helm_revision": "{{ .Release.Revision }}"}' +{{- end }} From a1166d335049203ebf6247ce6ef5d3fa19f2e26d Mon Sep 17 00:00:00 2001 From: Guido Iaquinti Date: Mon, 15 Aug 2022 19:06:14 +0100 Subject: [PATCH 2/2] UDYYY --- charts/posthog/templates/grafana-annotation-post.job.yaml | 1 + charts/posthog/templates/grafana-annotation-pre.job.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/charts/posthog/templates/grafana-annotation-post.job.yaml b/charts/posthog/templates/grafana-annotation-post.job.yaml index 5e45f92c0..31329f698 100644 --- a/charts/posthog/templates/grafana-annotation-post.job.yaml +++ b/charts/posthog/templates/grafana-annotation-post.job.yaml @@ -1,3 +1,4 @@ +# # This job gets installed only if Grafana, Loki and Promtail are enabled. # # It's an ephemeral container running at the start and end of each Helm diff --git a/charts/posthog/templates/grafana-annotation-pre.job.yaml b/charts/posthog/templates/grafana-annotation-pre.job.yaml index 835f1cf31..68159b21e 100644 --- a/charts/posthog/templates/grafana-annotation-pre.job.yaml +++ b/charts/posthog/templates/grafana-annotation-pre.job.yaml @@ -1,3 +1,4 @@ +# # This job gets installed only if Grafana, Loki and Promtail are enabled. # # It's an ephemeral container running at the start and end of each Helm