Skip to content

Instantly share code, notes, and snippets.

@fermayo
Created April 23, 2019 14:54
Show Gist options
  • Save fermayo/ee51254c616187b55e835351705e8cd8 to your computer and use it in GitHub Desktop.
Save fermayo/ee51254c616187b55e835351705e8cd8 to your computer and use it in GitHub Desktop.
Deletes all completed jobs from all namespaces in a Kubernetes cluster
for NAMESPACE in $(kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'); do
kubectl -n $NAMESPACE delete job $(kubectl -n $NAMESPACE get jobs -o jsonpath='{.items[?(@.status.completionTime)].metadata.name}')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment