From eed5be1564b2e58cf46df8d307c1570988b748c4 Mon Sep 17 00:00:00 2001 From: Florian Heubeck Date: Fri, 10 Nov 2023 13:02:08 +0100 Subject: [PATCH] [Pod-Cleanup] Update to kubectl 1.27 and make pod field-selector customizable --- chart-tests/pod-cleanup/ci/test-values-phase.yaml | 1 + charts/pod-cleanup/Chart.yaml | 2 +- charts/pod-cleanup/templates/cronjob.yaml | 2 +- charts/pod-cleanup/values.yaml | 5 ++++- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 chart-tests/pod-cleanup/ci/test-values-phase.yaml diff --git a/chart-tests/pod-cleanup/ci/test-values-phase.yaml b/chart-tests/pod-cleanup/ci/test-values-phase.yaml new file mode 100644 index 0000000..f703b3f --- /dev/null +++ b/chart-tests/pod-cleanup/ci/test-values-phase.yaml @@ -0,0 +1 @@ +podFieldSelector: status.phase=!Running diff --git a/charts/pod-cleanup/Chart.yaml b/charts/pod-cleanup/Chart.yaml index eeaed42..25c87cf 100644 --- a/charts/pod-cleanup/Chart.yaml +++ b/charts/pod-cleanup/Chart.yaml @@ -6,4 +6,4 @@ type: application maintainers: - name: MediaMarktSaturn url: https://github.com/MediaMarktSaturn -version: 1.0.0 +version: 1.1.0 diff --git a/charts/pod-cleanup/templates/cronjob.yaml b/charts/pod-cleanup/templates/cronjob.yaml index 908d599..cd43a52 100644 --- a/charts/pod-cleanup/templates/cronjob.yaml +++ b/charts/pod-cleanup/templates/cronjob.yaml @@ -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 diff --git a/charts/pod-cleanup/values.yaml b/charts/pod-cleanup/values.yaml index 4afef52..5b084c4 100644 --- a/charts/pod-cleanup/values.yaml +++ b/charts/pod-cleanup/values.yaml @@ -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) @@ -25,3 +25,6 @@ resources: limits: cpu: 100m memory: 100Mi + +# --field-selector value to identify pods to be cleaned up +podFieldSelector: status.phase=Failed