Kubectl status nodes provides different responses for equivalent clusters

6/19/2020

I have recently started using kubectl krew (v0.3.4), which later was used to install "status" plugin (v0.4.1).

I am managing right now different clusters, and I'm checking the nodes' status. Most of the clusters answer something exactly like:

Node/[NodeName], created 25d ago  linux Oracle Linux Server 7.8     
(amd64), kernel 4.1.12-124.36.4.el7uek.x86_64, kubelet v1.18.2, kube-proxy v1.18.2 
cpu: 0.153/7 (2%)     
mem: 4.4GB/7.1GB (63%)    
ephemeral-storage: 2.2GB 

There is one cluster that answers, for some reason:

Node/[nodeName], created 11d ago     
linux Oracle Linux Server 7.8 (amd64), kernel 4.1.12-124.26.5.el7uek.x86_64, kubelet v1.18.2, kube-proxy v1.18.2     
cpu: 5, mem: 7.1GB, ephemeral-storage: 2.2GB

(Let me clarify that I'm trying to automate some resources checking and the way resources are differently displayed is quite annoying, plus the used vs total resources is exactly what I need!)

I am absolutely unable to locate the status plugin repo, and I have no idea where to go with this issue. kubectl version says that both clusters have the same server version, I'm executing the kubectl status command from my local in both cases and... I am completely out of ideas.

Does anyone know why this might be happening, or when can I go to look for answers?

-- Roberto Gutierrez
kubectl
kubernetes
status

1 Answer

6/26/2020

To display used and total resources you can use kubectl top

Display Resource (CPU/Memory/Storage) usage.

The top command allows you to see the resource consumption for nodes or pods.

This command requires Metrics Server to be correctly configured and working on the server.

Available Commands: node Display Resource (CPU/Memory/Storage) usage of nodes pod Display Resource (CPU/Memory/Storage) usage of pods

Usage: kubectl top flags

You can also have a look at Tools for Monitoring Resources inside Kubernetes docs.

As for doing the same using Kubernetes Python Client you can use:

from kubernetes.config import load_kube_config                                  
from kubernetes.client import CustomObjectsApi                                  
load_kube_config()                                                              
cust = CustomObjectsApi()                                                       
cust.list_cluster_custom_object('metrics.k8s.io', 'v1beta1', 'nodes') # All node metrics
cust.list_cluster_custom_object('metrics.k8s.io', 'v1beta1', 'pods') # All Pod Metrics
-- Crou
Source: StackOverflow