Setting Kubernetes CPU and memory requests and limits

Set Kubernetes CPU and memory requests and limits so the scheduler places pods correctly and nodes stay stable, with QoS, throttling, OOM and VPA guidance for self-managed clusters.

On this page

Setting Kubernetes CPU and memory requests and limits for stable nodes

Requests and limits tell Kubernetes how much CPU and memory a container needs and how much it may use. The request is what the scheduler reserves on a node when it places the pod, and the limit is the ceiling the kubelet enforces at runtime. If your pods are being OOM killed, throttled or evicted, or your nodes look full while showing little real use, the values in resources.requests and resources.limits are the first place to check. The scheduler only sums requests, so a node can be declared full while its actual CPU and memory use is low, and kubelet only acts on limits and on node pressure signals.

The scheduler places a pod on a node where the remaining allocatable capacity covers the sum of its container requests. Setting requests too low lets too many pods land on one node, which increases node pressure once workloads grow. Setting them too high wastes capacity and pushes you toward scaling out too early. For CPU, a limit is enforced through throttling, so a container at its limit slows down without being killed. For memory, a container that exceeds its limit is terminated by the kernel with an OOM kill, and kubelet restarts it according to the pod's restart policy. Whether a pod is evicted under node pressure depends on its QoS class, which is set by how requests and limits are declared together.

Run a right-sizing pass before adding nodes when pods show repeated restarts with OOM kill reasons, when CPU throttling appears in metrics for latency-sensitive services, or when the cluster reports full nodes with low utilization. Collect usage data over a period that includes peak load, then compare it with requests and limits in your monitoring stack. The Vertical Pod Autoscaler can produce recommendations in an advisory mode before you let it change workloads. Confirm with your platform and application owners how the VPA's update mode interacts with your deployment process and disruption budgets, and confirm the VPA version you plan to run is compatible with your cluster version.

Which request and limit pattern fits each workload

This table compares four common ways to set CPU and memory requests and limits, with the stability and throttling trade-off of each and the workload types it suits. Read each row as a starting point, then confirm the choice against measured usage for your own services.

PatternStability and throttling trade-offWorkload type it suits
Requests only, no limitsPods are scheduled on their requests but can use spare node capacity. Throttling is avoided, but a busy neighbor can push memory use high enough that the kubelet evicts pods under node pressure.Services with uneven load on shared nodes where the team accepts some eviction risk and monitors node memory closely
Requests equal to limits (Guaranteed)Pods get a Guaranteed QoS class and are the last to be evicted under node pressure. CPU is capped at the limit, so bursts can be throttled even when the node is idle.Latency-sensitive services with steady demand, and workloads where predictable behavior matters more than efficient packing
CPU limit omitted, memory limit setCPU can burst into idle capacity without throttling, and memory is capped so a leak cannot take down the node. Memory limits still cause OOM kills when a container exceeds them.Latency-sensitive APIs and web services that need burst headroom, provided the memory limit is sized from observed peak usage
Burstable (requests below limits)Pods are scheduled on a smaller footprint and can use more when capacity is free. They are evicted before Guaranteed pods, and tight limits can still cause CPU throttling under load.General-purpose services and batch jobs that tolerate variable performance and can be restarted or rescheduled
System daemons and node agentsThese need reserved resources so they keep running when workloads are busy. Setting low requests or tight limits can starve logging, monitoring or networking agents.DaemonSets such as log shippers, CNI agents and monitoring exporters, sized with the node reservation settings in mind

What Guaranteed, Burstable and BestEffort QoS mean for eviction

Kubernetes assigns every pod a Quality of Service class from its CPU and memory requests and limits. That class decides how the kubelet ranks pods when a node runs short of memory, so the requests and limits you set determine which workloads survive pressure and which go first.

Guaranteed pods

A pod is Guaranteed when every container sets memory and CPU limits equal to its requests, and every container has both values set. Guaranteed pods are the last candidates for eviction under node pressure. Use this class for latency-sensitive or stateful workloads such as databases, where a sudden eviction costs more than the reserved capacity. Check that the reserved amounts still fit your node sizes, because each Guaranteed pod holds its full request whether or not it uses it.

Burstable pods

A pod is Burstable when it sets at least one request or limit but does not meet the Guaranteed rule, for example a memory request lower than its limit. Burstable pods can use spare capacity above their requests, which suits most web services and batch jobs. Under pressure the kubelet evicts them after BestEffort pods, and it chooses among Burstable pods by how far each exceeds its requests. Confirm which of your pods are Burstable before you rely on them for critical work.

BestEffort pods

