In Kubernetes, what happens when a container exceeds its CPU request but stays below its CPU limit?
Think about how Kubernetes manages guaranteed CPU resources versus maximum allowed CPU.
CPU requests define the guaranteed CPU for a container. If the container uses more CPU than requested but less than the limit, Kubernetes allows it but may throttle it to not exceed the limit.
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"CPU limits set the maximum CPU a container can use.
The CPU limit of 1 CPU means the container cannot use more than 1 CPU. If it tries to use 2 CPUs, Kubernetes throttles it to 1 CPU.
Which of the following Kubernetes container resource configurations correctly sets a CPU request of 250m and a CPU limit of 500m?
CPU values in Kubernetes are usually specified in millicores with 'm' suffix.
CPU requests and limits should be specified as strings with units. "250m" means 250 millicores (0.25 CPU). Options A and D lack units and are invalid. Option A uses decimal notation which is valid but less common; however, Kubernetes expects strings for resource quantities.
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?
Look for events and resource usage details in pod descriptions.
The kubectl describe pod command shows detailed pod info including events and resource usage, which can indicate CPU throttling. Other commands do not provide this info directly.
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?
Think about balancing guaranteed resources and allowing burst capacity.
Setting CPU request to average usage guarantees baseline CPU. Setting limit to max spike allows bursting without throttling. Setting request and limit equal wastes resources. No limit risks node stability. Zero request risks eviction.