# Autoscaling in Kubernetes

## Kubernetes Cluster Auto Scaler

The Kubernetes Cluster Auto Scaler automatically adjusts the number of nodes in your cluster when pods fail or are rescheduled onto other nodes.&#x20;

### Step1: Enable Cluster AutoScaler in Infrastructure

You can configure Cluster AutoCcaler for the Infrastructure created with EKS Enabled

Enable Cluster Autoscaler from **Administrator** > **Infrastructure** > **Settings**. Add Setting to enable Autoscaler. Refer screenshot

![](/files/h1MJHTCS1Vabr5w8pxq0)

### Step2: Configure Auto Scaling Group (ASG)

Navigate to **DevOps** > **Hosts** > **ASG.**  Enable **Use for Cluster Autoscaling** toggle button.

This setting allows managing the cluster auto-scaling.

<figure><img src="/files/gGJhpcDm5GcROAcQM9Pd" alt=""><figcaption></figcaption></figure>

## Kubernetes Horizontal Pod Autoscaler (HPA)

Horizontal Pod Autoscaler (HPA) automatically scales the Deployment and its ReplicaSet. HPA checks the metrics configured in regular intervals and then scales the replicas up or down accordingly.

#### Configuring Services with HPA

You can configure HPA while creating Deployment Service from DuploCloud Portal.

Navigate **DevOps** > **Containers** > **EKS/Native.**

Create a new Service. Select **Replication Strategy** as *'Horizontal Pod Scheduler'*

Add below sample configuration in the **Horizontal Pod Autoscaler Config** textarea section.  Update minimum/maximum Replica Count, resource section based on the requirement.

{% code title="Horizontal Pod Autoscaler (HPA)" %}

```
maxReplicas: 5
metrics:
  - resource:
      name: cpu
      target:
        averageUtilization: 80
        type: Utilization
    type: Resource
minReplicas: 2
```

{% endcode %}

<figure><img src="/files/4Vd6p4ej7H8uuazZ1uot" alt=""><figcaption></figcaption></figure>

For HPA Configures Services, **Replica** is set as *Auto* in DuploCloud Portal

<figure><img src="/files/NHm5OWHUQDXntjFwqAzp" alt=""><figcaption></figcaption></figure>

#### Setting Container Configuration

It is important to have the Resources set in the **Other Container Config** so that HPA can work. Below is an example:

<figure><img src="/files/6WnwWbfsc2VMp74Igz3Q" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.duplocloud.com/docs/~/changes/i1ah7lBvMELea01fsIga/azure/use-cases/autoscaling/autoscaling-in-kubernetes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
