A LimitRange is a Kubernetes resource that sets default resource limits and requests for containers in a namespace. It helps control how much CPU and memory each container can use.
Click to reveal answer
beginner
How does a LimitRange set default resource limits?
A LimitRange can specify default CPU and memory limits and requests. If a container does not specify these, Kubernetes applies the defaults from the LimitRange automatically.
Click to reveal answer
intermediate
What happens if a container requests resources outside the LimitRange?
If a container requests resources less than the minimum or more than the maximum defined in the LimitRange, Kubernetes rejects the pod creation with an error.
Click to reveal answer
intermediate
Example YAML snippet to set default CPU and memory limits using LimitRange?
Why use LimitRanges for defaults in a Kubernetes namespace?
LimitRanges help ensure fair resource use, prevent resource starvation, and avoid unexpected high resource consumption by setting sensible defaults and limits for containers.
Click to reveal answer
What does a LimitRange resource in Kubernetes do?
ASets default and max resource limits for containers in a namespace
BManages network policies for pods
CSchedules pods to nodes
DStores container images
✗ Incorrect
LimitRange sets default and maximum CPU and memory limits for containers in a namespace.
If a container does not specify resource requests, what happens when a LimitRange with defaults exists?
AThe container runs without any resource limits
BThe pod is rejected
CKubernetes applies the default resource requests and limits from the LimitRange
DThe pod is scheduled to a random node
✗ Incorrect
Kubernetes uses the default resource requests and limits defined in the LimitRange if the container does not specify them.
What happens if a container requests more CPU than the maximum in the LimitRange?
AKubernetes ignores the request and schedules the pod
BThe pod is scheduled but marked as pending
CThe container is throttled after starting
DPod creation is rejected with an error
✗ Incorrect
Kubernetes rejects pod creation if resource requests exceed the maximum defined in the LimitRange.
Which type field is used in LimitRange to set defaults for containers?
APod
BContainer
CNode
DNamespace
✗ Incorrect
The type 'Container' is used in LimitRange to define default resource limits and requests for containers.
Why is it important to set default resource limits in Kubernetes?
ATo prevent resource overuse and ensure fair sharing
BTo speed up pod scheduling
CTo increase network bandwidth
DTo store logs efficiently
✗ Incorrect
Setting default resource limits prevents resource overuse and helps ensure fair resource sharing among containers.
Explain what a LimitRange is and how it helps manage resources in a Kubernetes namespace.
Think about how Kubernetes controls CPU and memory usage for containers.
You got /4 concepts.
Describe what happens when a container's resource requests do not match the limits set by a LimitRange.
Consider Kubernetes behavior when resource requests are outside allowed ranges.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a LimitRange in a Kubernetes namespace?
easy
A. To schedule pods on specific nodes
B. To set default and maximum resource limits for containers in that namespace
C. To create network policies for pods
D. To manage persistent storage volumes
Solution
Step 1: Understand LimitRange role
A LimitRange defines default, minimum, and maximum resource limits for containers in a namespace.
Step 2: Compare with other options
Network policies, scheduling, and storage are managed by other Kubernetes resources, not LimitRange.
Final Answer:
To set default and maximum resource limits for containers in that namespace -> Option B
Quick Check:
LimitRange controls resource limits = C [OK]
Hint: LimitRange controls resource limits, not networking or storage [OK]
Common Mistakes:
Confusing LimitRange with NetworkPolicy
Thinking LimitRange schedules pods
Assuming LimitRange manages storage
2. Which of the following is the correct YAML snippet to set a default CPU request of 100m using a LimitRange?
5. You want all containers in a namespace to have a default CPU request of 200m and a default memory request of 512Mi, but also want to ensure no container can request more than 1 CPU or 1Gi memory. Which LimitRange YAML snippet correctly enforces this?