A pod is BestEffort when no container sets any CPU or memory request or limit. The scheduler places these pods without reserving capacity, and the kubelet evicts them first when a node runs out of memory. BestEffort suits disposable work such as test jobs or local experiments. Audit namespaces for BestEffort pods, because a missing value often means a chart default was never reviewed rather than a deliberate choice.

Why the class is set at creation

The QoS class is computed from the pod spec when the pod is created and does not change while the pod runs. Changing a Deployment's requests or limits creates new pods with a new class, and existing pods keep the old one until they are replaced. Review the class of running pods after a resource change, and plan rollouts so the workloads you need protected are replaced in a controlled order.

Linking the choice to eviction thresholds

QoS only sets the order of eviction, while the timing depends on the kubelet's memory, disk and inode thresholds and on reserved system resources. The node-pressure eviction topic in this group covers those signals and grace periods. Read it alongside this section so that your class choices and node settings are designed together, and confirm the thresholds on your own nodes before assuming when eviction starts.

How to set and verify requests and limits in your cluster

This sequence turns observed usage into requests, deliberate memory limits and namespace guardrails, then confirms with metrics and events that nodes stay stable under load.

  1. Confirm metrics collection is working

    The platform team confirms that metrics-server or the monitoring stack (for example Prometheus) returns CPU and memory figures for every namespace that will be sized. Run kubectl top pods -n <namespace> and kubectl top nodes against a few workloads. Done means each target workload returns current values and the node totals look plausible for the hardware. Without this, every later number is a guess.

  2. Collect usage over a representative period

    The application owners and platform team gather CPU and memory usage across a window that includes normal peaks, batch jobs and at least one scheduled high-load event, not just an idle snapshot. Use your monitoring stack to record p95 or peak values per container, not averages alone. Done means you have a per-container table of typical and peak usage that the owners have reviewed. Confirm the window length with the application team, since it depends on their traffic cycle.

  3. Set initial requests from observed baselines

    Set each container's CPU and memory requests near its typical sustained usage, since the scheduler places pods using requests and nodes are sized against the sum of requests. Leave headroom for normal variation but avoid copying peak values into every request, which wastes node capacity. Check the result with kubectl describe node <node> and review the Allocated resources section to see how much each node has committed. Done means the requests are written in manifests or Helm values and the committed totals fit the planned node pool.

  4. Set memory limits deliberately

    The application owners and platform team decide whether each container gets a memory limit, and at what level, based on the application's known peak memory and what the node can tolerate. A memory limit above what the container actually needs can let one workload push neighbors into OOM kills, while a limit below peak usage causes the kernel to terminate the container. Record the reasoning for each limit. CPU limits are a separate decision because they cause throttling, so review them with the throughput needs of the service. Done means each limit has an owner and a stated reason.

  5. Add LimitRange defaults and ResourceQuota per namespace

    The platform team adds a LimitRange so containers without explicit values receive sensible defaults and bounds, and a ResourceQuota so each namespace cannot claim more than its allocation. Apply both with kubectl apply, then create a test pod without resource fields to confirm the defaults are injected. Run kubectl describe resourcequota -n <namespace> to see used versus hard values. Done means a pod without explicit settings picks up the defaults and the quota shows the expected hard limits.

  6. Roll out and watch for pressure signals

    Deploy the changed workloads in the usual release order, ideally one namespace at a time so that any regression stays contained. Watch for pods stuck in Pending, which indicates the scheduler cannot find room for the requests. Run kubectl get events --sort-by=.lastTimestamp and check for FailedScheduling messages. Done means all target pods are Running and Ready and no scheduling failures remain.

  7. Verify throttling, OOM events and scheduling pressure

    After a full usage cycle, check the signals that show whether the settings hold. Use kubectl describe pod to read the Last State reason for OOMKilled containers and the restart count. In Prometheus, review the container_cpu_cfs_throttled_periods_total and container_cpu_cfs_periods_total counters to measure throttling, and check node memory and CPU against requests. Done means there are no unexplained OOMKilled restarts, throttling is within the level the application owners accept, and the node commitments are documented for the next review.

How requests, limits and enforcement connect

The path starts in the pod spec, where requests and limits are declared per container. The scheduler reads only the requests when it picks a node, so requests decide placement. On the chosen node, the kubelet translates the limits into cgroup settings: CPU limits throttle the container's processing time, while memory limits are enforced by the kernel, which can terminate a container with an OOM kill. When a node runs short of memory, the kubelet may evict pods, and the QoS class decides the order. Check each hand-off with kubectl describe pod and node events.

Requests drive placement, while the kubelet and kernel enforce limits on the node.

