Kubernetes autoscaling

Kubernetes autoscaling in a self-managed cluster combines pod scaling and node scaling, and each part depends on metrics, resource requests and capacity you run yourself. This page explains which mechanism fits which workload and what to plan before you configure it.

On this page

Kubernetes autoscaling: what it does and when your team needs it

Kubernetes autoscaling covers four things: the number of pod replicas a workload runs, the CPU and memory requests set on each pod, the scaling of workloads that react to queues, streams or other events, and the number of worker nodes the cluster owns. In a self-managed cluster, none of these happens by itself. Someone must choose the mechanisms, set the thresholds and decide who owns the node pool. If your team adjusts replica counts by hand, sets oversized requests to avoid throttling, or keeps spare nodes running through quiet hours, you are paying for idle capacity or absorbing spikes with delays. That is the situation where autoscaling earns its design effort.

Each mechanism answers a different question. The HorizontalPodAutoscaler adds or removes replicas when a workload's observed metrics move away from its target, and it is the usual first step for stateless services. The Vertical Pod Autoscaler add-on recommends or applies new requests values for pods that are sized wrongly, which matters most for workloads that cannot run several replicas at once. In-place pod resizing changes container resources without recreating the pod, a capability you should confirm against the Kubernetes version you run, since its behavior and support have changed across releases. KEDA suits queue-driven or event-driven workloads that should scale to zero. Node autoscaling depends on your infrastructure, because the cluster autoscaler or an equivalent must be able to create and remove machines in your cloud account, data center or hypervisor.

Before you pick a mechanism, confirm three things with your platform team. First, the metrics source: HPA scaling on CPU and memory needs the metrics pipeline installed and healthy, and custom metrics need an adapter. Second, the Kubernetes version and its support window, which you can check on the Kubernetes releases page, because autoscaling APIs and add-on compatibility move with each minor release. Third, who has authority to change node pool size and cloud budgets, because node autoscaling without that owner tends to fail in production. Document the answer for each workload class so the scaling design matches how your teams actually deploy and pay for capacity.

Which autoscaling mechanism answers which question

Kubernetes autoscaling is not one feature. Each mechanism changes a different thing: the replica count, the resource requests of a pod, the resources of a running pod, the trigger that drives replicas, or the number of nodes. Matching the mechanism to the question you are asking is the first design decision, and most production setups combine two or three of them.

Horizontal Pod Autoscaler

The HorizontalPodAutoscaler changes the replica count of a Deployment, StatefulSet or similar workload based on observed metrics such as CPU or memory utilization, or custom metrics served through the metrics APIs. It does not change how much CPU or memory each pod requests, so it works best when pods are stateless and can be added or removed without coordination. Check that every target has resource requests set, because utilization is calculated against them, and confirm which metrics adapter your cluster runs for anything beyond CPU and memory.

Operating etcd clusters

Vertical Pod Autoscaler

The Vertical Pod Autoscaler is an add-on, not part of the core cluster, that recommends or applies CPU and memory requests for pods based on observed usage. In recommendation mode it only publishes suggestions, which is a low-risk way to learn real sizing. In automatic mode it evicts pods to apply new requests, so it changes running workloads. It does not add replicas, and it should not run on the same resource metric as an HPA without a deliberate split of responsibilities.

In-place pod resizing

In-place pod resizing changes the CPU and memory requests and limits of a running pod without recreating it. It answers the question of how to adjust resources without the restart that eviction causes. It does not change the replica count, and it does not guarantee that the container avoids a restart, because the resize policy of each container decides whether it restarts. Confirm the cluster version supports the feature in the release you run, and test the resize policy on each workload before relying on it in production.

KEDA for event-driven scaling

KEDA, the Kubernetes Event-driven Autoscaling project, scales workloads on event sources such as message queues, Kafka lag, cron schedules or external metrics. Its distinguishing capability is scaling to zero when no events arrive, which the HPA alone does not do. KEDA creates and manages an HPA underneath, so it does not replace the HPA model. Check that the source credentials are stored as Secrets with least-privilege access, and plan for cold-start latency when a workload scales from zero.

Node autoscaling

Node autoscaling adds nodes when pods are pending because no node has room for them, and removes nodes that stay underused. It answers the capacity question, not the workload question, so it depends on pods already requesting resources accurately. It does not fix pods that are unschedulable because of taints, affinity rules or storage constraints. In a self-managed cluster, the mechanism needs an integration with your hypervisor, cloud API or bare-metal provisioning, and that integration is usually the largest part of the work.

