Skip to content

Commit

Permalink
Merge pull request #68 from MediaMarktSaturn/pod-cleanup/Customizable…
Browse files Browse the repository at this point in the history
…Phase

[Pod-Cleanup] Update to kubectl 1.27 and make pod field-selector customizable
  • Loading branch information
heubeck authored Nov 10, 2023
2 parents 6e07cd2 + eed5be1 commit f1a4ef9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions chart-tests/pod-cleanup/ci/test-values-phase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
podFieldSelector: status.phase=!Running
2 changes: 1 addition & 1 deletion charts/pod-cleanup/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ type: application
maintainers:
- name: MediaMarktSaturn
url: https://github.com/MediaMarktSaturn
version: 1.0.0
version: 1.1.0
2 changes: 1 addition & 1 deletion charts/pod-cleanup/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
command:
- /bin/sh
- -c
- kubectl delete pods -A --field-selector=status.phase=Failed
- kubectl delete pods -A --field-selector={{ $.Values.podFieldSelector }}
resources:
{{- toYaml $.Values.resources | nindent 16 }}
imagePullPolicy: IfNotPresent
Expand Down
5 changes: 4 additions & 1 deletion charts/pod-cleanup/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ image:
# A different image can be used as long as it contains the "kubectl" tool
repository: bitnami/kubectl
# Tag can be set to any Kubernetes version, to avoid unexpected compability issues it is recommended to use the same version configured for the K8s cluster
tag: "1.25"
tag: "1.27"

# CronJob schedule https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax
# Defaults to once every Monday on 07:00 AM (once per week)
Expand All @@ -25,3 +25,6 @@ resources:
limits:
cpu: 100m
memory: 100Mi

# --field-selector value to identify pods to be cleaned up
podFieldSelector: status.phase=Failed

0 comments on commit f1a4ef9

Please sign in to comment.