From 5ef5533d9dd1a0450f1492b8dcda2d120f38752f Mon Sep 17 00:00:00 2001 From: Jose Segura Date: Wed, 25 Sep 2019 14:52:35 -0600 Subject: [PATCH] Update ApiVersion for CronJob. Support Kubernetes 13.5 --- README.md | 2 +- etcd-empty-dir-cleanup.yml | 2 +- k8s-clean.sh | 2 +- k8s-clean.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c1db8ee..d7bab56 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Here are 3 cleanups you can apply on your kubernetes cluster: * Cleans up old replica sets, finished jobs and unrecycled evicted pods as a CronJob (`k8s-clean.yml`). * Cleans up empty directory (not used anymore) in etcd as a CronJob (`etcd-empty-dir-cleanup.yml`). -You must have `batch/v2alpha1` enabled on your k8s API server runtime config in order to run the CronJob. +You must have `batch/v1beta1` enabled on your k8s API server runtime config in order to run the CronJob. ### Env vars In the DaemonSet (`docker-clean.yml`) you can set `DOCKER_CLEAN_INTERVAL` to modify the interval when it cleans up exited containers and dangling images/volumes; defaults to 30min (1800s). diff --git a/etcd-empty-dir-cleanup.yml b/etcd-empty-dir-cleanup.yml index 59e3ff2..b42f65c 100644 --- a/etcd-empty-dir-cleanup.yml +++ b/etcd-empty-dir-cleanup.yml @@ -1,5 +1,5 @@ --- -apiVersion: batch/v2alpha1 +apiVersion: batch/v1beta1 kind: CronJob metadata: name: etcd-empty-dir-cleanup diff --git a/k8s-clean.sh b/k8s-clean.sh index ae1b0e9..4f5e645 100755 --- a/k8s-clean.sh +++ b/k8s-clean.sh @@ -27,7 +27,7 @@ for job in $finishedJobs; do done # Get unrecycled evicted pods older than 1h -evictedPods=$(kubectl get pods --all-namespaces -a | grep 'Evicted' | \ +evictedPods=$(kubectl get pods --all-namespaces | grep 'Evicted' | \ awk 'IF $6 ~ /h|d/ {print $1 "|" $2}') # Loop through evicted pods and delete them diff --git a/k8s-clean.yml b/k8s-clean.yml index 8934042..1792b0a 100644 --- a/k8s-clean.yml +++ b/k8s-clean.yml @@ -1,5 +1,5 @@ --- -apiVersion: batch/v2alpha1 +apiVersion: batch/v1beta1 kind: CronJob metadata: name: k8s-cleanup