Kubectl Get Nodes Sort by AGE, IP and more | Devops Junction

In this short article, we are going to see some command variations and options with kubectl get nodes to sort the nodes by age ( creation time), last transition time, IP address etc.

let us see the quick Kubectl command to Get nodes in the cluster sorted by their Age

~ kubectl get nodes – sort-by=".metadata.creationTimestamp"

 

Sometimes you would want to sort the Nodes by their last transition time and you can use the following command

~ kubectl get nodes – sort-by=".status.conditions[?(@.reason == 'KubeletReady' )].lastTransitionTime"

 

Here is a command to get nodes sorted by their IP range

kubectl get nodes – sort-by=".status.addresses[?(@.type == 'InternalIP' )].address"