Configuration options and when each fits

Stateless web services are the most common starting point for the HorizontalPodAutoscaler (HPA). The HPA adds or removes replicas of a Deployment based on observed resource use, most often CPU or memory utilization relative to each container's requests. It works well when requests are a reasonable estimate of real use and when replicas can start quickly without coordinating state. The main trade-off is that utilization percentages are only meaningful when requests are set accurately, so the autoscaler inherits every mistake in the resource settings.

  • Metrics pipeline: The HPA needs a resource metrics source running in the cluster, which is usually metrics-server. Confirm it is installed and healthy before writing any HPA objects.
  • Requests set: Every container being scaled needs CPU or memory requests, because utilization is calculated against them.
  • Replica bounds: Set a minimum and maximum replica count so a metrics gap cannot scale the service to zero or to an unbounded size.
  • Startup behavior: Slow-starting services need readiness probes and a review of scale-up delay, or new replicas will receive traffic before they can serve it.
  • Trade-off: CPU-based scaling reacts to load after it has already reached the pods, so latency can rise briefly during sudden spikes.

Before relying on this option, check that requests match measured usage over a representative period and that the minimum replica count covers the service's availability needs during node maintenance.

Setup sequence with checks

This sequence takes a self-managed cluster from unscaled workloads to tested autoscaling, with each layer added only after the layer beneath it returns usable data. Each step ends with a check so that a failure is found where it starts, not during a traffic spike.

  1. Set resource requests and limits on workloads

    Your platform and application teams set CPU and memory requests for every workload that will scale, because the HorizontalPodAutoscaler calculates utilization against requests and the scheduler places pods using them. Agree on limits separately, since a memory limit set too low causes restarts that look like scaling problems. Review the baseline values against measured usage from a representative period. Done means every targeted Deployment or StatefulSet has requests set in its pod template, and a server-side dry run of the manifests passes without warnings about missing values.

  2. Install and verify the metrics pipeline

    Install metrics-server in the cluster, then confirm that the aggregated Metrics API responds. If you plan to scale on application or queue metrics, also install the custom or external metrics adapter your team has chosen and confirm the API groups it registers. Run kubectl top nodes and kubectl top pods, then query the custom metrics API for one known metric. Done means node and pod CPU and memory values return for every namespace in scope, and the metric you plan to scale on returns a current value rather than an error.

  3. Configure the HorizontalPodAutoscaler

    Create a HorizontalPodAutoscaler for each workload that scales on CPU, memory, or a custom metric. Set minReplicas to the lowest count that still meets availability needs, and maxReplicas to a ceiling your cluster capacity and budget can absorb. Set target utilization values and, where your version supports it, scale-up and scale-down behavior policies so that replicas do not oscillate. Done means kubectl get hpa shows current metric values rather than unknown, and a controlled load test produces a scale-up event visible in kubectl describe hpa.

  4. Add KEDA or VPA where the workload needs them

    Install KEDA for event-driven scaling on queues, streams, or other external sources, including scale to zero where the workload tolerates it. Install the Vertical Pod Autoscaler add-on only in recommendation mode first, so your team can compare suggested requests against the values set in step one before any automatic changes. Avoid pointing VPA in automatic mode at the same metric that drives an HPA, because the two controllers can fight. Done means each ScaledObject or VPA object reports a status, and KEDA-driven scale events appear in the object's events when the test source changes.

  5. Define node group bounds and the cluster autoscaler

    Set minimum and maximum node counts for each node group, and install the cluster autoscaler or the equivalent provisioner your distribution supports. Check that the node groups' instance templates carry the labels and taints your workloads expect, and that the autoscaler has permission to add and remove nodes in your infrastructure. Confirm with your infrastructure team how new machines are provisioned in your environment, since this varies by hypervisor, bare metal tooling, and cloud. Done means a pending pod that cannot fit on existing nodes triggers a scale-up event on the node group, and an idle node is removed after the autoscaler's configured delay.

  6. Load test the full chain and record the results

    Run a load test that exercises the application path, then watch the chain in order: the metric rises, the HPA or KEDA object scales the workload, pods become pending when nodes are full, and the node group adds capacity. Repeat the test with the load removed to confirm scale-down and node removal. Record the observed times for each stage and any throttling, OOM kills, or failed readiness checks. Done means a written test report lists the scale-up and scale-down events for each workload, and any gap between stages has an owner and a fix before production use.

