All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ALB::ServerGroup

Last Updated:Jul 10, 2024

ALIYUN::ALB::ServerGroup is used to create a server group.

Syntax

{
  "Type": "ALIYUN::ALB::ServerGroup",
  "Properties": {
    "VpcId": String,
    "ResourceGroupId": String,
    "Scheduler": String,
    "StickySessionConfig": Map,
    "HealthCheckConfig": Map,
    "Protocol": String,
    "ServerGroupType": String,
    "ServerGroupName": String,
    "Tags": List,
    "ServiceName": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

HealthCheckConfig

Map

Yes

Yes

The configurations of health checks.

For more information, see HealthCheckConfig properties.

ServerGroupName

String

Yes

Yes

The name of the server group.

The name must be 2 to 128 characters in length and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

VpcId

String

Yes

No

The virtual private cloud (VPC) ID.

You can add only servers that are deployed in the VPC to the server group.

Protocol

String

No

No

The backend protocol.

Valid values:

  • HTTP (default): allows you to associate HTTPS, HTTP, or Quick UDP Internet Connections (QUIC) listeners with the server group.

  • HTTPS: allows you to associate only HTTPS listeners with the server group.

ResourceGroupId

String

No

Yes

The resource group ID.

None.

Scheduler

String

No

Yes

The scheduling algorithm.

Valid values:

  • Wrr (default): Backend servers that have higher weights receive more requests than backend servers that have lower weights.

  • Wlc: Requests are distributed based on the weights and number of connections to backend servers. If multiple backend servers have the same weight, the backend server that has the least connections receives more requests.

  • Sch: Consistent hashing is performed on source IP addresses.

ServerGroupType

String

No

No

The server group type.

Valid values:

  • Instance (default): server

  • Ip: IP address

ServiceName

String

No

Yes

The name of the Kubernetes service that is associated with the server group.

Note

This property is applicable only to scenarios in which Application Load Balancer (ALB) Ingresses are used.

StickySessionConfig

Map

No

Yes

The configurations of session persistence.

For more information, see StickySessionConfig properties.

Tags

List

No

Yes

The tags of the server group.

You can add up to 20 tags to a server group.

For more information, see Tags properties.

StickySessionConfig syntax

"StickySessionConfig": {
  "Cookie": String,
  "CookieTimeout": Integer,
  "StickySessionType": String,
  "StickySessionEnabled": Boolean
}

StickySessionConfig properties

Property

Type

Required

Editable

Description

Constraint

Cookie

String

No

Yes

The cookie that you configure for the server.

The cookie must be 1 to 200 characters in length and can contain letters and digits. The cookie cannot contain commas (,), semicolons (;), or spaces or start with a dollar sign ($).

Note

This property is required if you set StickySessionEnabled to true and StickySessionType to Server.

CookieTimeout

Integer

No

Yes

The timeout period of the cookie.

Valid values: 1 to 86400.

Default value: 1000.

Unit: seconds.

Note

This property is required if you set StickySessionEnabled to true and StickySessionType to Insert.

StickySessionEnabled

Boolean

No

Yes

Specifies whether to enable session persistence.

Valid values:

  • true

  • false

Note

This property is required if you set ServerGroupType to Instance or Ip.

StickySessionType

String

No

Yes

The method that you want to use to handle the cookie.

Valid values:

  • Insert: inserts a cookie. ALB inserts the cookie SERVERID into the first HTTP or HTTPS response packet that is sent to a client. The next request from the client carries the cookie and ALB forwards this request to the backend server that is associated with ALB.

  • Server: rewrites a cookie. When ALB detects a custom cookie that you specify, ALB uses the custom cookie to overwrite the original cookie. The next request from the client carries the custom cookie and ALB forwards this request to the backend server that is associated with ALB.

Note

This property is required if you set StickySessionEnabled to true.

HealthCheckConfig syntax

"HealthCheckConfig": {
  "HealthCheckInterval": Integer,
  "HealthCheckConnectPort": Integer,
  "HealthCheckCodes": List,
  "UnhealthyThreshold": Integer,
  "HealthCheckMethod": String,
  "HealthCheckPath": String,
  "HealthCheckHost": String,
  "HealthyThreshold": Integer,
  "HealthCheckProtocol": String,
  "HealthCheckHttpVersion": String,
  "HealthCheckEnabled": Boolean,
  "HealthCheckTimeout": Integer
}

HealthCheckConfig properties

Property

Type

Required

Editable

Description

Constraint

HealthCheckEnabled

Boolean

Yes

Yes

Specifies whether to enable the health check feature.

Valid values:

  • true

  • false

HealthCheckCodes

List

No

Yes

The status codes for health checks.

Valid values:

  • http_2xx (default)

  • http_3xx

  • http_4xx

  • http_5xx

Note

This property takes effect only if HealthCheckProtocol is set to HTTP.

HealthCheckConnectPort

Integer

No

Yes

The port that is used for health checks on backend servers.

Valid values: 0 to 65535.

Default value: 0. This value specifies that the port of a backend server is used for health checks.

HealthCheckHost

String

No

Yes

The domain name that is used for health checks.

The domain name must be 1 to 80 characters in length and can contain lowercase letters, digits, hyphens (-), and periods (.).

Example: www.example.com.

Note

This property takes effect only if HealthCheckProtocol is set to HTTP.

HealthCheckHttpVersion

String

No

Yes

The version of HTTP that is used for health checks.

Valid values:

  • HTTP1.0

  • HTTP1.1 (default)

Note

This property takes effect only if HealthCheckProtocol is set to HTTP.

HealthCheckInterval

Integer

No

Yes

The interval at which the system performs health checks.

Valid values: 1 to 50.

Default value: 2.

Unit: seconds.

HealthCheckMethod

String

No

Yes

The health check method.

Valid values:

  • GET

  • HEAD (default)

Note

This property takes effect only if HealthCheckProtocol is set to HTTP.

HealthCheckPath

String

No

Yes

The path that is used for health checks.

The path must be 1 to 80 characters in length and can contain letters, digits, and the following special characters: - / . % ? # & = _ ; ~ ! ( ) * [ ] @ $ ^ : ' , +.

Note

This property takes effect only if HealthCheckProtocol is set to HTTP.

HealthCheckProtocol

String

No

Yes

The protocol that you want to use for health checks.

Valid values:

  • HTTP

  • HTTPS

HealthCheckTimeout

Integer

No

Yes

Specify the timeout period of a health check response.

If a backend Elastic Compute Service (ECS) instance does not return a health check response within the specified timeout period, the instance fails the health check.

Valid values: 1 to 300.

Default value: 5.

Unit: seconds.

Note

If the value of HealthCheckTimeout is smaller than the value of HealthCheckInterval, the timeout period specified by HealthCheckTimeout becomes invalid, and the value of HealthCheckInterval is used as the timeout period.

HealthyThreshold

Integer

No

Yes

The number of consecutive successful health checks that must occur in an unhealthy backend server before the backend server is declared healthy. If this number is reached, the health check status is changed from failed to successful.

Valid values: 2 to 10.

Default value: 3.

UnhealthyThreshold

Integer

No

Yes

The number of consecutive failed health checks that must occur in a healthy backend server before the backend server is declared unhealthy. If this number is reached, the health check status is changed from successful to failed.

Valid values: 2 to 10.

Default value: 3.

Tags syntax

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  

Tags properties

Property

Type

Required

Editable

Description

Constraint

Key

String

Yes

No

The tag key.

The tag key must be 1 to 128 characters in length and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

Value

String

No

No

The tag value.

The tag value must be 0 to 128 characters in length and cannot contain http:// or https://. The tag value cannot start with aliyun or acs:.

Return values

Fn::GetAtt

ServerGroupId: the ID of the server group.

Examples

Note

Change the values of masked parameters based on your business requirements.

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Label:
      zh-cn: VPC ID
      en: Existing VPC Instance ID
Resources:
  ServerGroup:
    Type: ALIYUN::ALB::ServerGroup
    Properties:
      VpcId:
        Ref: VpcId
      StickySessionConfig:
        Cookie: B490B5EBF6F3CD402E515D22****
        CookieTimeout: 1000
        StickySessionEnabled: true
        StickySessionType: Insert
      HealthCheckConfig:
        HealthCheckConnectPort: 80
        HealthCheckEnabled: true
        HealthCheckHost: www.example.com
        HealthCheckCodes:
          - http_2xx
        HealthCheckHttpVersion: HTTP1.0
        HealthCheckInterval: 5
        HealthCheckMethod: HEAD
        HealthCheckPath: /test/index.html
        HealthCheckProtocol: HTTP
        HealthCheckTimeout: 3
        HealthyThreshold: 4
        UnhealthyThreshold: 4
      ServerGroupName: TestServerGroup
Outputs:
  ServerGroupId:
    Description: The ID of the server group.
    Value:
      Fn::GetAtt:
        - ServerGroup
        - ServerGroupId                  

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "VpcId": {
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
      "Type": "String",
      "Label": {
        "zh-cn": "VPC ID",
        "en": "Existing VPC Instance ID"
      }
    }
  },
  "Resources": {
    "ServerGroup": {
      "Type": "ALIYUN::ALB::ServerGroup",
      "Properties": {
        "VpcId": {
          "Ref": "VpcId"
        },
        "StickySessionConfig": {
          "Cookie": "B490B5EBF6F3CD402E515D22****",
          "CookieTimeout": 1000,
          "StickySessionEnabled": true,
          "StickySessionType": "Insert"
        },
        "HealthCheckConfig": {
          "HealthCheckConnectPort": 80,
          "HealthCheckEnabled": true,
          "HealthCheckHost": "www.example.com",
          "HealthCheckCodes": [
            "http_2xx"
          ],
          "HealthCheckHttpVersion": "HTTP1.0",
          "HealthCheckInterval": 5,
          "HealthCheckMethod": "HEAD",
          "HealthCheckPath": "/test/index.html",
          "HealthCheckProtocol": "HTTP",
          "HealthCheckTimeout": 3,
          "HealthyThreshold": 4,
          "UnhealthyThreshold": 4
        },
        "ServerGroupName": "TestServerGroup"
      }
    }
  },
  "Outputs": {
    "ServerGroupId": {
      "Description": "The ID of the server group.",
      "Value": {
        "Fn::GetAtt": [
          "ServerGroup",
          "ServerGroupId"
        ]
      }
    }
  }
}