Skip to main content

Lab 12.1 - Resource Management Configuration

Lab Objectives

By the end of this lab, you will be able to:

  • Understand Requests and Limits.
  • Configure CPU and memory resources.
  • Understand QoS (Quality of Service) classes.
  • Configure Resource Quotas and Limit Ranges.

Estimated Duration

45-60 minutes

Prerequisites

  • kubectl installed and configured.
  • Working local Kubernetes cluster.

Part 1: Configuring Requests and Limits

Step 1.1: Create a Pod with Resources

Create pod-with-resources.yaml:

apiVersion: v1
kind: Pod
metadata:
name: resource-pod
spec:
containers:
- name: app
image: nginx:1.20
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi

Apply:

kubectl apply -f pod-with-resources.yaml

Verify:

kubectl describe pod resource-pod

Part 2: QoS Classes

Step 2.1: Understanding the Classes

Pods are classified as:

  • Guaranteed: Requests = Limits for both CPU and memory.
  • Burstable: At least one resource with Request < Limit.
  • BestEffort: No Requests or Limits.

Test different scenarios.


Part 3: Resource Quotas

Step 3.1: Create a Resource Quota

Create resource-quota.yaml:

apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-quota
namespace: default
spec:
hard:
requests.cpu: "2"
requests.memory: 4Gi
limits.cpu: "4"
limits.memory: 8Gi
pods: "10"

Apply:

kubectl apply -f resource-quota.yaml

Part 4: Limit Ranges

Step 4.1: Create a Limit Range

Create limit-range.yaml:

apiVersion: v1
kind: LimitRange
metadata:
name: mem-limit-range
namespace: default
spec:
limits:
- default:
memory: 512Mi
cpu: 500m
defaultRequest:
memory: 256Mi
cpu: 100m
type: Container

Lab Summary

In this lab, you configured resource management with Requests, Limits, Resource Quotas, and Limit Ranges.


Next Steps

The next lab will show you how to configure horizontal and vertical autoscaling.

Lab 12.2: Horizontal and Vertical Autoscaling


Lab created on: December 2024