Create a gist now

Instantly share code, notes, and snippets.

@yudppp /Dockerfile
Last active Aug 17, 2017

What would you like to do?
kube job remover
FROM alpine
ENV KUBECTL_VERSION v1.5.3
ADD https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl /bin/kubectl
RUN chmod +x /bin/kubectl
# Delete successed job after 2 hours ago
CMD while true; do kubectl get job | awk '{ if(match($4, /^([2-9]h|[1-2][0-9]h|[0-9]+d)$/) && ($3==1)) print $1}' | xargs -n 1 --no-run-if-empty kubectl delete job; sleep 600s; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment