Kubernetes metrics allow you to gain insight into a wide variety of data about your Kubernetes applications. You can use these metrics to gain insight into how your compute resources are being used. In this lab, you will have the opportunity to hone your skills by investigating existing pods running in a Kubernetes cluster to determine which ones are using the most CPU.
You are working for BeeBox, a company that provides regular shipments of bees to customers. The company is in the process of building a Kubernetes-based infrastructure for some of their software.
It looks like a pod in the cluster may be using more CPU than expected. Search the beebox-mobile
namespace for pods with the label app=auth
, and determine which of these pods is using the most CPU. Save the name of that pod to a file for future reference.
The cluster does not have Metrics Server installed, so you will need to install it in order to perform this task.
-
Install Kubernetes Metrics Server
Install the Kubernetes Metrics Server in the cluster. Use this file to install Metrics Server: https://raw.githubusercontent.com/ACloudGuru-Resources/content-cka-resources/master/metrics-server-components.yaml
-
Locate the CPU-Using Pod and Write Its Name to a File
Locate the pod using the most CPU that also meets the following criteria:
- Located in the
beebox-mobile
namespace - Has the label
app=auth
Ignore any pods that do not meet those criteria, even if they are using more CPU.
Write the name of the pod to the file
/home/cloud_user/cpu-pod-name.txt
. - Located in the
-
Log in to the lab server using the credentials provided:
ssh cloud_user@<PUBLIC_IP_ADDRESS>
-
Install Kubernetes Metrics Server:
kubectl apply -f https://raw.githubusercontent.com/ACloudGuru-Resources/content-cka-resources/master/metrics-server-components.yaml
-
Verify Metrics Server is responsive:
kubectl get --raw /apis/metrics.k8s.io/
-
It may take a few minutes for Metrics Server to become responsive to requests.
-
In the
beebox-mobile
namespace, determine which pod with the labelapp=auth
is using the most CPU:kubectl top pod -n beebox-mobile --sort-by cpu --selector app=auth
-
If you get an error message saying metrics are not available, wait a few minutes and then run the command again.
-
Write the name of the pod to a file:
echo auth-proc > /home/cloud_user/cpu-pod-name.txt