Files
my-docs/Containerization & Orchestration/Kubernetes/node-manage.md
2025-06-29 16:56:28 +03:30

1.1 KiB

🌐 Node Management with Kubernetes

Efficient management of Kubernetes nodes ensures cluster stability and workload flexibility. Below are key commands for listing and maintaining nodes.


📋 Listing Nodes

🔹 Show All Nodes

kubectl get nodes

🔹 Show Nodes with Labels

kubectl get nodes --show-labels

🔧 Node Maintenance (Cordon / Drain)

🚫 Cordon a Node

Prevent new pods from being scheduled on the node.

kubectl cordon <node-name>

Uncordon a Node

Mark the node as schedulable again.

kubectl uncordon <node-name>

🧹 Drain a Node

Evict all pods from the node (excluding those managed by DaemonSets).

  • Forcefully drain the node:

    kubectl drain <node-name> --ignore-daemonsets --force
    
  • Drain and delete local data:

    kubectl drain <node-name> --ignore-daemonsets --delete-local-data
    

🔄 Undo Drain (Uncordon)

kubectl uncordon <node-name>

⚠️ Warning: Draining a node will evict running pods. Ensure that this is planned to avoid service disruption.