aboutsummaryrefslogtreecommitdiff
path: root/content/blog/kubernetes/delete-all-evicted-pods.md
diff options
context:
space:
mode:
authorJulien Dessaux2021-09-01 14:53:05 +0200
committerJulien Dessaux2021-09-01 14:54:20 +0200
commitb9e13eea30fa89d3de8983e9cd2205ace75f2a61 (patch)
treea3a60374d0fb476470b8cf33d49768e207a9127d /content/blog/kubernetes/delete-all-evicted-pods.md
parentAdded oathbringer book article (diff)
downloadwww-b9e13eea30fa89d3de8983e9cd2205ace75f2a61.tar.gz
www-b9e13eea30fa89d3de8983e9cd2205ace75f2a61.tar.bz2
www-b9e13eea30fa89d3de8983e9cd2205ace75f2a61.zip
Added kubernetes evicted pods article
Diffstat (limited to '')
-rw-r--r--content/blog/kubernetes/delete-all-evicted-pods.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/content/blog/kubernetes/delete-all-evicted-pods.md b/content/blog/kubernetes/delete-all-evicted-pods.md
new file mode 100644
index 0000000..ec624fd
--- /dev/null
+++ b/content/blog/kubernetes/delete-all-evicted-pods.md
@@ -0,0 +1,22 @@
+---
+title: How to delete all evicted pods in kubernetes
+description: A quick note for future reference
+date: 2021-09-01
+---
+
+## Introduction
+
+I was playing with the percona xtradb operator on one of my test clusters last week and left it in a state where mysqld errors logs were piling up over the week-end. On monday morning my nodes had their filesystems full and I discovered what kubernetes evicted pods were : pods that fail when a node's resources get constrained.
+
+My problem is : these evicted pods lingered, so I looked for a way to clean them up.
+
+## How to delete all evicted pods
+
+My google fu directed my towards several commands looking like the following, but they all had a thing or another that did not work. Here is the one I pieced together from these various resources :
+```sh
+kubectl get pods --all-namespaces -o json |
+ jq '.items[] | select(.status.reason!=null) |
+ select(.status.reason | contains("Evicted")) |
+ "kubectl -n \(.metadata.namespace) delete pod \(.metadata.name)"' |
+ xargs -n 1 bash -c
+```