How to Read Nodes in Kubernetes [Quick K8s Tip]
This quick Kubernetes tip helps you to get details about a Kubernetes worker node and how to read and understand its output.
What is a Kubernetes node?
A node is a worker machine (virtual/physical) in Kubernetes where pods carrying your applications run. The services which runs on a node include Docker, kubelet and kube-proxy.
Listing available nodes in your Kubernetes cluster
The simplest way to see the available nodes is by using the kubectl command in this fashion:
kubectl get nodes
It should show you all the nodes in your cluster at a glance. You can see the status, role, age and version of each node.
root@kmaster-rj:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
kmaster-rj Ready master 39d v1.18.8
kworker-rj1 Ready <none> 39d v1.18.8
kworker-rj2 Ready <none> 39d v1.18.8
root@kmaster-rj:~#
As you can see both the worker nodes are in ready state.
In order to view a more detailed output run following command, you can add the -o wide
option like this:
kubectl get nodes -o wide
Now you'll see additional details like internal and external IP, container image, kernel version and runtime for the container.
root@kmaster-rj:~# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
kmaster-rj Ready master 39d v1.18.8 172.42.42.200 <none> Ubuntu 18.04.5 LTS 4.15.0-101-generic docker://19.3.6
kworker-rj1 Ready <none> 39d v1.18.8 172.42.42.201 <none> Ubuntu 18.04.4 LTS 4.15.0-101-generic docker://19.3.6
kworker-rj2 Ready <none> 39d v1.18.8 172.42.42.202 <none> Ubuntu 18.04.5 LTS 4.15.0-101-generic docker://19.3.6
Let's go deeper and know more about a specific node.
Describing a node for more details
If you want detailed information on a specific node, you can use the kubectl describe
command with the node name:
kubectl describe nodes worker-node-name
Here's a sample output:
root@kmaster-rj:~# kubectl describe nodes kworker-rj1
Name: kworker-rj1
Roles: <none>
Labels: app=front-end
beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/arch=amd64
kubernetes.io/hostname=kworker-rj1
kubernetes.io/os=linux
size=medium
Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: 0
projectcalico.org/IPv4Address: 172.42.42.201/24
projectcalico.org/IPv4IPIPTunnelAddr: 172.16.213.0
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Sun, 02 Aug 2020 15:42:32 +0000
Taints: app=front-end:NoExecute
Unschedulable: false
Lease:
HolderIdentity: kworker-rj1
AcquireTime: <unset>
RenewTime: Fri, 11 Sep 2020 07:09:51 +0000
Conditions:
Type Status LastHeartbeatTime LastTransitionTime Reason Message
---- ------ ----------------- ------------------ ------ -------
NetworkUnavailable False Fri, 11 Sep 2020 02:57:12 +0000 Fri, 11 Sep 2020 02:57:12 +0000 CalicoIsUp Calico is running on this node
MemoryPressure False Fri, 11 Sep 2020 07:06:56 +0000 Fri, 28 Aug 2020 06:33:29 +0000 KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False Fri, 11 Sep 2020 07:06:56 +0000 Fri, 28 Aug 2020 06:33:29 +0000 KubeletHasNoDiskPressure kubelet has no disk pressure
PIDPressure False Fri, 11 Sep 2020 07:06:56 +0000 Fri, 28 Aug 2020 06:33:29 +0000 KubeletHasSufficientPID kubelet has sufficient PID available
Ready True Fri, 11 Sep 2020 07:06:56 +0000 Fri, 11 Sep 2020 02:56:03 +0000 KubeletReady kubelet is posting ready status. AppArmor enabled
Addresses:
InternalIP: 172.42.42.201
Hostname: kworker-rj1
Capacity:
cpu: 2
ephemeral-storage: 64800356Ki
hugepages-2Mi: 0
memory: 2040812Ki
pods: 110
Allocatable:
cpu: 2
ephemeral-storage: 59720007991
hugepages-2Mi: 0
memory: 1938412Ki
pods: 110
System Info:
Machine ID: c7dbeba40d7b45a387082c96df6cc554
System UUID: 595C28CA-DBBF-304D-8C5A-7862AA0A60E5
Boot ID: 306f36e0-ded3-4b45-946a-89509f845c21
Kernel Version: 4.15.0-101-generic
OS Image: Ubuntu 18.04.4 LTS
Operating System: linux
Architecture: amd64
Container Runtime Version: docker://19.3.6
Kubelet Version: v1.18.8
Kube-Proxy Version: v1.18.8
Non-terminated Pods: (5 in total)
Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE
--------- ---- ------------ ---------- --------------- ------------- ---
default toleration-demo-dep-54f9ff64b9-7zcrn 0 (0%) 0 (0%) 0 (0%) 0 (0%) 4h9m
default toleration-demo-dep-54f9ff64b9-9sldm 0 (0%) 0 (0%) 0 (0%) 0 (0%) 4h9m
default toleration-demo-dep-54f9ff64b9-rgh7z 0 (0%) 0 (0%) 0 (0%) 0 (0%) 4h9m
kube-system calico-node-2jlhm 250m (12%) 0 (0%) 0 (0%) 0 (0%) 39d
kube-system kube-proxy-54894 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22d
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 250m (12%) 0 (0%)
memory 0 (0%) 0 (0%)
ephemeral-storage 0 (0%) 0 (0%)
hugepages-2Mi 0 (0%) 0 (0%)
Events: <none>
That's a lot of information. What's important for you?
- Most of the information is informational regarding the system IP, hostname, resources (CPUs, GPUs, memory) and version information (OS, Docker, Kubernetes).
- kubelet service status.
- Unschedulable parameter.
- The Conditions section can indicate whether there are system resource issues that will affect the running of the application. For example, if any of the OutOfDisk, MemoryPressure, or DiskPressure conditions are True, there are insufficient system resources to serve further workloads.
- The Events section at last will also have messages that can indicate if there are issues with the environment.
Hope you like this quick Kubernetes tip. Stay tuned and don't forget to subscribe for more.