When the Vertical Pod Autoscaler helps and when it does not

The Vertical Pod Autoscaler (VPA) watches a workload's actual CPU and memory use and recommends new requests values, and in its active modes it applies them. It does not tune limits the way you might expect, and it is not part of a default Kubernetes installation. You install it as a separate add-on from the autoscaler project, with its own components and its own upgrade cycle. Before you plan around it, confirm which VPA release your cluster can run, check that release against your Kubernetes version, and confirm whether your platform team is willing to operate another controller. Those checks belong in your environment, not in a generic compatibility table.

The most useful starting mode is recommendation-only, where VPA publishes suggested requests in its status and changes nothing in running pods. You can compare those suggestions with metrics from your monitoring stack, then set requests in your Deployment manifests through your normal review process. Applying modes change pod specs, and in the versions you are likely to run, applying a new request generally means evicting and recreating the pod. Confirm that behavior, and how it interacts with your PodDisruptionBudgets and replica counts, before enabling any mode that writes to running workloads. Stateful services and single-replica workloads deserve particular caution.

VPA and the Horizontal Pod Autoscaler (HPA) should not both scale the same workload on CPU or memory. HPA changes replica counts based on utilization relative to requests, while VPA changes the requests themselves, so the two signals chase each other. A common pattern is to let HPA scale on a custom or external metric such as request rate, and let VPA right-size the per-pod requests. Confirm this split in your own environment and test it under load before production. Workloads that have not yet shown a stable usage pattern are usually poor candidates for automated changes, and a recommendation-only run over a representative period is a safer first step.

Operational risks of getting requests and limits wrong

Requests and limits affect more than one workload. They decide how many pods a node accepts, how far one team's workload can crowd another, and who is accountable when a pod is killed. The cards below cover the operational risks and the admission and access controls that keep them contained.

Overcommitted nodes

Requests drive scheduling, but limits can add up to far more than a node's allocatable capacity. When many pods burst at once, the kubelet may evict pods or the node may become unresponsive. Check the sum of requests and limits per node against allocatable capacity, and watch for nodes where requests look safe but actual usage is close to the node's capacity during peak hours.

Pod Security Standards

Noisy neighbors in shared namespaces

When several teams share a namespace without requests on their pods, one team's batch job can take most of the CPU and memory that other workloads expect. The effect appears as latency and restarts in services that did not change. Confirm which namespaces host more than one team, and whether each workload sets requests that reflect its real usage.

Runaway memory without limits

A container with no memory limit can keep allocating until the node itself runs out of memory. The kernel then selects processes to kill, which may not be the workload that caused the problem. Review workloads that have no memory limit set, especially long-running services and jobs with unbounded input, and decide deliberately which ones may go without a limit.

Who can change resource settings

Anyone allowed to edit a Deployment can lower a memory limit or remove a request, and the change takes effect on the next rollout. Use RBAC to decide which roles can update workload specs in each namespace, and review audit logs for changes to resource fields in production. Treat changes to resource settings as reviewable changes, not routine edits.

LimitRange as a default guardrail

A LimitRange sets default requests and limits for containers in a namespace and can enforce minimum and maximum values. It protects the scheduler when a team forgets to set values. Decide the defaults with the platform team, and confirm how existing workloads behave when a new LimitRange is applied, since defaults apply only at admission time.

ResourceQuota as a namespace ceiling

A ResourceQuota caps the total requests and limits a namespace may consume, so one team cannot take the whole cluster. Quotas on CPU and memory require that pods set those values, which is why quotas and LimitRange are usually designed together. Confirm the quota for each namespace against capacity planning, and alert before a namespace reaches its ceiling.

Questions teams ask before setting requests and limits

What drives the cost of a requests and limits engagement?

The main drivers are the number of workloads in scope, how mature the metrics stack is, how strict your change control is, and whether your team has the time to review recommendations. A cluster with a few dozen services that already exports CPU and memory history to a dashboard usually costs less to tune than one with hundreds of workloads, no long-term metrics and a formal approval step for every change. Cost is a one-time pass plus any retainer you add for ongoing review. Ask any quote to separate the discovery work, the per-workload tuning, the rollout and the verification, and to state which of these recur.

How long does a right-sizing pass take?

The duration depends mostly on how much usage history exists. Without at least several weeks of CPU and memory data covering normal and peak periods, the first pass can only set conservative starting values and must be revisited after real traffic arrives. With a full history that includes month-end jobs, releases and seasonal peaks, the analysis is faster but the review with workload owners takes longer. Ask for the timeline to be tied to the data available on day one and to a defined observation window after changes are applied. No duration is given here because the figure depends on your environment and is best confirmed in a written scope.

