CKA (Certified Kubernetes Administrator)/Kode Kloud

03.Logging & Monitoring - Monitor Cluster Components

seulseul 2022. 1. 20. 16:09
LABS – CERTIFIED KUBERNETES ADMINISTRATOR WITH PRACTICE TESTS >
LOGGING & MONITORING, PRACTICE TEST MONITOR CLUSTER COMPONENTS

Logging & Monitoring

 

01. We have deployed a few PODs running workloads. Inspect them.

Wait for the pods to be ready before proceeding to the next question.

- Ok

02. Let us deploy metrics-server to monitor the PODs and Nodes. Pull the git repository for the deployment files.

 

03. Deploy the metrics-server by creating all the components downloaded.

Run the kubectl create -f . command from within the downloaded repository.

CheckCompleteIncomplete
  • Metrics server deployed?
root@controlplane:~# cd kubernetes-metrics-server/
root@controlplane:~/kubernetes-metrics-server# ls
README.md                       auth-delegator.yaml  metrics-apiservice.yaml         metrics-server-service.yaml
aggregated-metrics-reader.yaml  auth-reader.yaml     metrics-server-deployment.yaml  resource-reader.yaml
root@controlplane:~/kubernetes-metrics-server# kubectl create -f .
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
serviceaccount/metrics-server created
deployment.apps/metrics-server created
service/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created

04. It takes a few minutes for the metrics server to start gathering data.

Run the kubectl top node command and wait for a valid output.

root@controlplane:~/kubernetes-metrics-server# kubectl top node
NAME           CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
controlplane   359m         0%     1249Mi          0%        
node01         55m          0%     340Mi           0%

05. Identify the node that consumes the most CPU.

root@controlplane:~/kubernetes-metrics-server# kubectl top node --sort-by='cpu'
NAME           CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
controlplane   434m         1%     1260Mi          0%        
node01         60m          0%     345Mi           0%

06. Identify the node that consumes the most Memory.

root@controlplane:~/kubernetes-metrics-server# kubectl top node --sort-by='memory'
NAME           CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%   
controlplane   365m         1%     1211Mi          0%        
node01         70m          0%     346Mi           0%

07. Identify the POD that consumes the most Memory.

root@controlplane:~/kubernetes-metrics-server# kubectl top pod --sort-by='memory'
NAME       CPU(cores)   MEMORY(bytes)   
rabbit     136m         252Mi           
elephant   21m          32Mi            
lion       1m           19Mi

08. Identify the POD that consumes the least CPU.

root@controlplane:~/kubernetes-metrics-server# kubectl top pod --sort-by='cpu'
NAME       CPU(cores)   MEMORY(bytes)   
rabbit     143m         252Mi           
elephant   22m          32Mi            
lion       1m           19Mi