- Lab
- A Cloud Guru
Using Prometheus with Kubernetes
This lab guides the student through basic Prometheus Queries (PromQL) and demonstrates how the Kubernetes architecture may be interrogated. The lab also introduces a simple means of stressing a cluster and demonstrates how those techniques affect the metrics being stored in the time series database.
Path Info
Table of Contents
-
Challenge
Check that your lab environment is ready.
Log in to the master node:
ssh cloud_user@[Public IP here]
List the home directory contents:
ls -l
Verify that
stress-test.yaml
is present. -
Challenge
Access Prometheus from your browser.
Access Prometheus from your browser:
http://[Master Node public ip address]:9090
You may also access the sAdvisor dashboard at the following address:
http://[Worker Node Public IP Address]:8080
-
Challenge
Use the provided PromQL queries to interrogate your cluster.
The following are the suggested PromQL queries you may perform.
To measure CPU utilization:
node_cpu_seconds_total
irate(node_cpu_seconds_total{job="node"}[5m])
avg(irate(node_cpu_seconds_total{job="node"}[5m])) by (instance)
avg(irate(node_cpu_seconds_total{job="node",mode="idle"}[5m])) by (instance) * 100
100 - avg(irate(node_cpu_seconds_total{job="node",mode="idle"}[5m])) by (instance) * 100
To measure memory, use:
(node_memory_MemTotal_bytes - (node_memory_MemFree_bytes + node_memory_Cached_bytes + node_memory_Buffers_bytes)) / node_memory_MemTotal_bytes * 100
-
Challenge
Deploy the stress test and vary its replicas to examine changes.
In the terminal emulator session that is established to the Master Node:
Deploy the Stress-Test Deployment:
kubectl create -f stress-test.yaml
Interrogate the number of replicas deployed:
kubectl get deployments
Interrogate the pods running:
kubectl get pods
-
Challenge
Refresh your Prometheus graphs and scale the deployment up and down to vary metrics.
Use refresh on your browser to see the time series metrics change over time.
Use the following command to increase and decrease the number of replicas running in the stress-test deployment.
kubectl scale deployment.v1.apps/stress-test --replicas=[from 1 to 50 here]
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.