How pod and node scaling signals connect

The flow starts with workload metrics collected from pods and nodes, which feed the metrics pipeline. The HorizontalPodAutoscaler or KEDA reads that signal and changes the replica count of the Deployment. The scheduler places new pods where capacity exists, and pods it cannot place are the trigger for node autoscaling. The Vertical Pod Autoscaler or in-place resizing adjusts requests on existing pods, which changes how the scheduler packs them. Check the boundary where KEDA reads external event sources, since those signals sit outside the cluster's control.

Scaling signals flow from pod metrics to replicas, scheduling and nodes, with external events entering through KEDA.

Security and operational risks to plan for

Autoscaling widens what a cluster can do on its own: it creates pods and nodes, reads event sources and restarts workloads. The cards below cover the access, cost, disruption and version risks that connect those behaviors, and the shared controls that limit them.

Scope RBAC for autoscalers

Each autoscaler runs under a service account with RBAC permissions to read metrics and change scale targets. Bind those permissions to a dedicated service account in the namespaces it manages, not a cluster-wide role. Check which resources each autoscaler can patch, especially Deployments, StatefulSets and the scale subresource, and confirm that application teams cannot edit the autoscaler objects that govern their own workloads. Review these bindings whenever a new autoscaler is added.

Authentication docs

Protect event source credentials

Event-driven scalers such as KEDA connect to queues, databases and metrics backends using credentials. Store those credentials as Kubernetes Secrets, enable encryption at rest for etcd, and restrict list and watch access to the Secrets, since those verbs expose values to anyone who can read them. Where policy requires it, load credentials from an external store through the Secrets Store CSI Driver. Give each scaler a read-only account scoped to the single queue or metric it needs.

Secrets good practices

Cap runaway scale-out

An autoscaler without bounds can scale a workload past what the budget or the cluster can absorb. Set maxReplicas on every HorizontalPodAutoscaler and maxReplicaCount on every KEDA ScaledObject, and set node group maximums in the node autoscaler. A queue backlog or a metric spike from a bad release can then drive scale-out that consumes all node capacity and starves other namespaces. Pair these limits with ResourceQuota objects so one team's scaling cannot take the whole cluster.

Limit VPA restart disruption

The Vertical Pod Autoscaler applies new requests by evicting and recreating pods unless the workload uses in-place resizing. Each restart can interrupt in-flight requests, reset caches and briefly reduce capacity. Run the VPA in recommendation-only mode first, confirm that the workload tolerates restarts, and protect critical services with PodDisruptionBudgets. Ask the application team which workloads can accept restarts during business hours before enabling automatic updates.

Keep autoscaler versions aligned

Autoscalers depend on Kubernetes APIs and on the metrics pipeline, so their versions must match the cluster version closely. Check each autoscaler's compatibility matrix before a cluster upgrade, and upgrade the autoscaler alongside the control plane rather than after it. Test scaling behavior in a staging cluster on the target version, since a deprecated API or changed metrics endpoint can silently stop scaling. Record the version of every autoscaler in the same inventory as the cluster components.

Version skew policy

Use shared pod and audit controls

Autoscaling depends on controls the cluster already enforces. Pod Security Standards applied per namespace stop autoscaled pods from running privileged or with host access, which matters when scaling creates new pods without review. Audit logging records who changed a scale target, an autoscaler spec or a Secret, and should feed a SIEM so unexpected scale changes are visible. Confirm both controls are active in every namespace where autoscalers run.

Questions buyers ask before hiring outside help

How much effort does Kubernetes autoscaling take to set up?

Effort depends mostly on how many workloads need scaling, where their metrics come from, and how varied the infrastructure is. A cluster with a few stateless services scaled on CPU and memory is a small job. A cluster with dozens of services, custom metrics from Prometheus, event sources such as queues or streams for KEDA, and more than one node pool with different hardware takes much longer to design and test. Load testing is often the largest single driver, because each scaling rule needs to be proven under realistic traffic before it is trusted in production. Ask any partner to list the workloads, metric sources and node pools in scope before discussing effort.

Can our platform team set up autoscaling without outside help?

