All Products
Search
Document Center

Container Service for Kubernetes:Use CronHPA for scheduled Pod scaling

Last Updated:Apr 03, 2026

Cron Horizontal Pod Autoscaler (CronHPA) scales pods on a crontab-like schedule. Use CronHPA when your application traffic follows a predictable pattern — for example, scaling up before peak hours and scaling down overnight.

ACK offers multiple auto scaling solutions at both the scheduling layer (workload scaling) and resource layer (node scaling). Before proceeding, read Auto scaling to understand which solution fits your use case.

How it works

CronHPA is built on kubernetes-cronhpa-controller, a time-based horizontal scaling controller. At each scheduled trigger time, CronHPA sets the target workload's replica count to targetSize. After that, CronHPA takes no further action until the next scheduled trigger fires.

CronHPA is a trigger-point model, not a time-window model. It sets the replica count once at the trigger time and does not maintain that count. If another controller (such as HPA) adjusts replicas in between, CronHPA does not intervene until its next trigger fires.

CronHPA works with any Kubernetes object that supports scale subresources, such as Deployment and StatefulSet.

Prerequisites

Before you begin, ensure that you have:

Step 1: Install the CronHPA component

Install the ack-kubernetes-cronhpa-controller add-on to enable CronHPA in your cluster.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Operations > Add-ons.

  3. On the Manage Applications tab, find ack-kubernetes-cronhpa-controller, click Install, and follow the prompts to complete the installation.

Step 2: Create a CronHPA job

Before creating a CronHPA job, confirm that:

  • The ack-kubernetes-cronhpa-controller component is running normally in the cluster.

  • The target workload has at most one Horizontal Pod Autoscaler (HPA) configured.

The following sections use a Deployment as an example. The steps are similar for other workload types.

Option 1: Create a CronHPA job when creating a new application

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Workloads > Deployments.

  3. On the Deployments page, click Create from Image.

  4. Complete the Basic Information, Container, and other configuration sections. When you reach Advanced, expand the Scaling section, enable CronHPA, and configure the following parameters: For all other configuration steps and parameters, see Create a stateless application by using a Deployment.

    Parameter Description
    Job Name The name of the CronHPA job.
    Desired Number of Replicas The target replica count when the scheduled time is reached.
    Scaling Schedule The cron expression defining the trigger schedule. See Cron expression format.

Option 2: Create a CronHPA job for an existing application

Workloads page

From the Deployments page:

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Workloads > Deployments.

  3. On the Deployments page, click Details in the Actions column of the target Deployment, then click the Pod Scaling tab.

  4. In the CronHPA section, click Create and configure the following parameters:

    Parameter Description
    Job Name The name of the CronHPA job.
    Desired Number of Replicas The target replica count when the scheduled time is reached.
    Scaling Schedule The cron expression defining the trigger schedule. See Cron expression format.

    create

Workload scaling page

From the Workload Scaling page (allowlist required):

The Workload Scaling page is available only to accounts on the allowlist. To request access, submit a ticket.
  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Auto Scaling > Workload Scaling.

  3. In the upper-right corner, click Create Auto Scaling, select the target workload, and click the Horizontal Scaling tab.

  4. Select the CronHPA option and configure the following parameters:

    Parameter Description
    CronHPA Name The name of the CronHPA resource.
    Job Name The name of the CronHPA job.
    Desired Number of Replicas The target replica count when the scheduled time is reached.
    Scaling Schedule The cron expression defining the trigger schedule. See Cron expression format.

CronHPA YAML reference

CronHPA is configured as a CronHorizontalPodAutoscaler custom resource. The following example scales a Deployment down to 1 replica at 30 seconds past each hour, and up to 3 replicas at the top of each hour, skipping November 15th and every Friday.

apiVersion: autoscaling.alibabacloud.com/v1beta1
kind: CronHorizontalPodAutoscaler
metadata:
  labels:
    controller-tools.k8s.io: "1.0"
  name: cronhpa-sample
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: nginx-deployment-basic
  excludeDates:
    # Skip November 15th
    - "* * * 15 11 *"
    # Skip every Friday
    - "* * * * * 5"
  jobs:
    - name: "scale-down"
      schedule: "30 */1 * * * *"
      targetSize: 1
    - name: "scale-up"
      schedule: "0 */1 * * * *"
      targetSize: 3
      runOnce: false

Parameters

Parameter Description
scaleTargetRef The workload to scale. The target object must support scale subresources.
excludeDates A list of dates on which all jobs are skipped. Granularity is one day. Use the 6-field cron format: "<Seconds> <Minutes> <Hours> <Day of month> <Month> <Day of week>".
jobs[].name The job name. Must be unique within the CronHPA resource.
jobs[].schedule The cron expression that defines when the job fires. Uses the Go go-cron library. See Cron expression format.
jobs[].targetSize The number of replicas to scale to when the job fires.
jobs[].runOnce When set to true, the task executes only once and exits after the first execution. Default: false.

Cron expression format

CronHPA uses a 6-field cron expression (seconds-first), unlike standard 5-field crontab syntax.

<Seconds> <Minutes> <Hours> <Day of month> <Month> <Day of week>
Field Required Allowed values Special characters
Seconds Yes 0–59 * / , -
Minutes Yes 0–59 * / , -
Hours Yes 0–23 * / , -
Day of month Yes 1–31 * / , - ?
Month Yes 1–12 or JAN–DEC * / , -
Day of week Yes 0–6 or SUN–SAT * / , - ?

Common schedule examples:

Schedule Meaning
0 0 8 * * * Every day at 08:00
0 0 18 * * 1-5 Weekdays (Mon–Fri) at 18:00
0 0 */1 * * * Every hour, on the hour
0 30 */1 * * * Every hour, at 30 minutes past
0 0 8 * * 1-5 Weekdays at 08:00 (scale up for business hours)
0 0 20 * * 1-5 Weekdays at 20:00 (scale down after business hours)

For the full expression reference, see the kubernetes-cronhpa-controller documentation.

More operations

View, add, or edit CronHPA jobs

After creating CronHPA jobs, you can view their status and edit the configuration from the following entry points:

  • Workload Scaling page: In the left-side navigation pane, choose Auto Scaling > Workload Scaling. On the Horizontal Scaling tab, find the target CronHPA in the CronHPA section and click Edit in the Actions column.

  • Deployments page: In the left-side navigation pane, choose Workloads > Deployments. Click Details for the target Deployment, then click the Pod Scaling tab. In the CronHPA section, click Add or Edit Job in the Actions column.

Coordinate CronHPA with HPA

CronHPA and HPA operate independently and are unaware of each other. If both are configured for the same workload, their scaling actions may conflict — the later action overwrites the earlier one.

To resolve this conflict, if ACK detects that both CronHPA and HPA are deployed, it sets the scaling target of CronHPA to HPA, thereby enabling scheduled scaling for the HPA scaling object, such as a Deployment.

For setup instructions, see Implement coordination between CronHPA and HPA.

FAQ

How do I uninstall ack-kubernetes-cronhpa-controller?

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Applications > Helm.

  3. On the Helm page, check whether the ack-kubernetes-cronhpa-controller component exists.

    • If it exists, click Delete in the Actions column. > Important: Deleting the component via Helm does not delete the Custom Resource Definition (CRD) or any CronHPA task resources. Delete those manually after uninstalling the component.

    • If it does not exist, proceed to the next step.

  4. In the left-side navigation pane, choose Operations > Add-ons.

  5. On the Add-ons page, find ack-kubernetes-cronhpa-controller and click Uninstall.

What's next

References