Updated on 2023-12-13 GMT+08:00

APM.AutoScaler

Element Description

The APM.AutoScaler element is used to control elastic scaling of applications.

Element Properties

Table 1 Property Description

Property

Required

Descripiton

name

Yes

Auto scaling policy type

Type: string

Value Description: Supports customization.

Value Constraint: The value contains 1 to 64 characters. This value is unique under a tenant, and must meet the following requirement: {"regex": "^[a-zA-Z][0-9a-zA-Z-_]*$", "min_length" :1, "max_length" :64}.

maxInstances

Yes

Maximum number of instances supported by an auto scaling policy. If the number of instances reaches this value, scale-out will not be performed.

Type: integer

Value Description: Supports an integer ranging from 1 to 1000. For example, 15.

Default: 10

Value Constraint: The value must be an integer ranging from 1 to 1000. This integer must be greater than the value of minInstance.

Suggestion: Set the value based on specifications and requirements.

appName

Yes

Application to which the auto scaling policy applies

Type: string

Value Description: Indicates the name of the CCE.deployment object in the template.

Default: ''

Suggestion: You are advised to connect to the CCE.deployment object and use the get_reference function to automatically obtain the value, or manually enter the value.

rules

Yes

Auto scaling rule, which indicates the scale-out or scale-in policy (currently, scaling can only be performed based on performance metrics)

Type: APM.AutoscalerRule Array

Value Description: Indicates the APM.AutoscalerRule array.

Value Constraint: The definition of the APM.AutoscalerRule type is met.

Suggestion: Select the rules field in the component part, and then fill in the field based on prompts.

clusterId

No

Cluster ID to which the auto scaling policy applies

Type: HuaweiCloud.CCE.Cluster.Id

Value Description: Indicates the ID of the CCE.cluster object in the template.

Suggestion: You are advised to connect to the CCE.deployment object which is contained in the CCE.cluster object and use the get_attribute function to automatically obtain the value, or manually enter the value.

cooldownTime

Yes

Cooldown time of auto scaling, that is, the interval between two consecutive auto scalings

Type: integer

Value Description: Supports an integer ranging from 0 to 86400 (unit: s). For example, 180.

Default: 60

Value Constraint: The value must be an integer ranging from 0 to 86400. The maximum cooldown time is 24 hours.

Suggestion: Set the value based on specifications and requirements.

minInstances

Yes

Minimum number of instances supported by an auto scaling policy.

Type: integer

Value Description: Supports an integer ranging from 1 to 1000. For example, 15.

Default: 1

Value Constraint: The value must be an integer ranging from 1 to 1000. This integer must be greater than the value of maxInstance.

Suggestion: Set the value based on specifications and requirements.

type

Yes

Auto scaling policy type

Type: string

Value Description: Supports auto scaling for the current type of application. That is, policies can be loaded to stateless applications and CCE deployment objects.

Default: app

Value Constraint: Currently, only app is supported.

Suggestion: Use the default value.

Relationships Between Elements

Table 2 Relationship description

Description

Target

Connected

ServiceStage.StatelessApplication

ContainedIn

CCE.Cluster

Connected

CCE.Deployment

Return Value

Property

Type

Description

refID

string

Instance ID of an auto scaling policy

refName

string

Instance name of an auto scaling policy

Blueprint Example

tosca_definitions_version: huaweicloud_tosca_version_1_0
inputs:
  images:
    type: string
  instances:
    default: 1
    type: integer
node_templates:
  containercomponent-2:      # Define containers of the application.
    type: HuaweiCloud.ServiceStage.ContainerComponent
    properties:
      package:
        image:
          get_input: images
        imagePullPolicy: Always
        lifecycle:
          postStart:
            - '/bin/bash'
            - '-c'
            - touch aos
          preStop:
            - '/bin/bash'
            - '-c'
            - sleep 60
  statelessapplication-1:     # Define a Deployment.
    type: HuaweiCloud.ServiceStage.StatelessApplication
    properties:
      affinitySelector:
        affinities:
          antiself: false
      instances:
        get_input: instances
      type: container
    requirements:
      - package:
          node: containercomponent-2
          relationship: HuaweiCloud.Relationships.PackageConsistsOf
  my-scaling-policy:
    type: HuaweiCloud.APM.AutoScaler
    properties:
      name: my-scaling-policy
      maxInstances: 10
      minInstances: 3
      cooldownTime: 180
      rules:
        - name: scaling-out-rule
          conditions:
            - evaluationPeriods: 1
              metricUnit: Percent
              period: 60
              metricOperation: '>'
              metricThreshold: 70
              metricNamespace: PAAS.CONTAINER
              statistic: average
              metricName: cpuUsage
          actions:
            - type: scale_out_k8s
              parameters:
                scaleUnit: 1
        - name: scaling-in-rule
          conditions:
            - metricNamespace: PAAS.CONTAINER
              metricName: cpuUsage
              metricUnit: Percent
              metricOperation: <
              metricThreshold: 50
              statistic: average
              period: 60
              evaluationPeriods: 3
          actions:
            - type: scale_in_k8s
    requirements:
      - application:
          node: statelessapplication-1       # Define the dependencies on StatelessApplication.