Yes, many teams do. HorizontalPodAutoscaler is part of core Kubernetes, and the Vertical Pod Autoscaler and KEDA are add-ons that a capable platform team can install and configure. The harder parts are usually design decisions: which signals should drive scaling, how to avoid scaling loops between pod and node autoscaling, how to set resource requests that the autoscalers can work with, and how to test scale-up and scale-down safely. If your team already runs the cluster well and has time for a load test window, it may be enough. If the platform team is stretched, an outside partner can take the design and build while your engineers keep ownership of the result.

What do we need to provide before work starts?

Plan to provide five things. First, read access to the cluster and the metrics pipeline, including the metrics server and any Prometheus instance that will feed custom metrics. Second, named workload owners who can confirm expected traffic patterns, safe minimum and maximum replica counts, and acceptable startup times. Third, a node pool design or a decision on whether node autoscaling should use your current cloud or infrastructure provider integration. Fourth, a test window in a non-production environment with load generation tools available. Fifth, a change process that allows scaling rules to be rolled out gradually. Missing any of these usually extends the timeline more than the technical work itself.

How long does an autoscaling engagement take?

Duration is set by the number of workloads in scope, the number of metric sources, the number of node pools, and how long your test window and approval cycles take. Those factors are fixed by your environment, not by the tooling. A scoped engagement usually moves in phases: discovery of workloads and metrics, design of scaling rules and node pool behavior, build and configuration, load testing, and handover. Your owners' availability for review often sets the pace. Ask for a timeline in the written scope that shows each phase, the dependencies on your team, and the testing window, rather than a single end date.

How is the cost of autoscaling work structured?

Cost has two parts. The first is one-time design and build: discovery, scaling rule design, configuration of HPA, VPA, KEDA or node autoscaling as scoped, load testing and handover documentation. The second is recurring work: upgrades when the autoscaler components or Kubernetes minor versions change, periodic tuning as traffic grows, and review of scaling behavior after incidents. The main cost drivers are the number of workloads, the variety of metric and event sources, the number of node pools and infrastructure types, and the scope of load testing. Ask any partner for a fixed-scope quote that separates the one-time work from any ongoing support or retainer, and that names what you must provide.

Which parts of autoscaling need the most ongoing care?

Plan for ongoing attention in four areas. Kubernetes releases about three times per year, and the project maintains only the three most recent minor releases, so autoscaler components and the version of the cluster must be upgraded on that schedule. Resource requests drift as applications change, which affects how HPA and VPA behave. Node autoscaling depends on cloud or infrastructure APIs that can change. Finally, traffic patterns shift, so scaling thresholds need periodic review. Ask whether a quote includes these recurring checks or whether they will be handled by your team under a separate retainer.

Does a partner need access to our production systems to configure autoscaling?

Work usually starts in non-production environments, where scaling rules can be tested without affecting users. Access to production is normally limited to what is needed to apply reviewed changes, and your change process should govern that. Partners typically need cluster-level access scoped by role, metrics read access, and access to the test environment. Agree these access levels in writing before the work starts, including who approves each production change and how access is removed at handover. Your security team should review the access model as part of the scope.

Official Kubernetes sources to read first

Start with the official Kubernetes documentation and the kubernetes/kubernetes repository before you install any autoscaling component. The HorizontalPodAutoscaler is part of the core API, so its behavior, fields and API version are documented with the rest of the workload APIs. The Vertical Pod Autoscaler is maintained as an add-on, and its release notes, install manifests and known limitations live in its own project repository, so confirm which version you are deploying against the Kubernetes version your cluster runs. Also check whether in-place pod resizing is enabled in your cluster version and whether your team's workloads depend on it, because the feature gate status and API behavior differ across releases. Keep a short written list of the exact documentation pages and repository tags your team used for the build, so that upgrades later start from the same references.

Check the Kubernetes version skew policy before installing any autoscaler. The policy sets which component versions can coexist, and autoscalers depend on the API server, controller manager and kubelets reporting consistent metrics and objects. Confirm that your kube-apiserver version is supported by the autoscaler release you plan to install, and that the metrics pipeline you choose is compatible with both. Record which Kubernetes minor versions are currently supported in the Kubernetes releases page, and plan your autoscaler upgrades alongside cluster upgrades rather than after them. Ask your installer or partner to show the version matrix they tested against, and ask them to name the component version that will be pinned in your configuration management.

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.