From 72a45c60540a5497f7e6bf30be976ab8a9b0ae23 Mon Sep 17 00:00:00 2001 From: Duncan Schulze <13733349+duncaan@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:05:14 -0500 Subject: [PATCH] [prometheus-push-gateway] Add lifecycle hooks Fixes #5102 Add support for lifecycle hooks in the push-gateway deployment. * Add lifecycle hooks configuration to `charts/prometheus-pushgateway/templates/deployment.yaml` * Add lifecycle hooks configuration to `charts/prometheus-pushgateway/templates/statefulset.yaml` * Add lifecycle hooks configuration options in `charts/prometheus-pushgateway/values.yaml` --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/prometheus-community/helm-charts/issues/5102?shareId=XXXX-XXXX-XXXX-XXXX). --- charts/prometheus-pushgateway/templates/deployment.yaml | 2 ++ charts/prometheus-pushgateway/templates/statefulset.yaml | 2 ++ charts/prometheus-pushgateway/values.yaml | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/charts/prometheus-pushgateway/templates/deployment.yaml b/charts/prometheus-pushgateway/templates/deployment.yaml index 557ca6f00c33..266c4660f385 100644 --- a/charts/prometheus-pushgateway/templates/deployment.yaml +++ b/charts/prometheus-pushgateway/templates/deployment.yaml @@ -25,4 +25,6 @@ spec: {{- include "prometheus-pushgateway.defaultLabels" . | nindent 8 }} spec: {{- include "prometheus-pushgateway.podSpec" . | nindent 6 }} + lifecycle: + {{- toYaml .Values.lifecycle | nindent 8 }} {{- end }} diff --git a/charts/prometheus-pushgateway/templates/statefulset.yaml b/charts/prometheus-pushgateway/templates/statefulset.yaml index 8d486a306fd9..fd9ba9e73369 100644 --- a/charts/prometheus-pushgateway/templates/statefulset.yaml +++ b/charts/prometheus-pushgateway/templates/statefulset.yaml @@ -22,6 +22,8 @@ spec: {{- include "prometheus-pushgateway.defaultLabels" . | nindent 8 }} spec: {{- include "prometheus-pushgateway.podSpec" . | nindent 6 }} + lifecycle: + {{- toYaml .Values.lifecycle | nindent 8 }} {{- if .Values.persistentVolume.enabled }} volumeClaimTemplates: - metadata: diff --git a/charts/prometheus-pushgateway/values.yaml b/charts/prometheus-pushgateway/values.yaml index 85f267fdb864..4bc5e146281c 100644 --- a/charts/prometheus-pushgateway/values.yaml +++ b/charts/prometheus-pushgateway/values.yaml @@ -369,3 +369,9 @@ networkPolicy: {} # Array of extra K8s objects to deploy (evaluated as a template) # The value can hold an array of strings as well as objects extraManifests: [] + +# Lifecycle hooks configuration +lifecycle: {} +# preStop: +# exec: +# command: ["/bin/sh", "-c", "sleep 30"]