ALIYUN::ALB::ServerGroup类型用于创建服务器组。

语法

{
  "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
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
VpcId String 专有网络ID。 只有该VPC下的服务器可以加入服务器组。
ResourceGroupId String 资源组ID。
Scheduler String 调度算法。 取值:
  • Wrr(默认值):权重值越高的后端服务器,被轮询到的概率也越高。
  • Wlc:除了根据每台后端服务器设定的权重值来进行轮询,同时还考虑后端服务器的实际负载(即连接数)。当权重值相同时,当前连接数越小的后端服务器被轮询到的概率也越高。
  • Sch:源IP一致性Hash。
StickySessionConfig Map 会话保持配置结构体。 更多信息,请参见StickySessionConfig属性
HealthCheckConfig Map 健康检查相关配置结构。 更多信息,请参见HealthCheckConfig属性
Protocol String 后端协议。 取值:
  • HTTP(默认值):支持关联HTTPS、HTTP和QUIC监听。
  • HTTPS:支持关联HTTPS监听。
ServerGroupType String 服务器组类型。 取值:
  • Instance(默认值):服务器类型。
  • Ip:IP地址类型。
ServerGroupName String 服务器组名称。 长度为2~128个字符,必须以英文字母或汉字开头,可包含数字、半角句点(.)、下划线(_)和短划线(-)。
Tags List 标签。 最多添加20个标签。

更多信息,请参见Tags属性

ServiceName String 服务器组对应的Kubernetes服务名称。
说明 本参数仅适用于应用路由场景。

StickySessionConfig语法

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

StickySessionConfig属性

属性名称 类型 必须 允许更新 描述 约束
Cookie String 服务器上配置的Cookie。 长度为1~200个字符,不能以美元符号($)开头,可包含英文字母和数字,不能包含半角逗号(,)、半角分号(;)或空格。
说明 当StickySessionEnabled取值为true且StickySessionType取值为Server时,必须指定该参数。
CookieTimeout Integer Cookie超时时间。 取值范围:1~86,400。

默认值:1000。

单位:秒。
说明 当StickySessionEnabled取值为true且StickySessionType取值为Insert时,必须指定该参数。
StickySessionType String Cookie的处理方式。 取值:
  • Insert(默认值):植入Cookie。客户端第一次访问时,负载均衡会在返回请求中植入Cookie(即在HTTP或HTTPS响应报文中插入SERVERID),下次客户端携带此Cookie访问,负载均衡服务会将请求定向转发给之前记录到的后端服务器上。
  • Server:重写Cookie。负载均衡发现用户自定义了Cookie,将会对原来的Cookie进行重写,下次客户端携带新的Cookie访问,负载均衡服务会将请求定向转发给之前记录到的后端服务器。
说明 当StickySessionEnabled取值为true时,必须指定该参数。
StickySessionEnabled Boolean 是否启用会话保持。 取值:
  • true:启用。
  • false:禁用。
说明 当ServerGroupType取值为 InstanceIp时,必须指定该参数。

HealthCheckConfig语法

"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属性

属性名称 类型 必须 允许更新 描述 约束
HealthCheckInterval Integer 健康检查的时间间隔。 取值范围:1~50。

默认值:2。

单位:秒。
HealthCheckConnectPort Integer 健康检查的后端服务器的端口。 取值范围: 0~65,535。

默认值:0,表示使用后端服务器的端口进行健康检查。

HealthCheckCodes List 健康检查的状态码列表。 取值:
  • http_2xx(默认值)
  • http_3xx
  • http_4xx
  • http_5xx
说明 当HealthCheckProtocol取值为HTTP时,该参数有效。
UnhealthyThreshold Integer 健康检查连续失败多少次后,将后端服务器的健康检查状态由成功判定为失败。 取值范围:2~10。

默认值:3。

HealthCheckMethod String 健康检查方式。 取值:
  • GET
  • HEAD(默认值)
说明 当HealthCheckProtocol取值为HTTP时,该参数有效。
HealthCheckPath String 健康检查的路径。 长度为1~80,必须以正斜线(/)开头。可包含英文字母、数字和特殊字符-/.%?#&=_;~!()*[]@$^:',+
说明 当HealthCheckProtocol取值为HTTP时,该参数有效。
HealthCheckHost String 健康检查域名。 长度为1~80个字符。可包含小写英文字母、数字、短划线(-)和半角句号(.)。

取值示例:www.example.com

说明 当HealthCheckProtocol取值为HTTP时,该参数有效。
HealthyThreshold Integer 健康检查连续成功多少次后,将后端服务器的健康检查状态由失败判定为成功。 取值范围:2~10。

默认值:3。

HealthCheckProtocol String 健康检查协议。 取值:
  • HTTP
  • HTTPS
HealthCheckHttpVersion String 健康检查HTTP协议版本。 取值:
  • HTTP1.0
  • HTTP1.1(默认值)
说明 当HealthCheckProtocol取值为HTTP时,该参数有效。
HealthCheckEnabled Boolean 是否启用健康检查。 取值:
  • true:启用。
  • false:禁用。
HealthCheckTimeout Integer 接收来自运行状况检查的响应需要等待的时间。 如果后端ECS在指定的时间内没有正确响应,则判定为健康检查失败。

取值范围:1~300。

默认值:5。

单位:秒。
说明 如果HealthCHeckTimeout的值小于HealthCheckInterval的值,则HealthCHeckTimeout无效,超时时间为HealthCheckInterval的值。

Tags语法

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

Tags属性

属性名称 类型 必须 允许更新 描述 约束
Key String 标签键。 长度为1~128个字符,不能以aliyunacs:开头,不能包含http://或https:// 。
Value String 标签值。 长度为0~128个字符,不能以aliyunacs:开头,不能包含http://或https:// 。

返回值

Fn::GetAtt

ServerGroupId:服务器组ID。

示例

  • YAML格式

    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格式

    {
      "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"
            ]
          }
        }
      }
    }