Skip to main content

Manage Autoscaling and HPA

"Autoscaling" is a term with many definitions. When we talk about autoscaling at Codiac, we are referring to one of two different types:

  1. Vertical node autoscaling
  2. Horizontal pod autoscaling (HPA)

Vertical Node Autoscaling

You set up vertical node autoscaling when you create your cluster. During the cluster creation process you specify how many nodes you want the cluster to have.

If one of the nodes stops working or becomes unreachable, Kubernetes automatically spins up a new node.

Vertical autoscaling is a simple and effective way to handle basic failure situations. This method is responsive to dying pods. It is not responsive to more nuanced issues like traffic or workload.

Horizontal Autoscaling (HPA)

Horizontal pod autoscaling (HPA) is a powerful and flexible way to scale your infrastructure based on resource usage. HPA has two main benefits:

  1. Responsive performance: Automatically upscale in response to an increase in workloads.
  2. Cost savings: Run your cluster efficiently by automatically downscaling idle nodes.

HPA works from the memory and CPU footprint you want to maintain per service.

tip

Contact us if you are interested in setting up HPA based on custom scaling parameters.

Add HPA

HPA is a set of configurations for an asset which are scoped to a cabinet.

You must add the Limit and Request for CPU and/or memory in order to scale by these factors.

note

Autoscaling properties are inherited just like other configurations. If you set autoscaling at the environment level, it will automatically be applied to all the cabinets in that environment.

Use codiac config add to set HPA on your asset.

  1. Select the asset.
  2. For Config select footprint if it exists.
    1. If this is the first footprint entry, select create new, then select footprint.
  3. For Setting select one of the following:
    • cpuLimit
      • Maximum number of millicores allocated to the asset.
      • Values are in the format of Nm where N = number of millicores.
      • For example, enter 800m to allocate 800 millicores.
    • cpuRequest
      • Minimum number of millicores allocated to the asset.
      • Values are in the format of Nm where N = number of millicores.
      • For example, enter 100m to allocate 100 millicores.
    • memLimit
      • Maximum number of megabytes allocated to the asset.
      • Values are in the format of Nmi where N = number of megabytes.
      • For example, enter 800mi to allocate 800 megabytes.
    • memRequest
      • Maximum number of megabytes allocated to the asset.
      • Values are in the format of Nmi where N = number of megabytes.
      • For example, enter 800mi to allocate 800 megabytes.
    • scaling.min
      • The minimum number of replicas.
    • scaling.max
      • The maximum number of replicas.
    • scaling.disabled
      • Set this value to false to enable autoscaling.
      • Set this value to true to disable autoscaling.
      • Note: You can use this setting to turn autoscaling off or on in specific cabinets and to override activation in a parent environment.
    • targetValue
      • The percentage at which a new replica is triggered. This is 75% by default for both CPU and memory.
      • You can override this setting with scaling.metrics.cpu.targetValue and/or scaling.metrics.mem.targetValue.
info

Repeat this process to add each setting. When all of your autoscaling settings are correct, set scaling.disabled to false to enable autoscaling.

  1. For Scope select the cabinet you want to use.
  2. For Value in cabinet CABINET_NAME enter the value you want to specify.
  3. For Apply? enter Y to apply the new footprint entry.

Show HPA settings

Use codiac config view to view your existing HPA footprint settings.

Follow the prompts to:

  1. Select the asset.
  2. Select footprint.
  3. Select the cabinet.
bash-$ codiac config view
? Asset: codiac-example
? Config: footprint
? Cabinet: │ └─ history-test
[footprint] for main/codiac-example in cabinet: [history-test]
{
"cpuLimit": "800m",
"cpuRequest": "100m",
"memLimit": "800mi",
"memRequest": "100mi",
"scaling": {
"disabled": "true",
"max": "8",
"min": "2"
}
}

Edit HPA settings

Use codiac config add to edit your HPA settings.

  1. For Target select footprint.
  2. For Setting select the setting you want to change.
  3. For Scope select the cabinet.
  4. For Value in cabinet CABINET_NAME enter the new value.
  5. For Apply? enter Y to update the footprint entry.

Delete HPA settings

Use codiac config delete to delete an HPA setting.

  1. Select the asset.
  2. For Config select footprint.
  3. Select the setting you want to delete.
  4. Select the cabinet.

The setting is deleted.