Skip to content

Instantly share code, notes, and snippets.

@danhigham
Last active April 15, 2020 13:45
Show Gist options
  • Save danhigham/12d3cdf79dd3b1b1966698a69b77c770 to your computer and use it in GitHub Desktop.
Save danhigham/12d3cdf79dd3b1b1966698a69b77c770 to your computer and use it in GitHub Desktop.
Dan's handy kubectl one liners
# Remove all replicasets with 0 pods
for i in $(kubectl get rs -o json | jq -r '.items[] | select(.status.replicas==0) | .metadata.name'); do kubectl delete rs/$i; done
# Remove all resources with a certain label set
for i in $(kubectl api-resources -o name); do for x in $(kubectl get $i -l "kapp.k14s.io/app=1586922989415912400" -o name); do kubectl delete $x; done; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment