kubernetes/get-nodes

Get Nodes

List all nodes in the Kubernetes cluster.

nodes
monitoring

Command

kubectl get nodes

Explanation

The 'kubectl get nodes' command lists all nodes participating in the Kubernetes cluster, showing their names, statuses, roles, and resource versions. The output helps cluster administrators monitor the state of nodes, determine readiness, and ensure proper node registration. With '-o wide', you can view IP addresses, OS details, and Kubernetes versions.

Common Use Cases

  • Monitor node health and readiness
  • Verify cluster scaling after adding new nodes
  • Check node roles and Kubernetes versions

Best Practices

  • Regularly check node readiness before scheduling workloads
  • Use JSON or YAML output formats for automation or scripting

Common Mistakes to Avoid

  • Assuming 'Ready' means all pods are healthy — it only indicates node availability
  • Forgetting '-o wide' for additional insights like internal IPs and versions

Troubleshooting

Problem: A node shows 'NotReady' status

Solution: Run 'kubectl describe node <name>' to inspect conditions and kubelet logs for failures.

Examples

List all nodes in the cluster

kubectl get nodes

List nodes with detailed info like IP and OS

kubectl get nodes -o wide