modified: README.md

This commit is contained in:
Márcio Fernandes committed 2026-09-13 19:26:17 +00:00
1 parent eba7eb86e2
commit 4e914398fd
1 file changed
+25
+25
View File
@@ -9,6 +9,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)
- [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)
@@ -250,6 +251,30 @@ echo $POD_NAME
kubectl delete pod -n appNamespace -l app=myAppName kubectl delete pod -n appNamespace -l app=myAppName
``` ```
### delete all Failed pods
``` bash
kubectl get pods --all-namespaces --field-selector=status.phase=Failed --no-headers | wc -l
```
``` bash
count=0
while true; do
pods=$(kubectl get pods --all-namespaces --field-selector=status.phase=Failed \
-o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' \
| head -n 100)
[ -z "$pods" ] && break
echo "Batch $((++count)): deleting up to 100 pods"
while read ns name; do
kubectl delete pod "$name" -n "$ns"
done <<< "$pods"
done
```
### delete all pods with prefix ### delete all pods with prefix
``` bash ``` bash