How do I delete Errored or Evicted pods?

Purpose

In situations such as the following, one or more NSP pods may enter the Errored or Evicted state. The NSP raises an alarm against each such pod, and a CLI query displays them, as shown below:

namespace     pod_a      1/1     Running   0    18m

namespace     pod_b      1/1     Errored   0    18m

namespace     pod_c      0/1     Evicted   0    19m

An Errored pod is typically the result of an unplanned VM reboot.

A pod is typically Evicted because of insufficient storage space on the host node, which is often called disk pressure.

In either case, the Kubernetes orchestrater reschedules the pod to a different node in the NSP cluster.

Each Errored or Evicted pod is preserved for forensic analysis, but consumes no host resources. When the investigation of the pod failure is complete, you can safely delete the preserved pod.

Perform the following procedure to delete all Errored or Evicted pods in an NSP cluster.

Steps
 

Log in as the root user on the NSP cluster host.


Open a console window.


Enter the following to list the pods in the NSP cluster.

kubectl get pods -A ↵

The pods are listed.


Enter the following:

kubectl get pods -A | awk '$4 ~ /Evicted|Error/{print $1, $2}' | xargs -n 2 kubectl delete pod -n ↵

Each Errored or Evicted pod is deleted.


Enter the following:

kubectl get pods -A ↵

The pods are listed.


Verify that no Errored or Evicted pods remain in the cluster.


Close the console window.

End of steps