From 9168ab558100823b89fc78575adca97358426f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Sun, 20 Sep 2026 22:31:22 +0000 Subject: [PATCH] modified: README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 859b1f1..3e5b3f2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Kubernetes is an open‑source platform that automates the deployment, scaling, - [Create an pod](#create-an-pod) - [Get Pod](#get-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) - [OOMKilled](#oomkilled) - [Attach to an pod](#attach-to-an-pod) @@ -254,23 +254,27 @@ echo $POD_NAME kubectl delete pod -n appNamespace -l app=myAppName ``` -### delete all Failed pods +### Failed pods +List all. + ``` bash kubectl get pods --all-namespaces --field-selector=status.phase=Failed --no-headers | wc -l ``` +Delete + ``` 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) + | head -n 500) [ -z "$pods" ] && break - echo "Batch $((++count)): deleting up to 100 pods" + echo "Batch $((++count)): deleting up to 500 pods" while read ns name; do kubectl delete pod "$name" -n "$ns"