<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Theojermass</title>
    <description>The latest articles on DEV Community by Theojermass (@jeriel8mass).</description>
    <link>https://dev.to/jeriel8mass</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3882007%2Fbf74a5d1-f09f-424c-97c8-c1389241fcd5.png</url>
      <title>DEV Community: Theojermass</title>
      <link>https://dev.to/jeriel8mass</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeriel8mass"/>
    <language>en</language>
    <item>
      <title>Autoscaling in Kubernetes</title>
      <dc:creator>Theojermass</dc:creator>
      <pubDate>Mon, 14 Sep 2026 13:40:23 +0000</pubDate>
      <link>https://dev.to/jeriel8mass/autoscaling-in-kubernetes-j69</link>
      <guid>https://dev.to/jeriel8mass/autoscaling-in-kubernetes-j69</guid>
      <description>&lt;p&gt;In practice, an elastic system starts with a minimal resource allocation so it can handle requests under normal load conditions.&lt;/p&gt;

&lt;p&gt;Over time, certain situations can arise (for example, seasonality in user demand, sudden massive spikes, etc.) where the system's resources tend to become saturated due to a sudden increase in incoming requests.&lt;/p&gt;

&lt;p&gt;In this situation, an elastic system expands its capacity by allocating additional resources from the Cloud to avoid service interruption or performance degradation.&lt;/p&gt;

&lt;p&gt;When the request rate drops from its peak back to normal, some system resources remain underutilized. In this case, the system reduces its capacity by releasing some resources back to the Cloud, thus no longer paying for idle usage.&lt;/p&gt;

&lt;p&gt;This is how an elastic system meets its performance criteria at minimal cost, in response to workload fluctuations.&lt;/p&gt;




&lt;p&gt;Kubernetes implements this mechanism through &lt;strong&gt;three complementary components&lt;/strong&gt;, each acting at a different level:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Horizontal Pod Autoscaler (HPA): minimal allocation and adapting to load
&lt;/h3&gt;

&lt;p&gt;In Kubernetes, a HorizontalPodAutoscaler (HPA) automatically updates a workload resource (such as a Deployment or a StatefulSet) to automatically adjust capacity to meet demand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Horizontal scaling&lt;/strong&gt; means that the response to increased load is to &lt;strong&gt;deploy more Pods&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If the load decreases and the number of Pods is above the configured minimum, the HorizontalPodAutoscaler tells the workload resource (the Deployment, the StatefulSet, or any other similar resource) to scale back down.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This is called scaling out and scaling in!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;⚠️ Horizontal Pod autoscaling does not apply to objects that cannot be scaled (for example: a DaemonSet).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3lu4hf6udipqw0qiylle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3lu4hf6udipqw0qiylle.png" alt="The HorizontalPodAutoscaler controls the scale of a Deployment and its ReplicaSet" width="551" height="352"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Vertical Pod Autoscaler (VPA): complementary adjustment
&lt;/h3&gt;

&lt;p&gt;A VerticalPodAutoscaler (VPA) automatically updates a workload management resource (such as a Deployment or a StatefulSet) to automatically adjust the &lt;strong&gt;infrastructure resource requests and limits&lt;/strong&gt; to match actual usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vertical scaling&lt;/strong&gt; means that the response to increased resource demand is to allocate more resources (for example: memory or CPU) to the Pods already running the workload.&lt;/p&gt;

&lt;p&gt;This is also known as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"&lt;strong&gt;rightsizing&lt;/strong&gt;"&lt;/li&gt;
&lt;li&gt;or sometimes "&lt;strong&gt;autopilot&lt;/strong&gt;"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This differs from horizontal scaling, which in Kubernetes would mean deploying more Pods to spread the load.&lt;/p&gt;

&lt;p&gt;If resource usage decreases and the Pods' resource requests are above optimal levels, the VerticalPodAutoscaler tells the workload resource to &lt;strong&gt;reduce the resource requests&lt;/strong&gt;, thus avoiding waste.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This is called scaling up and scaling down!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faxgupdxblnnskic2qxvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faxgupdxblnnskic2qxvd.png" alt="VPA scaling" width="733" height="298"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Cluster Autoscaler (CA): actual Cloud resource allocation
&lt;/h3&gt;

&lt;p&gt;The Cluster Autoscaler is a tool that automatically adjusts the &lt;strong&gt;size of the Kubernetes cluster&lt;/strong&gt; when one of the following conditions is met:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pods could not be scheduled in the cluster due to insufficient resources.&lt;/li&gt;
&lt;li&gt;Some nodes in the cluster have been underutilized for an extended period and their Pods can be moved to other existing nodes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main goal of the Cluster Autoscaler is to provide a place for &lt;em&gt;pending&lt;/em&gt; Pods to run. It periodically checks for pending Pods and increases the size of the cluster if appropriate and if the scaled cluster remains within user-defined limits.&lt;/p&gt;

