0
0
Kubernetesdevops~30 mins

Resource monitoring best practices in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Resource monitoring best practices
📖 Scenario: You are managing a Kubernetes cluster for a small web application. To keep the application healthy and efficient, you need to monitor resource usage like CPU and memory. This helps avoid crashes and slowdowns.
🎯 Goal: Build a simple Kubernetes Pod manifest with resource requests and limits set. Then, add a label to help identify the Pod for monitoring tools. Finally, print the Pod manifest to verify your setup.
📋 What You'll Learn
Create a Pod manifest named webapp-pod.yaml with a container named webapp
Set CPU request to 100m and memory request to 200Mi
Set CPU limit to 500m and memory limit to 500Mi
Add a label app: webapp to the Pod metadata
Print the Pod manifest content
💡 Why This Matters
🌍 Real World
In real Kubernetes clusters, setting resource requests and limits prevents resource contention and helps monitoring tools track application health.
💼 Career
DevOps engineers and site reliability engineers use these best practices daily to maintain stable and efficient cloud applications.
Progress0 / 4 steps
1
Create the basic Pod manifest
Create a YAML file named webapp-pod.yaml with a Pod named webapp-pod that has one container named webapp using the image nginx. Include only the basic structure with apiVersion, kind, metadata, and spec with the container name and image.
Kubernetes
Need a hint?

Start with the basic Pod YAML structure. Use apiVersion: v1 and kind: Pod. Add metadata with the Pod name and a spec with one container.

2
Add resource requests and limits
In the webapp-pod.yaml, add resource requests for CPU as 100m and memory as 200Mi. Also add resource limits for CPU as 500m and memory as 500Mi under the container named webapp.
Kubernetes
Need a hint?

Under the container, add a resources section with requests and limits. Use quotes around the values.

3
Add a label for monitoring
Add a label app: webapp under the metadata section of the Pod manifest webapp-pod.yaml. This label helps monitoring tools identify the Pod.
Kubernetes
Need a hint?

Under metadata, add a labels section with app: webapp.

4
Print the Pod manifest
Print the contents of the webapp-pod.yaml file to verify the Pod manifest with resource requests, limits, and label.
Kubernetes
Need a hint?

Use print statements to output each line of the Pod manifest exactly as in the YAML.