清理 Evicted 状态的 Pod
kubectl get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
清理 Error 状态的 Pod
kubectl get pods --all-namespaces -o wide | grep Error | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
清理 Completed 状态的 Pod
kubectl get pods --all-namespaces -o wide | grep Completed | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
kubectl get pods -n blade-env-pre -o wide | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n
删除指定pods
kubectl get pods -n blade-env-pre -o wide | awk '{print $1}' | xargs kubectl delete pod -n blade-env-pre
清理没有被使用的 PV
kubectl describe -A pvc | grep -E "^Name:.*$|^Namespace:.*$|^Used By:.*$" | grep -B 2 "
清理没有被绑定的 PVC
kubectl get pvc --all-namespaces | tail -n +2 | grep -v Bound | awk '{print $1,$2}' | xargs -L1 kubectl delete pvc -n
清理没有被绑定的 PV
kubectl get pv | tail -n +2 | grep -v Bound | awk '{print $1}' | xargs -L1 kubectl delete pv
删除其他资源
kubectl delete deployments.apps --all -n spring-blade
kubectl delete statefulsets.apps --all -n spring-blade
kubectl delete services --all -n spring-blade
kubectl delete configmaps --all -n spring-blade
kubectl delete secrets --all -n spring-blade