&lt;p&gt;The provisioning time of new nodes does not depend on the Cluster Autoscaler itself, but rather on the &lt;strong&gt;cloud provider&lt;/strong&gt; and other Kubernetes components.&lt;/p&gt;

&lt;p&gt;It is now widely treated as a standard autoscaling component by Cloud providers, which often integrate it natively into their offerings (&lt;strong&gt;EKS, GKE, AKS&lt;/strong&gt;).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 &lt;strong&gt;NB:&lt;/strong&gt; There are also other tools for scaling on application-specific metrics, beyond the native CPU/memory-based HPA. Indeed, the cluster can remain idle while requests time out, if the monitored metric (e.g. CPU) is not the real bottleneck (e.g. memory, database connections, message queues, etc.)&lt;/p&gt;

&lt;p&gt;Among these other tools are &lt;strong&gt;Prometheus Adapter&lt;/strong&gt;, &lt;strong&gt;KEDA&lt;/strong&gt;, and &lt;strong&gt;Datadog Kubernetes Autoscaling (DKA)&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The power of the AWS ecosystem with Amazon EKS
&lt;/h2&gt;

&lt;p&gt;Setting up a &lt;em&gt;cluster autoscaler&lt;/em&gt; without the help of a Cloud provider is complex. Indeed, if your physical servers have reached their limits, you can't "conjure up" RAM in two minutes. Moreover, it is often very difficult to tie the &lt;em&gt;cluster autoscaler&lt;/em&gt; to the physical hypervisor if you want to build an &lt;em&gt;on-premise&lt;/em&gt; Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;However, as mentioned above, the cluster autoscaler integrates well with public cloud providers. We'll focus on AWS and its managed EKS solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So what is EKS's competitive advantage at the infrastructure layer?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On AWS, the Cluster Autoscaler uses &lt;strong&gt;Amazon EC2 Auto Scaling Groups&lt;/strong&gt; to manage node groups. The Cluster Autoscaler typically runs as a Deployment in your cluster.&lt;/p&gt;

&lt;p&gt;The Cluster Autoscaler therefore acts as the &lt;strong&gt;bridge&lt;/strong&gt; between the state of the Kubernetes cluster (pending pods, underutilized nodes) and the AWS API that actually drives the EC2 instances (the ASG).&lt;/p&gt;

&lt;h3&gt;
  
  
  The two main loops of the Cluster Autoscaler on EKS
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Loop&lt;/th&gt;
&lt;th&gt;Frequency&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scale-Up&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Every 10 seconds&lt;/td&gt;
&lt;td&gt;Identifies unschedulable pending Pods. Simulates scheduling and, if necessary, increases the DesiredCapacity of the Auto Scaling group to trigger the launch of new instances. The Autoscaler selects a node group via the configured &lt;em&gt;expander&lt;/em&gt; strategy.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scale-Down&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Continuous&lt;/td&gt;
&lt;td&gt;Looks for underutilized nodes. If the Pods can be rescheduled safely, it &lt;em&gt;drains&lt;/em&gt; the node and reduces the DesiredCapacity to terminate the instance.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft3rm9k18y1wcroell259.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft3rm9k18y1wcroell259.png" alt="Cluster Autoscaler in AWS" width="690" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flow diagram:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Pod is in &lt;em&gt;pending&lt;/em&gt; state due to insufficient resources.&lt;/li&gt;
&lt;li&gt;The Kubernetes Cluster Autoscaler increases the desired number of instances in an Auto Scaling Group.&lt;/li&gt;
&lt;li&gt;AWS Auto Scaling provisions a new node.&lt;/li&gt;
&lt;li&gt;The Pod is scheduled on the new node.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The major drawbacks of the Cluster Autoscaler (CA)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Slow provisioning&lt;/strong&gt;: it can take up to &lt;strong&gt;10 minutes&lt;/strong&gt; to add a node.

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Why?&lt;/em&gt; The CA has to query several APIs in cascade: Auto Scaling Group API → EC2 API.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rigid configuration&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Requires the prior creation of "Managed Node Groups" or "Auto Scaling Groups".&lt;/li&gt;
&lt;li&gt;Each group must contain instances of a fixed type. For GPU, CPU-optimized, or high-memory instances, you must create a specific group for each type.&lt;/li&gt;
&lt;li&gt;If a workload requires a resource type that isn't configured in an existing group, the CA won't be able to scale.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operational complexity&lt;/strong&gt;: a lot of maintenance to manage the different node groups.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Karpenter revolution
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Karpenter&lt;/strong&gt; is an open-source project originally developed by Amazon to solve the problems described above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key advantages of Karpenter
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed&lt;/strong&gt;: it communicates directly with the cloud provider's API (e.g. EC2 on AWS), without going through intermediate layers (Node Groups / Auto Scaling Groups). Provisioning is much faster.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility (Right-sizing)&lt;/strong&gt;: instead of launching predefined instances, Karpenter analyzes the exact needs of the pending Pods and launches the most suitable instance (cheapest, just enough CPU/RAM).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consolidation&lt;/strong&gt;: Karpenter can consolidate workloads onto fewer nodes to reduce costs and avoid underutilized nodes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Cloud support&lt;/strong&gt;: AWS (native), Azure, Alibaba Cloud, and any provider supporting the &lt;em&gt;Cluster API&lt;/em&gt; (&lt;em&gt;Cluster API Provider&lt;/em&gt;).

