Develop/k8s
k8s pods 전체 삭제 및 특정 이름 전체 삭제
팡연
2023. 11. 9. 23:48
반응형
1. pods 전체삭제
# Pods 전체 삭제
kubectl delete pods --all --all-namespaces
kubectl delete pods --all -A
# Namespace 별 삭제
kubectl delete pods --all -n test
2. pods 특정 이름으로 삭제
<namespace> 자리에 namespace 입력 - test
/application/ 자리에 삭제할 이름 입력 - /nginx/
kubectl get pods -n <namespace> --no-headers=true | awk '/application/{print $1}'| xargs kubectl delete -n <namespace> pod
#namesapce가 test이고 test namespace안에 nginx라는 이름이 들어가는 pods 전체 삭제
kubectl get pods -n test --no-headers=true | awk '/nginx/{print $1}'| xargs kubectl delete -n test pod
참고 :
https://www.baeldung.com/linux/kubernetes-delete-all-pods
https://stackoverflow.com/questions/59473707/kubernetes-pod-delete-with-pattern-match-or-wildcard
반응형