Autoscaling in Kubernetes

Autoscale your DuploCloud Kubernetes deployment


Before autoscaling can be configured for your Kubernetes service, make sure that:
  1. 1.
    Autoscaling Group (ASG) is setup in the DuploCloud tenant
  2. 2.
    Cluster Autoscaler is enabled for your DuploCloud infrastructure

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 a Deployment Service from the DuploCloud Portal.
  1. 1.
    In the DuploCloud Portal, navigate Kubernetes -> Services, displaying the Services page.
  2. 2.
    Create a new Service by clicking Add.
  3. 3.
    In Add Service - Basic Options, from the Replication Strategy list box, select Horizontal Pod Scheduler.
    Basic Options on the Add Service page, with Replication Strategy list box and Horizontal Pod Autoscaler Config fields
  4. 4.
    In the Horizontal Pod Autoscaler Config field, add a sample configuration, as shown below. Update the minimum/maximum Replica Count in the resource attributes, based on your requirements.
    Horizontal Pod Autoscaler Config field in Basic Options, on the Add Service page
  5. 5.
    Click Next to navigate to Advanced Options.
  6. 6.
    In Advanced Options, in the Other Container Config field, ensure your resource attributes, such as Limits and Requests, are set to work with your HPA configuration, as in the example below.
    Other Container Config field in Advanced Options on the Add Service page
  7. 7.
    At the bottom of the Advanced Options page, click Create.
For HPA Configures Services, Replica is set as Auto in the DuploCloud Portal
When your services are running, Replicas: Auto is displayed on the Service page.
Service page with Replicas: Auto and Status: Running displayed

Stopping a running Kubernetes service that is using an HPA

If a Kubernetes Service is running with a Horizontal Pod AutoScaler (HPA), you cannot stop the Service by clicking Stop in the service's Actions menu in the DuploCloud Portal.
Instead, do the following to stop the service from running:
  1. 1.
    In the DuploCloud Portal, navigate to Kubernetes -> Containers and select the Service you want to stop.
  2. 2.
    From the Actions menu, select Edit.
  3. 3.
    From the Replication Strategy list box, select Static Count.
  4. 4.
    In the Replicas field, enter 0 (zero).
  5. 5.
    Click Next to navigate to the Advanced Options page.
  6. 6.
    Click Update to update the service.