&lt;ul&gt;
&lt;li&gt;Note: GKE has its own native solution, so Karpenter is not a priority for Google Cloud.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How Karpenter works technically
&lt;/h3&gt;

&lt;p&gt;Karpenter is installed via &lt;strong&gt;Helm&lt;/strong&gt; and deploys several &lt;strong&gt;CRDs&lt;/strong&gt; (Custom Resource Definitions).&lt;/p&gt;

&lt;h4&gt;
  
  
  a. The main CRDs
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;1. NodeClass (cloud-specific)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Defines how to interact with the provider (e.g. EC2NodeClass for AWS, AKSNodeClass for Azure).&lt;/li&gt;
&lt;li&gt;Configures low-level parameters: OS type, tags, security, Pod limits per node, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. NodePool (the key resource)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Defines &lt;strong&gt;needs&lt;/strong&gt; rather than fixed instance types.&lt;/li&gt;
&lt;li&gt;Examples of possible constraints: "I want between 2 and 10 vCPUs", "arm64 or amd64 architecture", "eu-west-1 zone", "Spot or On-Demand".&lt;/li&gt;
&lt;li&gt;Karpenter automatically picks the best instance type matching those criteria.&lt;/li&gt;
&lt;li&gt;Allows automatically adding &lt;em&gt;Taints&lt;/em&gt; and &lt;em&gt;Labels&lt;/em&gt; to new nodes.&lt;/li&gt;
&lt;li&gt;Manages node &lt;strong&gt;expiration&lt;/strong&gt; (to regularly renew instances and avoid configuration drift).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. NodeClaim (managed automatically)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Created and deleted dynamically by Karpenter.&lt;/li&gt;
&lt;li&gt;Represents a &lt;strong&gt;concrete request&lt;/strong&gt; for a node.&lt;/li&gt;
&lt;li&gt;Serves as a historical record to understand why a node was created or deleted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  b. The lifecycle
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;A Pod is in the &lt;strong&gt;"Pending"&lt;/strong&gt; state.&lt;/li&gt;
&lt;li&gt;Karpenter evaluates the needs and creates a NodeClaim.&lt;/li&gt;
&lt;li&gt;It calls the Cloud API to provision the instance.&lt;/li&gt;
&lt;li&gt;Once the node is ready, it updates the NodeClaim and schedules the Pods onto it.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Level of action&lt;/th&gt;
&lt;th&gt;Addresses&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;HPA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Number of Pods&lt;/td&gt;
&lt;td&gt;Application load (scale out/in)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VPA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Resources of a Pod&lt;/td&gt;
&lt;td&gt;Actual CPU/memory usage (scale up/down)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cluster Autoscaler&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cluster nodes&lt;/td&gt;
&lt;td&gt;Pending Pods / underutilized nodes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Karpenter&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cluster nodes (next generation)&lt;/td&gt;
&lt;td&gt;Precise Pod needs, without Node Groups&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Kubernetes autoscaling therefore relies on a combination of complementary mechanisms ( application-level (HPA/VPA) and infrastructure-level {Cluster Autoscaler or Karpenter} ) to guarantee performance and cost control in the face of load variations.&lt;/p&gt;




&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/kubernetes/autoscaler/blob/" rel="noopener noreferrer"&gt;https://github.com/kubernetes/autoscaler/blob/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/docs/concepts/workloads/autoscaling/" rel="noopener noreferrer"&gt;https://kubernetes.io/docs/concepts/workloads/autoscaling/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/autoscaling.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/eks/latest/userguide/autoscaling.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/autoscaling.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/eks/latest/userguide/autoscaling.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://karpenter.sh/docs/getting-started/" rel="noopener noreferrer"&gt;https://karpenter.sh/docs/getting-started/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=THj__UYiq90" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=THj__UYiq90&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kubernetes</category>
      <category>karpenter</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
