Logging and Monitoring
Updated Dec 29, 2023 ·
Some of the scenario questions here are based on Kodekloud's CKA course labs.
NOTE
CKAD and CKA can have similar scenario questions. It is recommended to go through the CKAD practice tests.
Shortcuts
First run the two commands below for shortcuts.
export do="--dry-run=client -o yaml"
export now="--force --grace-period=0"
Questions
-
Deploy metrics-server to monitor the PODs and Nodes.
Answer
controlplane ~ ➜ k get poNAME READY STATUS RESTARTS AGEelephant 1/1 Running 0 10slion 1/1 Running 0 10srabbit 1/1 Running 0 10scontrolplane ~ ➜ git clone https://github.com/kodekloudhub/kubernetes-metrics-server.gitCloning into 'kubernetes-metrics-server'...remote: Enumerating objects: 31, done.remote: Counting objects: 100% (19/19), done.remote: Compressing objects: 100% (19/19), done.remote: Total 31 (delta 8), reused 0 (delta 0), pack-reused 12Unpacking objects: 100% (31/31), 8.06 KiB | 1.34 MiB/s, done.controlplane ~ ➜ ls -ltotal 4drwxr-xr-x 3 root root 4096 Dec 29 03:44 kubernetes-metrics-server-rw-rw-rw- 1 root root 0 Dec 13 05:39 sample.yamlcontrolplane ~ ✖ k apply -f kubernetes-metrics-server/clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader createdclusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator createdrolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader createdapiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io createdserviceaccount/metrics-server createddeployment.apps/metrics-server createdservice/metrics-server createdclusterrole.rbac.authorization.k8s.io/system:metrics-server createdclusterrolebinding.rbac.authorization.k8s.io/system:metrics-server createdStart monitoring the nodes.
controlplane ~ ➜ k top nodeNAME CPU(cores) CPU% MEMORY(bytes) MEMORY%controlplane 241m 0% 1159Mi 0%node01 24m 0% 300Mi 0% -
Identify the POD that consumes the most Memory(bytes) in default namespace.
Answer
controlplane ~ ➜ k get poNAME READY STATUS RESTARTS AGEelephant 1/1 Running 0 4m33slion 1/1 Running 0 4m33srabbit 1/1 Running 0 4m33scontrolplane ~ ➜ k top podNAME CPU(cores) MEMORY(bytes)elephant 15m 31Milion 1m 18Mirabbit 107m 252Mi -
A user - USER5 - has expressed concerns accessing the application. Identify the cause of the issue.
controlplane ~ ➜ k get poNAME READY STATUS RESTARTS AGEwebapp-1 1/1 Running 0 108sAnswer
controlplane ~ ✖ k logs webapp-1 | grep WARNING[2023-12-29 08:49:33,717] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILED ATTEMPTS.[2023-12-29 08:49:36,719] WARNING in event-simulator: USER7 Order failed as the item is OUT OF STOCK.[2023-12-29 08:49:38,722] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILED ATTEMPTS.[2023-12-29 08:49:43,728] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILED ATTEMPTS. -
A user is reporting issues while trying to purchase an item. Identify the user and the cause of the issue. Inspect the logs of the webapp-2 in the POD
controlplane ~ ➜ k get poNAME READY STATUS RESTARTS AGEwebapp-1 1/1 Running 0 2m53swebapp-2 2/2 Running 0 17sAnswer
controlplane ~ ➜ k logs webapp-2 | grep WARNINGDefaulted container "simple-webapp" out of: simple-webapp, db[2023-12-29 08:52:05,219] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILED ATTEMPTS.[2023-12-29 08:52:08,221] WARNING in event-simulator: USER30 Order failed as the item is OUT OF STOCK.[2023-12-29 08:52:10,224] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILED ATTEMPTS.[2023-12-29 08:52:15,228] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILED ATTEMPTS.[2023-12-29 08:52:16,229] WARNING in event-simulator: USER30 Order failed as the item is OUT OF STOCK.