Skip to content

Kubernetes: Cleanup & nodes

4 Kubernetes commands: Cleanup & nodes. Click a command to see what each part does.

Index
4 items
Click a command to see what each part does.

Cleanup & nodes4

  • kubectl delete pods -n <namespace> --field-selector=status.phase=FailedDelete failed / evicted podsDestructive

    What each part does

    1. delete podsdelete pods…
    2. --field-selector=status.phase=Failed…but only those in phase Failed (includes Evicted)
  • kubectl get pods -n <namespace> --no-headers | awk '/<pattern>/{print $1}' | xargs -r kubectl delete pod -n <namespace>Delete pods whose name matches a patternDestructive

    What each part does

    1. --no-headersdrop the header row so only data lines go through
    2. awk '/<pattern>/{print $1}'for lines matching <pattern>, print column 1 (the pod name)
    3. xargs -r kubectl delete poddelete each name; -r: skip if nothing matched
  • kubectl drain <node> --ignore-daemonsets --delete-emptydir-data; kubectl uncordon <node>Take a node out for maintenance and backCaution

    What each part does

    1. drain <node>cordon the node and evict its pods
    2. --ignore-daemonsetsdon't fail on DaemonSet pods (they stay)
    3. --delete-emptydir-dataallow evicting pods that use emptyDir (that data is lost)
    4. uncordon <node>make it schedulable again
  • kubectl top node; kubectl describe node <node>Node usage and details

    What each part does

    1. top nodeCPU/memory per node
    2. describe nodecapacity, allocatable, conditions (DiskPressure, MemoryPressure) and pods on it

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…