Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a CronFederatedHPA to Scale Pods at Regular Intervals

Updated on 2024-09-19 GMT+08:00

This section describes how you can create a CronFederatedHPA so that pods in workloads are automatically scaled in or out at regular intervals.

Before creating a CronFederatedHPA, you must have learnt the basic working principle and concepts of CronFederatedHPA (How CronFederatedHPA Works). To know the differences between the FederatedHPA and CronFederatedHPA, see Overview.

Constraints

CronFederatedHPA can be configured only for clusters 1.19 or later.

Creating a CronFederatedHPA

Using the console

  1. Log in to the UCS console and choose Fleets in the navigation pane.
  2. Click the name of the fleet with federation enabled.
  3. Choose Workload Scaling in the navigation pane and click the Scheduled Policies tab. Then click Create Scheduled Policy in the upper right corner.
  4. Configure parameters for the CronFederatedHPA by referring to Table 1.

    Table 1 Basic parameters

    Parameter

    Description

    Policy Name

    Enter a name for the CronFederatedHPA.

    Namespace

    Select the namespace for the workload for which you want to configure automatic scaling.

    Object

    Select Workloads or Metric-based Policy.

    • Workloads: Select or create a workload you will associate the policy with. For details, see Creating a Workload.
    • Metric-based Policy: Select an existing metric-based policy or click Create Metric-based Policy on the right to create one. For details, see Creating a FederatedHPA.

  5. Click Add Rule in Policy Settings. In the displayed dialog box, configure parameters by referring to Table 2.

    Table 2 Parameters for adding a rule

    Parameter

    Description

    Rule Name

    Enter a name for the CronFederatedHPA.

    Expected Copies

    Enter the desired number of pods scaled when the CronFederatedHPA is triggered.

    Triggered

    Select Hourly, Daily, Weekly, Monthly, Yearly, or Cron.

    • Hourly: a specific minute in an hour when the policy is executed. For example, if you select 5, the policy is executed at the fifth minute of every hour.
    • Daily: a specific minute every day when the policy is executed.
    • Weekly: a specific minute on a day of each week when the policy is executed.
    • Monthly: a specific minute on a day of each month when the policy is executed.
    • Yearly: a specific minute on a day of a month in each year when the policy is executed.
    • Cron:

      Cron expression syntax:

     ┌───────────── Minute (0 to 59)
     │ ┌───────────  Hour (0 to 23)
     │ │ ┌────────── A day in a month (1 to 31)
     │ │ │ ┌────────  Month (1 to 12)
     │ │ │ │ ┌─────── A day in a week (0 to 6)
     │ │ │ │ │ 
     │ │ │ │ │                           
     *  *  *  *  * 

    For example, 0 0 13 * 5 indicates that a task is started at 00:00 on every Friday and the 13th day of each month.

    Time Zone

    Select Shanghai or Singapore.

  6. Click OK and then click Create.

    In the displayed policy list, you can view the policy details.

Using kubectl

  1. Use kubectl to connect to the federation. For details, see Using kubectl to Connect to a Federation.
  2. Create and edit a cfhpa.yaml file.

    vi cfhpa.yaml

    For details about the parameters in this file, see Table 3. In this example, the CronFederatedHPA named cron-federated-hpa is used for the test workload and contains two rules (Scale-Up and Scale-Down) for scheduled scaling. Scale-Up specifies that 10 pods are scaled out at 8:30 daily, and Scale-Down specifies that 5 pods are scaled in at 21:00 daily.

    apiVersion: autoscaling.karmada.io/v1alpha1 
    kind: CronFederatedHPA 
    metadata: 
      name: cron-federated-hpa           # CronFederatedHPA name
    spec: 
      scaleTargetRef: 
        apiVersion: apps/v1 
        kind: Deployment                 # Select Deployment or FederatedHPA.
        name: test                       # Name of the workload or FederatedHPA
      rules: 
      - name: "Scale-Up"                 # Rule name
        schedule: 30 08 * * *            # Time when the policy is triggered
        targetReplicas: 10               # Desired number of pods, which is a non-negative integer
        timeZone: Asia/Shanghai          # Time zone
      - name: "Scale-Down"               # Rule name
        schedule: 0 21 * * *             # Time when the policy is triggered
        targetReplicas: 5                # Desired number of pods, which is a non-negative integer
        timeZone: Asia/Shanghai          # Time zone
    Table 3 Key parameters

    Parameter

    Mandatory

    Type

    Description

    kind

    Yes

    String

    Select Deployment or FederatedHPA.

    • Deployment: The CronFederatedHPA is used separately.
    • FederatedHPA: Both FederatedHPA and CronFederatedHPA are used.

    name

    Yes

    String

    Enter the rule name of 1 to 32 characters in the CronFederatedHPA.

    schedule

    Yes

    String

    Time when the policy is triggered. Cron expression syntax:

     ┌───────────── Minute (0 to 59)
     │ ┌───────────  Hour (0 to 23)
     │ │ ┌────────── A day in a month (1 to 31)
     │ │ │ ┌────────  Month (1 to 12)
     │ │ │ │ ┌─────── A day in a week (0 to 6)
     │ │ │ │ │ 
     │ │ │ │ │                           
      *  *  *  *  * 

    For example, 0 0 13 * 5 indicates that a task is started at 00:00 on every Friday and the 13th day of each month.

    targetReplicas

    Yes

    String

    Enter the desired number of pods scaled when the CronFederatedHPA is triggered.

    timeZone

    Yes

    String

    Select Shanghai or Singapore.

    • Shanghai: Asia/Shanghai
    • Singapore: Asia/Singapore

  3. Create a CronFederatedHPA.

    kubectl apply -f cfhpa.yaml

    If information similar to the following is displayed, the policy has been created:

    CronFederatedHPA.autoscaling.karmada.io/cron-federated-hpa created

    You can run the following commands to check the workload scaling:

    • kubectl get deployments: checks the current number of pods in a workload.
    • kubectl describe cronfederatedhpa cron-federated-hpa: views scaling events (latest three records) of the CronFederatedHPA.

    You can run the following commands to manage CronFederatedHPA cron-federated-hpa (replaced with the actual name):

    • kubectl get cronfederatedhpa cron-federated-hpa: obtains the CronFederatedHPA.
    • kubectl edit cronfederatedhpa cron-federated-hpa: updates the CronFederatedHPA.
    • kubectl delete cronfederatedhpa cron-federated-hpa: deletes the CronFederatedHPA.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback