VERSION=0.0.1
curl -o kubectl-prune.tar.gz -Lf https://github.com/zxh326/kubectl-prune/releases/download/v${VERSION}/kubectl-prune-v${VERSION}-$(go env GOOS)-amd64.tar.gz
tar xf kubectl-prune.tar.gz
cp kubectl-prune-v${VERSION}-$(go env GOOS)-amd64/kubectl-prune $GOPATH/bin/
prune unused k8s resources
support
- configmap
- secrets
- serviceAccount
- death pods
- 0 replicas deployment
- replicaset
- service
- custom crds
(can use --dry-run flag to test before delete)
$ k prune cm
delete configmap/unsed-map (y/n) y
delete configMap/usused-map2 (y/m) n
deleted configMap/unsed-map
$ k prune cm,secrets
...
k prune —all
$ k prune cm -y
delete cm/test2
delete cm/test
$ k prune —-all-namespaces