kubernetes cluster metrics
- When you run a pod, some load is laid on the node that runs it.
 
- The pod consume some of the memory and cpu power of that node.
 
- We'll use a tool called 
metrics-server to inspect resources.
 
- For minikube, the resource-server is available as an 
addon.
Here's how to install it (my profile is called five): 
 1$> kubectl top pods
 2error: Metrics API not available
 3$> minikube addons -p five enable metrics-server
 4💡  metrics-server is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
 5You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
 6    ▪ Using image registry.k8s.io/metrics-server/metrics-server:v0.7.1
 7🌟  The 'metrics-server' addon is enabled
 8$> kubectl top pods
 9error: Metrics API not available
10
11(**STILL GETTING ERRORS BECAUSE IT IS NOT READY**)
12
13$> kubectl top pods
14NAME         CPU(cores)   MEMORY(bytes)   
15envvar-pod   0m           0Mi             
16volume-pod   0m           0Mi             
17$> 
Memory Size Units
- Memory is generally measured in 
bytes
 
- There are Decimal and Binary  systems for memory multiple-byte unit.
 
- For example:
- 103 = 1000 bytes is called kilobyte (short kB)
 
- 210 = 1024 bytes is called kibibyte (short KiB)
 
 
- See a list of these units 
here
 
CPU load Units
- CPU is measure in 
CPU resource units
 
- In Kubernetes, 1 CPU unit is equivalent to 1 physical cpu core, or 1 virtual core, depending on whether the node is a physical host or a virtual machine running inside a physical machine
 
- Fractional units (so fractions of 1 CPU) are allowed.
 
- For example, 100m is the same as 0.1, which is 1/10 of a single cpu
 
- Another example: 0.5m is 5/1000 or 1/2 of a mili-cpu
 
The top command
- Here's an example:
We are creating a pod, exec into it, them run a script to create some load in this pod.
It may take 2-3 minutes until you'll see this reflected in the metrics: 
 1$> 
 2$> kubectl apply -f pod.yaml 
 3pod/my-pod created
 4$> kubectl get pods
 5NAME     READY   STATUS    RESTARTS   AGE
 6my-pod   1/1     Running   0          10s
 7$> kubectl exec -it my-pod -- sh
 8/ # 
 9/ # for i in 1 2 3 4; do while : ; do : ; done & done
10/ # 
11/ # exit
12$> 
13$> 
14$> kubectl top pods
15NAME     CPU(cores)   MEMORY(bytes)   
16my-pod   1m           0Mi             
17$> kubectl top pods
18NAME     CPU(cores)   MEMORY(bytes)   
19my-pod   1m           0Mi             
20$> 
21$> kubectl top pods
22NAME     CPU(cores)   MEMORY(bytes)   
23my-pod   3582m        1Mi             
24$> 
25$> kubectl top pods
26NAME     CPU(cores)   MEMORY(bytes)   
27my-pod   3978m        1Mi             
28$> kubectl top pods
29NAME     CPU(cores)   MEMORY(bytes)   
30my-pod   3978m        1Mi             
31$>