0
0
Kubernetesdevops~20 mins

CPU requests and limits in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CPU Resource Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding CPU Requests vs Limits

In Kubernetes, what happens when a container exceeds its CPU request but stays below its CPU limit?

AThe container is allowed to use unlimited CPU resources.
BThe container is throttled to stay within the CPU limit but can use more CPU than requested.
CThe container is paused until CPU usage drops below the request.
DThe container is immediately terminated for exceeding the CPU request.
Attempts:
2 left
💡 Hint

Think about how Kubernetes manages guaranteed CPU resources versus maximum allowed CPU.

💻 Command Output
intermediate
1:30remaining
CPU Limit Enforcement Output

Given this pod spec snippet with CPU requests and limits, what will be the CPU usage behavior if the container tries to use 2 CPUs but the limit is set to 1 CPU?

resources:
  requests:
    cpu: "500m"
  limits:
    cpu: "1"
AThe container will be throttled and cannot use more than 1 CPU.
BThe container will use 2 CPUs without restriction.
CThe container will be killed for exceeding the CPU limit.
DThe container will only use 500m CPU and no more.
Attempts:
2 left
💡 Hint

CPU limits set the maximum CPU a container can use.

Configuration
advanced
2:00remaining
Correct CPU Resource Configuration

Which of the following Kubernetes container resource configurations correctly sets a CPU request of 250m and a CPU limit of 500m?

A
resources:
  requests:
    cpu: "250m"
  limits:
    cpu: "500m"
B
resources:
  requests:
    cpu: 250
  limits:
    cpu: 500
C
resources:
  requests:
    cpu: "0.25"
  limits:
    cpu: "0.5"
D
resources:
  requests:
    cpu: "250"
  limits:
    cpu: "500"
Attempts:
2 left
💡 Hint

CPU values in Kubernetes are usually specified in millicores with 'm' suffix.

Troubleshoot
advanced
1:30remaining
Diagnosing CPU Throttling Issues

A developer complains their pod is running slower than expected. The pod has CPU requests and limits set. Which kubectl command helps check if the pod is being CPU throttled?

Akubectl exec <pod-name> -- top
Bkubectl get pods --all-namespaces
Ckubectl logs <pod-name>
Dkubectl describe pod <pod-name>
Attempts:
2 left
💡 Hint

Look for events and resource usage details in pod descriptions.

🔀 Workflow
expert
2:30remaining
Optimizing CPU Requests and Limits for a Production Pod

You want to optimize CPU resource settings for a production pod that sometimes spikes in CPU usage but should not be throttled during spikes. Which approach is best?

ASet CPU request to maximum spike and no CPU limit.
BSet CPU request and limit both to the maximum expected spike.
CSet CPU request to average usage and CPU limit to maximum expected spike.
DSet CPU request to zero and CPU limit to maximum spike.
Attempts:
2 left
💡 Hint

Think about balancing guaranteed resources and allowing burst capacity.