modified: README.md
This commit is contained in:
1 parent
060ea17354
commit
9168ab5581
1 file changed
+8
-4
@@ -10,7 +10,7 @@ Kubernetes is an open‑source platform that automates the deployment, scaling,
|
|||||||
- [Create an pod](#create-an-pod)
|
- [Create an pod](#create-an-pod)
|
||||||
- [Get Pod](#get-pod)
|
- [Get Pod](#get-pod)
|
||||||
- [delete Pod](#delete-pod)
|
- [delete Pod](#delete-pod)
|
||||||
- [delete all Failed pods](#delete-all-failed-pods)
|
- [Failed pods](#failed-pods)
|
||||||
- [delete all pods with prefix](#delete-all-pods-with-prefix)
|
- [delete all pods with prefix](#delete-all-pods-with-prefix)
|
||||||
- [OOMKilled](#oomkilled)
|
- [OOMKilled](#oomkilled)
|
||||||
- [Attach to an pod](#attach-to-an-pod)
|
- [Attach to an pod](#attach-to-an-pod)
|
||||||
@@ -254,23 +254,27 @@ echo $POD_NAME
|
|||||||
kubectl delete pod -n appNamespace -l app=myAppName
|
kubectl delete pod -n appNamespace -l app=myAppName
|
||||||
```
|
```
|
||||||
|
|
||||||
### delete all Failed pods
|
### Failed pods
|
||||||
|
|
||||||
|
|
||||||
|
List all.
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
kubectl get pods --all-namespaces --field-selector=status.phase=Failed --no-headers | wc -l
|
kubectl get pods --all-namespaces --field-selector=status.phase=Failed --no-headers | wc -l
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Delete
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
count=0
|
count=0
|
||||||
while true; do
|
while true; do
|
||||||
pods=$(kubectl get pods --all-namespaces --field-selector=status.phase=Failed \
|
pods=$(kubectl get pods --all-namespaces --field-selector=status.phase=Failed \
|
||||||
-o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' \
|
-o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' \
|
||||||
| head -n 100)
|
| head -n 500)
|
||||||
|
|
||||||
[ -z "$pods" ] && break
|
[ -z "$pods" ] && break
|
||||||
|
|
||||||
echo "Batch $((++count)): deleting up to 100 pods"
|
echo "Batch $((++count)): deleting up to 500 pods"
|
||||||
|
|
||||||
while read ns name; do
|
while read ns name; do
|
||||||
kubectl delete pod "$name" -n "$ns"
|
kubectl delete pod "$name" -n "$ns"
|
||||||
|
|||||||
Reference in new issue
Block a user