What do you need from our team before the work starts?

You need read access to the metrics system that holds container CPU and memory history, such as Prometheus or your existing monitoring platform, along with access to the cluster through kubectl with permission to read workload specs. You also need named workload owners who can confirm expected peak behavior, a list of latency-sensitive and batch services, and a change window in which requests and limits can be applied and watched. Agree in advance who approves each change and how a rollback is triggered. Missing owners are the most common cause of delay, because tuning a limit without knowing the business peak is guesswork.

Can our internal platform team do requests and limits tuning alone?

Yes, a capable platform team can do this without a partner, especially for a small cluster with good metrics and few workloads. The work requires understanding how the scheduler uses requests, how CPU throttling and memory limits behave, and how QoS classes affect eviction. The harder part is coordinating with application owners and repeating the review as code changes. Ask yourself whether the team has spare capacity for several review cycles, a way to test changes outside production, and someone who will own the settings after handover. If any of those is missing, a fixed-scope engagement that ends with documented values and a review process is often the faster route.

Why do pods get OOM killed when memory looks fine on the dashboard?

Dashboards often show averages, while the kernel reacts to the peak inside the container's memory limit. A pod can run well at a typical load and still be killed with an OOM event when a short burst, a garbage collection cycle or a large batch pushes it over the limit. Check the last termination reason on the pod, compare the limit with the maximum working set over the period rather than the average, and confirm whether the container is the one killed or the node ran out of memory. Setting a memory limit well above observed peaks, or none, changes the failure mode and should be a deliberate decision.

Should every workload have CPU limits, or only memory limits?

There is no single rule that fits every workload, and the answer depends on what you are protecting. CPU limits cap usage and can cause throttling even when the node has idle capacity, which hurts latency-sensitive services. Memory limits protect neighbors from a runaway process but cause restarts when exceeded. Common choices are to set memory limits on most workloads, set CPU requests everywhere so scheduling is fair, and apply CPU limits only where a noisy neighbor is a real problem. Document the decision per namespace so reviewers can see why a workload is treated differently.

Is the Vertical Pod Autoscaler safe to run in production?

The Vertical Pod Autoscaler can recommend requests from observed usage, and some modes can apply them, but applying changes restarts pods and must be planned like any other rollout. Start in recommendation-only mode, compare its output with your own analysis of peak usage, and confirm it respects PodDisruptionBudgets and your change windows before enabling automatic updates. Check the version and installation method against your Kubernetes release, since autoscaler components are installed separately from the control plane. Ask a quote to include how autoscaler recommendations will be reviewed, not just installed.

What is recurring after the first pass?

The first pass is one-time, but the settings drift as code, traffic and dependencies change. Recurring work includes reviewing new workloads before they reach production, watching for throttling and OOM events, re-running right-sizing after major releases, and keeping the metrics retention long enough to show peaks. Ongoing support can be handled by your team or by a retainer. Ask for a written handover that names the dashboards, alert rules and review cadence, so the settings remain owned after the engagement ends.

How DeployOpen scopes and delivers resource tuning

DeployOpen plans and implements Kubernetes resource settings inside clusters you control, starting from your workloads and node capacity rather than generic defaults. Each engagement is fixed-scope, with the findings, changes and evidence agreed in writing before work starts.

How we scope

  • Inventory the namespaces, workloads and node pools whose CPU and memory settings will be reviewed and changed.
  • Agree in writing which QoS targets, LimitRange and ResourceQuota defaults, and VPA modes are in or out of scope.
  • Confirm which metrics sources, dashboards and historical data windows are available from your monitoring stack before tuning starts.

How we build

  • Compare observed CPU and memory usage with current requests and limits to find throttling, OOM kills and over-reserved capacity.
  • Draft request and limit values per workload, then test them in a non-production namespace or cluster you designate.
  • Configure the Vertical Pod Autoscaler in recommendation mode first, and review its suggestions before any automated updates are enabled.

How we hand over

  • Deliver a written record of each changed workload with its old values, new values, rationale and rollback steps.
  • Document the QoS class each critical workload ends up in, and how that class affects eviction under node pressure.
  • Walk your platform and application teams through the review process so future changes follow the same method.

How we support

  • Offer ongoing support, periodic right-sizing reviews and alert tuning for resource signals as a retainer, if you want it.
  • Retest workloads after Kubernetes upgrades, new releases of applications, or significant traffic changes.
  • Confirm with your team who owns request and limit decisions after handover, so changes are reviewed rather than applied ad hoc.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.