The `kubectl` command to get all nodes in a Kubernetes cluster is:

“`bash
kubectl get nodes
“`

### **Description**:
This command lists all the nodes in your cluster and provides a summary of their current state.

### **Example Output**:
“`plaintext
NAME STATUS ROLES AGE VERSION
node-1.cluster.local Ready worker 7d v1.27.3
node-2.cluster.local Ready worker 7d v1.27.3
control-plane-node.cluster.local Ready master 7d v1.27.3
“`

### **What Each Column Represents**:
– **NAME**: The hostname or identifier of the node.
– **STATUS**: Indicates the health of the node:
– `Ready`: Node is operational and ready to schedule workloads.
– `NotReady`: Node is not healthy or available for scheduling.
– **ROLES**: Node roles, such as `master` (control plane) or `worker`.
– **AGE**: How long the node has been part of the cluster.
– **VERSION**: The version of Kubernetes running on the node.

### **Additional Useful Commands**:
1. **Detailed Information About a Node**:
“`bash
kubectl describe node [NODE_NAME]
“`
Provides details about the node, including conditions, resource capacity, and usage.

2. **List Nodes with Labels**:
“`bash
kubectl get nodes –show-labels
“`
Displays all nodes along with their associated labels, which are used for workload scheduling.

3. **Node Resource Usage** (requires metrics server):
“`bash
kubectl top nodes
“`
Shows the CPU and memory usage for all nodes in the cluster.

These commands help monitor and manage the nodes effectively in a Kubernetes cluster.

Sign In

Sign Up