Skip to content

Commit

Permalink
[prometheus-push-gateway] Add lifecycle hooks (#5103)
Browse files Browse the repository at this point in the history
* [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`

Signed-off-by: Duncan Schulze <[email protected]>

* address comments
Signed-off-by: Duncan Schulze <[email protected]>

* Correct placement of lifecycle

Signed-off-by: zeritti <[email protected]>

* Add CI test cases

Signed-off-by: zeritti <[email protected]>

---------

Signed-off-by: Duncan Schulze <[email protected]>
Signed-off-by: zeritti <[email protected]>
Co-authored-by: zeritti <[email protected]>
  • Loading branch information
duncaan and zeritti authored Dec 31, 2024
1 parent 1f46261 commit da39668
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/prometheus-pushgateway/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: "v1.10.0"
description: A Helm chart for prometheus pushgateway
name: prometheus-pushgateway
version: 2.15.0
version: 2.16.0
home: https://github.com/prometheus/pushgateway
sources:
- https://github.com/prometheus/pushgateway
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
automountServiceAccountToken: false
2 changes: 2 additions & 0 deletions charts/prometheus-pushgateway/ci/default-sts-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# default sts values
runAsStatefulSet: true
1 change: 1 addition & 0 deletions charts/prometheus-pushgateway/ci/default-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# default values
3 changes: 3 additions & 0 deletions charts/prometheus-pushgateway/ci/extraargs-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
extraArgs:
- "--log.level=debug"
19 changes: 19 additions & 0 deletions charts/prometheus-pushgateway/ci/extramanifests-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
extraManifests:
- apiVersion: v1
kind: ConfigMap
metadata:
labels:
foo: bar
name: pushgateway-extra-cm-first
data:
FOO: "bar"
- apiVersion: v1
kind: ConfigMap
metadata:
labels:
baz: qux
name: pushgateway-extra-cm-second
data:
pushgateway.txt: '{{ include "prometheus-pushgateway.fullname" . }}'
immutable: true
4 changes: 4 additions & 0 deletions charts/prometheus-pushgateway/ci/extravars-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
extraVars:
- name: FOO
value: bar
5 changes: 5 additions & 0 deletions charts/prometheus-pushgateway/ci/lifecycle-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 10"]
9 changes: 9 additions & 0 deletions charts/prometheus-pushgateway/ci/persistence-sts-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
runAsStatefulSet: true
persistentVolume:
enabled: true
size: 1Gi

persistentVolumeLabels:
foo: bar
baz: qux
8 changes: 8 additions & 0 deletions charts/prometheus-pushgateway/ci/persistence-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
persistentVolume:
enabled: true
size: 1Gi

persistentVolumeLabels:
foo: bar
baz: qux
5 changes: 5 additions & 0 deletions charts/prometheus-pushgateway/ci/podlabels-sts-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
runAsStatefulSet: true
podLabels:
foo: bar
baz: qux
4 changes: 4 additions & 0 deletions charts/prometheus-pushgateway/ci/podlabels-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
podLabels:
foo: bar
baz: qux
8 changes: 8 additions & 0 deletions charts/prometheus-pushgateway/ci/resources-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
resources:
requests:
cpu: 50m
memory: 32Mi
limits:
cpu: 100m
memory: 32Mi
9 changes: 9 additions & 0 deletions charts/prometheus-pushgateway/ci/securitycontext-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
containerSecurityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
seccompProfile:
type: RuntimeDefault
4 changes: 4 additions & 0 deletions charts/prometheus-pushgateway/ci/servicelabels-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
serviceLabels:
foo: bar
baz: qux
7 changes: 7 additions & 0 deletions charts/prometheus-pushgateway/ci/servicemonitor-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
serviceMonitor:
enabled: true
namespace: null
interval: 15s
additionalLabels:
release: prometheus
3 changes: 3 additions & 0 deletions charts/prometheus-pushgateway/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ containers:
securityContext:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.lifecycle }}
lifecycle: {{ toYaml . | nindent 6 }}
{{- end }}
volumeMounts:
- name: storage-volume
mountPath: "{{ .Values.persistentVolume.mountPath }}"
Expand Down
6 changes: 6 additions & 0 deletions charts/prometheus-pushgateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit da39668

Please sign in to comment.