For stateless applications with periodic fluctuations in business usage, CronHPA (Cron Horizontal Pod Autoscaler) supports adjusting the number of pods based on the time policies you set, allowing you to optimize resource usage according to predictable business patterns.
You can create a cron horizontal pod autoscaler to specify the number of pods you want to run at specific times according to a schedule, allowing you to prepare for predictable traffic patterns or reduce resource usage during off-peak hours.
After you create a cron horizontal pod autoscaler, the platform begins to monitor the schedule and automatically adjusts the number of pods at the specified times. This time-based scaling occurs independently of resource utilization metrics, making it ideal for applications with known usage patterns.
The CronHPA works by defining one or more schedule rules, each specifying a time (using crontab format) and a target number of replicas. When a scheduled time is reached, the CronHPA adjusts the pod count to match the specified target, regardless of the current resource utilization.
The cron horizontal pod autoscaler (CronHPA) extends the concept of pod auto-scaling with time-based controls. The CronHPA lets you define specific times when the number of pods should change, allowing you to prepare for predictable traffic patterns or reduce resource usage during off-peak hours.
The CronHPA works by continuously checking the current time against the defined schedules. When a scheduled time is reached, the controller adjusts the number of pods to match the target replica count specified for that schedule. If multiple schedules trigger at the same time, the platform will use the rule with higher priority (the one defined earlier in the configuration).
Please ensure that the monitoring components are deployed in the current cluster and are functioning properly. You can check the deployment and health status of the monitoring components by clicking on the top right corner of the platform > Platform Health Status..
You can create a cron horizontal pod autoscaler using the command line interface by defining a YAML file and using the kubectl create
command. The following example shows scheduled scaling for a Deployment object:
cronhpa.yaml
with the following content:This example configures the deployment to:
Enter Container Platform.
In the left navigation bar, click Workloads > Deployments.
Click on Deployment Name.
Scroll down to the Elastic Scaling section and click Update on the right.
Select Scheduled Scaling, and configure the scaling rules. When the type is Custom, you must provide a Crontab expression for the trigger condition, formatted as minute hour day month week
. For detailed introduction, please refer to Writing Crontab Expressions.
Click Update.
Important Notes:
minute hour day month week
) and follows the same rules as Kubernetes CronJobs.