0
0
Kubernetesdevops~30 mins

Memory requests and limits in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Memory requests and limits
📖 Scenario: You are managing a Kubernetes cluster where you need to ensure that your application pods have proper memory allocation. This helps the cluster schedule pods efficiently and prevents pods from using too much memory and affecting others.
🎯 Goal: You will create a Kubernetes pod configuration YAML file that sets memory requests and limits for a container. This ensures the pod requests a minimum amount of memory and does not exceed a maximum amount.
📋 What You'll Learn
Create a pod manifest YAML with a container named myapp
Set the container's memory request to 128Mi
Set the container's memory limit to 256Mi
Use the resources field under the container spec to define requests and limits
💡 Why This Matters
🌍 Real World
Setting memory requests and limits is essential in real Kubernetes clusters to avoid resource contention and ensure fair resource distribution among applications.
💼 Career
Understanding how to configure resource requests and limits is a key skill for DevOps engineers and site reliability engineers managing containerized applications.
Progress0 / 4 steps
1
Create the basic pod YAML structure
Create a YAML manifest for a pod named memory-demo with one container named myapp using the image nginx. Include the apiVersion, kind, metadata, and spec sections.
Kubernetes
Need a hint?

Start with the basic pod YAML structure including apiVersion, kind, metadata, and spec. Add one container named myapp with image nginx.

2
Add memory requests configuration
Add a resources section under the container myapp and set the memory request to 128Mi.
Kubernetes
Need a hint?

Under the container, add resources: then requests: and set memory: "128Mi".

3
Add memory limits configuration
Extend the resources section to add a memory limit of 256Mi alongside the existing memory request.
Kubernetes
Need a hint?

Under resources:, add limits: and set memory: "256Mi" to limit the container's memory usage.

4
Display the complete pod YAML
Print the complete YAML manifest for the pod named memory-demo with the container myapp having memory requests of 128Mi and limits of 256Mi.
Kubernetes
Need a hint?

Show the full YAML manifest you created with memory requests and limits included.