ALIYUN::CS::ClusterNodePool類型用於為叢集建立節點池。
文法
{
"Type": "ALIYUN::CS::ClusterNodePool",
"Properties": {
"TeeConfig": Map,
"ClusterId": String,
"NodePoolInfo": Map,
"KubernetesConfig": Map,
"Count": Integer,
"Management": Map,
"AutoScaling": Map,
"ScalingGroup": Map
}
}屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
ClusterId | String | 是 | 否 | 叢集ID。 | 您可以通過調用DescribeClustersV1查詢叢集ID。 |
ScalingGroup | Map | 是 | 是 | 節點池擴容組配置。 | 您可以通過調用DescribeClusterNodePools查詢節點池擴容組配置。 更多資訊,請參見ScalingGroup文法和ScalingGroup屬性。 |
AutoScaling | Map | 否 | 否 | 自動調整配置。 | 更多資訊,請參見AutoScaling文法和AutoScaling屬性。 |
Count | Integer | 否 | 是 | 節點池節點數量。 | 無 |
KubernetesConfig | Map | 否 | 是 | 叢集相關配置。 | 更多資訊,請參見KubernetesConfig文法和KubernetesConfig屬性。 |
Management | Map | 否 | 否 | 託管節點池配置。 | 更多資訊,請參見Management文法和Management屬性。 |
NodePoolInfo | Map | 否 | 否 | 節點池配置。 | 更多資訊,請參見NodePoolInfo文法和NodePoolInfo屬性。 |
TeeConfig | Map | 否 | 否 | 加密計算叢集配置。 | 更多資訊,請參見TeeConfig文法和TeeConfig屬性。 |
TeeConfig文法
"TeeConfig": {
"TeeEnable": Boolean
}TeeConfig屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
TeeEnable | Boolean | 是 | 否 | 是否開啟加密計算叢集。 | 取值:
|
NodePoolInfo文法
"NodePoolInfo": {
"ResourceGroupId": String,
"Name": String
}NodePoolInfo屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Name | String | 是 | 否 | 節點池名稱。 | 無 |
ResourceGroupId | String | 否 | 否 | 節點池所屬的資源群組ID。 | 無 |
KubernetesConfig文法
"KubernetesConfig": {
"CpuPolicy": String,
"Runtime": String,
"CmsEnabled": Boolean,
"UserData": String,
"NodeNameMode": String,
"RuntimeVersion": String,
"Labels": List,
"Unschedulable": Boolean,
"Taints": List
}KubernetesConfig屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Runtime | String | 是 | 是 | 容器運行時的名稱。 | 無 |
RuntimeVersion | String | 是 | 是 | 容器運行時版本。 | 無 |
CpuPolicy | String | 否 | 是 | 節點CPU管理原則。 | 當叢集版本在1.12.6及以上時,支援以下兩種策略:
|
CmsEnabled | Boolean | 否 | 是 | 是否在ECS節點上安裝CloudMonitor。 | 安裝CloudMonitor後,可以在CloudMonitor控制台查看所建立ECS執行個體的監控資訊。推薦開啟。 取值:
|
NodeNameMode | String | 否 | 否 | 自訂節點名。 | 節點名稱由三部分組成:首碼+節點IP地址子串+尾碼。
|
Labels | List | 否 | 是 | 節點標籤,為Kubernetes叢集節點添加標籤。 | |
UserData | String | 否 | 是 | 節點自訂資料。 | 無 |
Unschedulable | Boolean | 否 | 是 | 是否調度新添加的節點。 | 取值:
|
Taints | List | 否 | 否 | 汙點配置。 |
Labels文法
"Labels": [
{
"Value": String,
"Key": String
}
]Labels屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Value | String | 是 | 是 | 標籤值。 | 無 |
Key | String | 是 | 是 | 標籤鍵。 | 無 |
Taints文法
"Taints": [
{
"Value": String,
"Effect": String,
"Key": String
}
]Taints屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Value | String | 是 | 否 | 汙點值。 | 無 |
Key | String | 是 | 否 | 汙點名稱。 | 無 |
Effect | String | 否 | 否 | 調度策略。 | 取值:
|
Management文法
"Management": {
"UpgradeConfig": Map,
"AutoRepair": Boolean,
"Enable": Boolean
}Management屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Enable | Boolean | 是 | 否 | 是否啟用託管節點池。 | 取值:
|
AutoRepair | Boolean | 否 | 否 | 是否啟用自動修複。 | 此參數僅在Enable取值為true時生效。 取值:
|
UpgradeConfig | Map | 否 | 否 | 自動升級的配置。 | 該屬性僅在Enable取值為true時生效。 更多資訊,請參見UpgradeConfig文法和UpgradeConfig屬性。 |
UpgradeConfig文法
"UpgradeConfig": {
"AutoUpgrade": Boolean,
"SurgePercentage": Integer,
"Surge": Integer,
"MaxUnavailable": Integer
}UpgradeConfig屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
AutoUpgrade | Boolean | 否 | 否 | 是否啟用自動升級。 | 取值:
|
SurgePercentage | Integer | 否 | 否 | 額外節點比例。 | SurgePercentage和Surge只能指定其中一個。 |
Surge | Integer | 否 | 否 | 額外節點數量。 | SurgePercentage和Surge只能指定其中一個。 |
MaxUnavailable | Integer | 否 | 否 | 最大不可用節點數量。 | 取值範圍:1~1000。預設值:1。 |
AutoScaling文法
"AutoScaling": {
"EipBandwidth": Integer,
"Type": String,
"IsBondEip": Boolean,
"MinInstances": Integer,
"Enable": Boolean,
"MaxInstances": Integer,
"EipInternetChargeType": String
}AutoScaling屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Enable | Boolean | 是 | 否 | 是否啟用自動調整。 | 取值:
|
EipBandwidth | Integer | 否 | 否 | EIP頻寬峰值。 | 無 |
EipInternetChargeType | String | 否 | 否 | EIP計費類型。 | 取值:
|
IsBondEip | Boolean | 否 | 否 | 是否綁定EIP。 | 取值:
|
MinInstances | Integer | 否 | 否 | 自動調整組最小執行個體數。 | 無 |
MaxInstances | Integer | 否 | 否 | 自動調整組最大執行個體數。 | 無 |
Type | String | 否 | 否 | 自動調整類型。 | 取值(按照自動調整執行個體類型):
|
ScalingGroup文法
"ScalingGroup": {
"SpotInstanceRemedy": Boolean,
"Platform": String,
"DataDisks": List,
"SystemDiskSize": Integer,
"CompensateWithOnDemand": Boolean,
"InstanceChargeType": String,
"OnDemandPercentageAboveBaseCapacity": Integer,
"AutoRenew": Boolean,
"OnDemandBaseCapacity": Integer,
"SystemDiskPerformanceLevel": String,
"ImageId": String,
"SpotPriceLimit": List,
"InstanceTypes": List,
"Tags": List,
"SpotStrategy": String,
"LoginPassword": String,
"MultiAzPolicy": String,
"AutoRenewPeriod": Integer,
"ScalingPolicy": String,
"KeyPair": String,
"VSwitchIds": List,
"SecurityGroupId": String,
"SpotInstancePools": Integer,
"Period": Integer,
"InternetChargeType": String,
"SystemDiskCategory": String,
"InternetMaxBandwidthOut": Integer,
"RdsInstances": List,
"PeriodUnit": String,
"ZoneIds": List,
"SocEnabled": Boolean,
"ImageType": String,
"InstancePatterns": List,
"SecurityHardeningOs": Boolean
}ScalingGroup屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
InstanceTypes | List | 否 | 是 | 搶佔式執行個體規格。 | 無 |
SystemDiskSize | Integer | 是 | 是 | 節點的系統磁碟大小。 | 單位:GiB。取值範圍:40~500。 |
VSwitchIds | List | 是 | 是 | 交換器ID。 | 無 |
AutoRenew | Boolean | 否 | 是 | 節點池節點是否開啟自動續約。 | 當InstanceChargeType取值為PrePaid時生效。 取值:
|
AutoRenewPeriod | Integer | 否 | 是 | 節點池節點自動續約周期。 | 當InstanceChargeType取值為PrePaid,且AutoRenew取值為true時,AutoRenewPeriod生效且為必選值。 當PeriodUnit取值為Month時,取值:
|
CompensateWithOnDemand | Boolean | 否 | 是 | 當MultiAzPolicy取值為COST_OPTIMIZED時,如果因價格、庫存等原因無法建立足夠的搶佔式執行個體,是否允許自動嘗試建立按量執行個體滿足ECS執行個體數量要求。 | 取值:
|
DataDisks | List | 否 | 是 | 節點池節點資料盤配置。 | 更多資訊,請參見DataDisks文法和DataDisks屬性。 |
InstanceChargeType | String | 否 | 是 | 節點池節點付費類型。 | 取值:
|
ImageId | String | 否 | 是 | 自訂鏡像ID。 | 預設使用系統提供的鏡像。 |
OnDemandPercentageAboveBaseCapacity | Integer | 否 | 是 | 伸縮組滿足OnDemandBaseCapacity要求後,超出的執行個體中按量執行個體應占的比例。 | 取值範圍:0~100。 |
OnDemandBaseCapacity | Integer | 否 | 是 | 伸縮組所需要按量執行個體個數的最小值。 | 取值範圍:0~1000。當按量執行個體個數少於該值時,將優先建立按量執行個體。 |
Platform | String | 否 | 是 | 作業系統。 | 取值:
|
Period | Integer | 否 | 是 | 節點池節點自動續約周期,當選擇預付費和自動續約時才生效,且為必選值。 | 當PeriodUnit取值為Month時,取值:
|
PeriodUnit | String | 否 | 是 | 節點池節點付費周期。 | 當InstanceChargeType取值為PrePaid的時候需要指定周期。 取值:
|
LoginPassword | String | 否 | 是 | SSH登入密碼。 | KeyPair和LoginPassword僅能指定其中一個。 密碼規則為8~30個字元,且至少包含英文字母、數字和特殊符號 |
MultiAzPolicy | String | 否 | 是 | 多可用性區域伸縮組ECS執行個體擴容和縮容策略。 | 取值:
|
KeyPair | String | 否 | 是 | 免密登入金鑰組名稱。 | KeyPair和LoginPassword僅能指定其中一個。 說明 如果建立託管節點池,則只支援KeyPair。 |
SecurityGroupId | String | 否 | 是 | 安全性群組ID。 | 無 |
SpotInstanceRemedy | Boolean | 否 | 是 | 是否使用搶佔式執行個體。 | 取值:
更多資訊,請參見建立搶佔式執行個體。 |
SystemDiskPerformanceLevel | String | 否 | 是 | 設定雲端硬碟的效能等級。 | 取值:
更多資訊,請參見ESSD雲端硬碟。 |
SpotStrategy | String | 否 | 是 | 搶佔式執行個體類型。 | 取值:
更多資訊,請參見使用搶佔式執行個體。 |
SpotPriceLimit | List | 否 | 是 | 設定執行個體的每小時最高價格。 | 最大支援3位小數,SpotStrategy取值為SpotWithPriceLimit時生效。 更多資訊,請參見SpotPriceLimit文法和SpotPriceLimit屬性。 |
SpotInstancePools | Integer | 否 | 是 | 指定可用執行個體規格的個數,伸縮組將按成本最低的多個規格均衡建立搶佔式執行個體。 | 取值範圍:1~10。 |
ScalingPolicy | String | 否 | 是 | 伸縮組模式。 | 取值:
|
SystemDiskCategory | String | 否 | 是 | 節點系統硬碟類型。 | 取值:
|
InternetChargeType | String | 否 | 是 | 公網計費類型。 | 取值:
|
InternetMaxBandwidthOut | Integer | 否 | 是 | 公網出頻寬最大值。 | 單位:Mbit/s。 取值範圍:1 Mbit/s~100 Mbit/s。 |
RdsInstances | List | 否 | 是 | RDS執行個體ID。 | 無 |
Tags | List | 否 | 是 | 僅為ECS執行個體添加標籤。 | 標籤鍵不可以重複,最大長度為128個字元;標籤鍵和標籤值都不能以 |
ZoneIds | List | 否 | 是 | 可用性區域ID列表。 | 無 |
SocEnabled | Boolean | 否 | 否 | 指定是否啟用 MLPS 安全強化。 | 無 |
ImageType | String | 否 | 否 | 作業系統鏡像的類型。 | 您必須指定此參數或Platform參數。 |
InstancePatterns | List | 否 | 是 | 執行個體屬性配置。 | 更多資訊,請參考InstancePatterns屬性。 |
SecurityHardeningOs | Boolean | 否 | 否 | 阿里雲 OS 安全強化。 | 取值:
預設值: |
InstancePatterns文法
"InstancePatterns": [
{
"CpuArchitectures": List,
"MaxCpuCores": Integer,
"MinMemorySize": Integer,
"Memory": Integer,
"InstanceFamilyLevel": String,
"MinCpuCores": Integer,
"Cores": Integer,
"InstanceTypeFamilies": List,
"InstanceCategories": List,
"ExcludedInstanceTypes": List,
"MaxMemorySize": Integer
}
]InstancePatterns屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
CpuArchitectures | List | 否 | 否 | 執行個體的 CPU 架構。 | 取值:
|
MaxCpuCores | Integer | 否 | 否 | 執行個體規格的最大 vCPU 核心數目 | 無 |
MinMemorySize | Integer | 否 | 否 | 執行個體規格的最小記憶體。 | 單位:GiB。 |
Memory | Integer | 否 | 否 | 執行個體規格的記憶體大小。 | 單位為 GiB。 |
InstanceFamilyLevel | String | 否 | 否 | 執行個體規格類型系列層級。 | 無 |
MinCpuCores | Integer | 否 | 否 | 執行個體規格的最小 vCPU 核心數目。 | 無 |
Cores | Integer | 否 | 否 | 執行個體規格的 vCPU 核心數目。 | 無 |
InstanceTypeFamilies | List | 否 | 否 | 指定執行個體規格類型系列。 | 無 |
InstanceCategories | List | 否 | 否 | 執行個體分類。 | 無 |
ExcludedInstanceTypes | List | 否 | 否 | 需要排除的執行個體規格。 | 無 |
MaxMemorySize | Integer | 否 | 否 | 執行個體規格的最大記憶體。 | 單位:GiB。 |
DataDisks文法
"DataDisks": [
{
"Category": String,
"Encrypted": Boolean,
"PerformanceLevel": String,
"Size": Integer,
"AutoSnapshotPolicyId": String,
"Categories": List
}
]DataDisks屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
AutoSnapshotPolicyId | String | 否 | 是 | 選擇自動快照策略ID,雲端硬碟會按照快照策略自動備份。 | 預設值為空白,表示不自動備份。 |
Category | String | 否 | 是 | 資料盤類型。 | 取值:
|
Encrypted | Boolean | 否 | 是 | 是否對資料盤加密。 | 取值:
|
PerformanceLevel | String | 否 | 是 | 設定雲端硬碟的效能等級。 | 取值:
更多資訊,請參見ESSD雲端硬碟。 |
Size | Integer | 否 | 是 | 資料盤大小。 | 取值範圍:40~32768。 預設值:120。 單位:GiB。 |
Categories | List | 否 | 否 | 資料磁碟類型的列表。 | 無 |
SpotPriceLimit文法
"SpotPriceLimit": [
{
"PriceLimit": Number,
"InstanceType": String
}
]SpotPriceLimit屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
PriceLimit | Number | 是 | 是 | 可搶佔執行個體的價格限制。 | 無 |
InstanceType | String | 是 | 是 | 可搶佔執行個體的執行個體類型。 | 無 |
Tags文法
"Tags": [
{
"Value": String,
"Key": String
}
]Tags屬性
屬性名稱 | 類型 | 必須 | 允許更新 | 描述 | 約束 |
Value | String | 是 | 是 | 標籤值。 | 無 |
Key | String | 是 | 是 | 標籤鍵。 | 無 |
傳回值
Fn::GetAtt
NodePoolId:叢集節點池ID。
樣本
情境 1 :建立節點池(固定入參)。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
TeeConfig:
Type: Json
Description: The configurations of confidential computing.
Default: |-
{
"TeeEnable": true
}
ClusterId:
Type: String
Description: Cluster ID.
AssociationProperty: ALIYUN::CS::Cluster::ClusterId
NodePoolInfo:
Type: Json
Description: The configurations of the node pool.
Default: |-
{
"Name": "test"
}
KubernetesConfig:
Type: Json
Description: The configurations of the ACK cluster.
Default: |-
{
"CpuPolicy": "static",
"Runtime": "containerd",
"CmsEnabled": true,
"UserData": "echo 'hello'",
"NodeNameMode": "customized,aliyun.com,5,test",
"RuntimeVersion": "1.4.8",
"Unschedulable": false
}
Count:
Type: Number
Description: The number of nodes in the node pool.
Default: 1
Management:
Type: Json
Description: The configurations of the managed node pool.
Default: |-
{
"UpgradeConfig": {
"AutoUpgrade": true,
"Surge": 1,
"MaxUnavailable": 1
},
"AutoRepair": true,
"Enable": true
}
ScalingGroup:
Type: Json
Description: The configurations of the scaling group used by the node pool.
Default: |-
{
"SpotInstanceRemedy": true,
"Platform": "AliyunLinux",
"SystemDiskSize": 120,
"InstanceChargeType": "PostPaid",
"SystemDiskPerformanceLevel": "PL1",
"ImageId": "aliyun_2_1903_x64_20G_alibase_20210726.vhd",
"InstanceTypes": [
"ecs.ebmhfc6.20xlarge"
],
"LoginPassword": "test****",
"MultiAzPolicy": "BALANCE",
"VSwitchIds": [
"vsw-*****"
],
"SystemDiskCategory": "cloud_essd",
"InternetMaxBandwidthOut": 0
}
Resources:
ClusterNodePool:
Type: ALIYUN::CS::ClusterNodePool
Properties:
TeeConfig:
Ref: TeeConfig
ClusterId:
Ref: ClusterId
NodePoolInfo:
Ref: NodePoolInfo
KubernetesConfig:
Ref: KubernetesConfig
Count:
Ref: Count
Management:
Ref: Management
ScalingGroup:
Ref: ScalingGroup
Outputs:
NodePoolId:
Description: Cluster node pool ID.
Value:
Fn::GetAtt:
- ClusterNodePool
- NodePoolId
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"TeeConfig": {
"Type": "Json",
"Description": "The configurations of confidential computing.",
"Default": "{\n \"TeeEnable\": true\n}"
},
"ClusterId": {
"Type": "String",
"Description": "Cluster ID.",
"AssociationProperty": "ALIYUN::CS::Cluster::ClusterId"
},
"NodePoolInfo": {
"Type": "Json",
"Description": "The configurations of the node pool.",
"Default": "{\n \"Name\": \"test\"\n}"
},
"KubernetesConfig": {
"Type": "Json",
"Description": "The configurations of the ACK cluster.",
"Default": "{\n \"CpuPolicy\": \"static\",\n \"Runtime\": \"containerd\",\n \"CmsEnabled\": true,\n \"UserData\": \"echo 'hello'\",\n \"NodeNameMode\": \"customized,aliyun.com,5,test\",\n \"RuntimeVersion\": \"1.4.8\",\n \"Unschedulable\": false\n}"
},
"Count": {
"Type": "Number",
"Description": "The number of nodes in the node pool.",
"Default": 1
},
"Management": {
"Type": "Json",
"Description": "The configurations of the managed node pool.",
"Default": "{\n \"UpgradeConfig\": {\n \"AutoUpgrade\": true,\n \"Surge\": 1,\n \"MaxUnavailable\": 1\n },\n \"AutoRepair\": true,\n \"Enable\": true\n}"
},
"ScalingGroup": {
"Type": "Json",
"Description": "The configurations of the scaling group used by the node pool.",
"Default": "{\n \"SpotInstanceRemedy\": true,\n \"Platform\": \"AliyunLinux\",\n \"SystemDiskSize\": 120,\n \"InstanceChargeType\": \"PostPaid\",\n \"SystemDiskPerformanceLevel\": \"PL1\",\n \"ImageId\": \"aliyun_2_1903_x64_20G_alibase_20210726.vhd\",\n \"InstanceTypes\": [\n \"ecs.ebmhfc6.20xlarge\"\n ],\n \"LoginPassword\": \"test****\",\n \"MultiAzPolicy\": \"BALANCE\",\n \"VSwitchIds\": [\n \"vsw-*****\"\n ],\n \"SystemDiskCategory\": \"cloud_essd\",\n \"InternetMaxBandwidthOut\": 0\n}"
}
},
"Resources": {
"ClusterNodePool": {
"Type": "ALIYUN::CS::ClusterNodePool",
"Properties": {
"TeeConfig": {
"Ref": "TeeConfig"
},
"ClusterId": {
"Ref": "ClusterId"
},
"NodePoolInfo": {
"Ref": "NodePoolInfo"
},
"KubernetesConfig": {
"Ref": "KubernetesConfig"
},
"Count": {
"Ref": "Count"
},
"Management": {
"Ref": "Management"
},
"ScalingGroup": {
"Ref": "ScalingGroup"
}
}
}
},
"Outputs": {
"NodePoolId": {
"Description": "Cluster node pool ID.",
"Value": {
"Fn::GetAtt": [
"ClusterNodePool",
"NodePoolId"
]
}
}
}
}情境 2 :建立節點池(動態入參)。
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
ClusterId:
AssociationProperty: ALIYUN::CS::Cluster::ClusterId
Type: String
VpcId:
Type: String
AssociationProperty: ALIYUN::ECS::VPC::VPCId
ZoneId1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId2
Label:
en: Availability Zone
zh-cn: 可用性區域1
VSwitchId1:
Type: String
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
ZoneId: ${ZoneId1}
VpcId: ${VpcId}
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: 可用性區域2
VSwitchId2:
Type: String
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
ZoneId: ${ZoneId2}
VpcId: ${VpcId}
InstanceType:
Type: CommaDelimitedList
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
CreateACKClusterParams:
NetworkPlugin: terway-eniip
Label:
en: Instance Type
zh-cn: 執行個體規格
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符號)
Label:
en: Instance Password
zh-cn: 執行個體密碼
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: '長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符號)'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
Default: null
Resources:
NodePools:
Type: 'ALIYUN::CS::ClusterNodePool'
Properties:
ClusterId:
Ref: ClusterId
NodePoolInfo:
Name: k8s-hpa-cluster-nodepool
ScalingGroup:
VSwitchIds:
- Ref: VSwitchId1
- Ref: VSwitchId2
ZoneIds:
- Ref: ZoneId1
- Ref: ZoneId2
SystemDiskCategory: cloud_essd
SystemDiskPerformanceLevel: PL0
SystemDiskSize: 40
InstanceTypes:
Ref: InstanceType
LoginPassword:
Ref: InstancePassword
Platform: AliyunLinux
ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
KubernetesConfig:
Runtime: containerd
RuntimeVersion: 1.6.28
AutoScaling:
Enable: true
MinInstances: 2
MaxInstances: 10
Outputs:
NodePoolId:
Description:
zh-cn: coffee服務訪問地址。
en: The addresses of coffee service.
Value:
Ref: NodePools
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- ClusterId
- VpcId
- ZoneId1
- VSwitchId1
- ZoneId2
- VSwitchId2
- InstanceType
- InstancePassword
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"ClusterId": {
"AssociationProperty": "ALIYUN::CS::Cluster::ClusterId",
"Type": "String"
},
"VpcId": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "可用性區域1"
}
},
"VSwitchId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"ZoneId": "${ZoneId1}",
"VpcId": "${VpcId}"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "可用性區域2"
}
},
"VSwitchId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
"AssociationPropertyMetadata": {
"ZoneId": "${ZoneId2}",
"VpcId": "${VpcId}"
}
},
"InstanceType": {
"Type": "CommaDelimitedList",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"CreateACKClusterParams": {
"NetworkPlugin": "terway-eniip"
}
},
"Label": {
"en": "Instance Type",
"zh-cn": "執行個體規格"
}
},
"InstancePassword": {
"NoEcho": true,
"Type": "String",
"Description": {
"en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)"
},
"Label": {
"en": "Instance Password",
"zh-cn": "執行個體密碼"
},
"ConstraintDescription": {
"en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)"
},
"AssociationProperty": "ALIYUN::ECS::Instance::Password",
"Default": null
}
},
"Resources": {
"NodePools": {
"Type": "ALIYUN::CS::ClusterNodePool",
"Properties": {
"ClusterId": {
"Ref": "ClusterId"
},
"NodePoolInfo": {
"Name": "k8s-hpa-cluster-nodepool"
},
"ScalingGroup": {
"VSwitchIds": [
{
"Ref": "VSwitchId1"
},
{
"Ref": "VSwitchId2"
}
],
"ZoneIds": [
{
"Ref": "ZoneId1"
},
{
"Ref": "ZoneId2"
}
],
"SystemDiskCategory": "cloud_essd",
"SystemDiskPerformanceLevel": "PL0",
"SystemDiskSize": 40,
"InstanceTypes": {
"Ref": "InstanceType"
},
"LoginPassword": {
"Ref": "InstancePassword"
},
"Platform": "AliyunLinux",
"ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd"
},
"KubernetesConfig": {
"Runtime": "containerd",
"RuntimeVersion": "1.6.28"
},
"AutoScaling": {
"Enable": true,
"MinInstances": 2,
"MaxInstances": 10
}
}
}
},
"Outputs": {
"NodePoolId": {
"Description": {
"zh-cn": "coffee服務訪問地址。",
"en": "The addresses of coffee service."
},
"Value": {
"Ref": "NodePools"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ClusterId",
"VpcId",
"ZoneId1",
"VSwitchId1",
"ZoneId2",
"VSwitchId2",
"InstanceType",
"InstancePassword"
]
}
]
}
}
}情境 3 :建立託管Kubernetes叢集,配置VPC、節點池。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 建立託管Kubernetes叢集,配置VPC、節點池、HPA及Log Service,實現容器應用的自動調整與監控。
en: Create a managed Kubernetes cluster, configure Virtual Private Cloud (VPC),
node pools, Horizontal Pod Autoscaler (HPA), and logging services to enable automatic
scaling and monitoring of containerized applications.
Parameters:
CommonName:
Type: String
Default: k8s-hpa-cluster
SlsProjectName:
Type: String
Label:
en: Name of sls project
zh-cn: 記錄項目的名稱
Description:
en: The name contains 3 to 36 characters. It must start and end with a lowercase letter or number. The value can contain lowercase letters, digits, and hyphens (-).
zh-cn: 長度為3~36個字元。必須以小寫英文字母或數字開頭和結尾。可包含小寫英文字母、數字和短劃線(-)。
AssociationProperty: AutoCompleteInput
AssociationPropertyMetadata:
Length: 5
Prefix: k8s-hpa-sls-project-
CharacterClasses:
- Class: lowercase
min: 1
ManagedKubernetesClusterName:
Type: String
Label:
en: Managed Kubernetes Cluster Name
zh-cn: ACK託管版叢集名稱
AssociationProperty: AutoCompleteInput
AssociationPropertyMetadata:
Length: 5
Prefix: k8s-hpa-cluster-
CharacterClasses:
- Class: lowercase
min: 1
ZoneId1:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId2
Label:
en: Availability Zone
zh-cn: 可用性區域1
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: 可用性區域2
InstanceType:
Type: CommaDelimitedList
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
SystemDiskCategory: cloud_essd
CreateACKClusterParams:
NetworkPlugin: terway-eniip
Label:
en: Instance Type
zh-cn: 執行個體規格
InstancePassword:
NoEcho: true
Type: String
Description:
en: >-
Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special
symbol in)
zh-cn: >-
伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
中的特殊符號)
Label:
en: Instance Password
zh-cn: 執行個體密碼
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: '長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/ 中的特殊符號)'
AssociationProperty: 'ALIYUN::ECS::Instance::Password'
Default: null
Resources:
Vpc:
Type: 'ALIYUN::ECS::VPC'
Properties:
CidrBlock: 10.0.0.0/8
VpcName:
Fn::Sub: ${CommonName}-vpc
VSwitch1:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 10.0.0.0/24
ZoneId:
Ref: ZoneId1
VSwitchName:
Fn::Sub: ${CommonName}-vsw
VSwitch2:
Type: 'ALIYUN::ECS::VSwitch'
Properties:
VpcId:
Ref: Vpc
CidrBlock: 10.0.1.0/24
ZoneId:
Ref: ZoneId2
VSwitchName:
Fn::Sub: ${CommonName}-vsw
SecurityGroup:
Type: 'ALIYUN::ECS::SecurityGroup'
Properties:
VpcId:
Ref: Vpc
SecurityGroupName:
Fn::Sub: ${CommonName}-sg
SecurityGroupIngress:
- PortRange: 443/443
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
- PortRange: 80/80
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
SlsProject:
Type: 'ALIYUN::SLS::Project'
Properties:
Name:
Ref: SlsProjectName
AliyunCSManagedAutoScalerRole:
Type: 'ALIYUN::RAM::Role'
Properties:
RoleName: AliyunCSManagedAutoScalerRole
Description: CS使用此角色來訪問您在其他雲產品中的資源。
AssumeRolePolicyDocument:
Version: '1'
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service:
- cs.aliyuncs.com
MaxSessionDuration: 3600
IgnoreExisting: true
DeletionForce: true
PolicyAttachments:
System:
- AliyunCSManagedAutoScalerRolePolicy
AckCluster:
Type: 'ALIYUN::CS::ManagedKubernetesCluster'
DependsOn: AliyunCSManagedAutoScalerRole
Properties:
VpcId:
Ref: Vpc
VSwitchIds:
- Ref: VSwitch1
- Ref: VSwitch2
PodVswitchIds:
- Ref: VSwitch1
- Ref: VSwitch1
Name:
Ref: ManagedKubernetesClusterName
KubernetesVersion: 1.31.1-aliyun.1
ServiceCidr: 192.168.0.0/16
ClusterSpec: ack.pro.small
LoadBalancerSpec: slb.s2.small
IsEnterpriseSecurityGroup: true
SnatEntry: true
NumOfNodes: 0
EndpointPublicAccess: true
Platform: AliyunLinux
Addons:
- Name: ack-node-local-dns
- Name: terway-eniip
Config: '{"IPVlan":"false","NetworkPolicy":"false","ENITrunking":"false"}'
- Name: csi-plugin
- Name: csi-provisioner
- Name: storage-operator
Config: '{"CnfsOssEnable":"false","CnfsNasEnable":"false"}'
- Name: nginx-ingress-controller
Disabled: true
- Name: logtail-ds
Config: '{"IngressDashboardEnabled":"true"}'
- Name: alb-ingress-controller
Version: ""
Config:
Fn::Sub: >-
{"albIngress":{"AddressType":"Internet","ZoneMappings":{"${ZoneId1}":["${VSwitch1}"],
"${ZoneId2}":["${VSwitch2}"]},"CreateDefaultALBConfig":true}}
- Name: ack-helm-manager
- Name: arms-prometheus
ProxyMode: ipvs
DeleteOptions:
- ResourceType: ALB
DeleteMode: delete
- ResourceType: SLB
DeleteMode: delete
- ResourceType: SLS_Data
DeleteMode: delete
- ResourceType: SLS_ControlPlane
DeleteMode: delete
- ResourceType: PrivateZone
DeleteMode: delete
NodePools:
Type: 'ALIYUN::CS::ClusterNodePool'
Properties:
ClusterId:
Ref: AckCluster
NodePoolInfo:
Name: k8s-hpa-cluster-nodepool
ScalingGroup:
VSwitchIds:
- Ref: VSwitch1
- Ref: VSwitch2
ZoneIds:
- Ref: ZoneId1
- Ref: ZoneId2
SystemDiskCategory: cloud_essd
SystemDiskPerformanceLevel: PL0
SystemDiskSize: 40
InstanceTypes:
Ref: InstanceType
LoginPassword:
Ref: InstancePassword
Platform: AliyunLinux
ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
KubernetesConfig:
Runtime: containerd
RuntimeVersion: 1.6.28
AutoScaling:
Enable: true
MinInstances: 2
MaxInstances: 10
Sleep:
Type: 'ALIYUN::ROS::Sleep'
DependsOn: NodePools
Properties:
CreateDuration: 300
AckMetricsAdapter:
Type: 'ALIYUN::CS::ClusterHelmApplication'
DependsOn: Sleep
Properties:
Namespace: kube-system
ChartUrl: 'https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ack-alibaba-cloud-metrics-adapter-1.3.3.tgz'
ClusterId:
Ref: AckCluster
Name: ack-alibaba-cloud-metrics-adapter
ChartValues:
AlibabaCloudMetricsAdapter:
commonLabels: ''
replicas: 1
resources:
metricsAdapterDeployment:
resources:
limits:
cpu: 0.5
memory: 1Gi
requests:
cpu: 100m
memory: 200Mi
configReloader:
resources:
limits:
cpu: 20m
memory: 30Mi
requests:
cpu: 20m
memory: 30Mi
listenPort: 443
costWeights:
cpu: '1.0'
memory: '0.0'
image:
repository: registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/alibaba-cloud-metrics-adapter-amd64
tag: v0.2.7-f1ee5c3-aliyun
pullPolicy: Always
nameOverride: ''
fullnameOverride: ''
service:
type: ClusterIP
serviceAccountName: ack-alibaba-cloud-metrics-adapter
annotations: { }
nodeSelector: { }
tolerations: [ ]
env:
- AccessKeyId: ''
- AccessKeySecret: ''
- Region: ''
affinity: { }
prometheus:
enabled: true
url: { }
metricsRelistInterval: 1m
logLevel: 5
adapter:
rules:
default: false
custom:
- seriesQuery: container_memory_working_set_bytes{namespace!="",pod!=""}
resources:
overrides:
namespace:
resource: namespace
pod:
resource: pod
name:
matches: ^(.*)_bytes
as: ${1}_bytes_per_second
metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)
- seriesQuery: container_cpu_usage_seconds_total{namespace!="",pod!=""}
resources:
overrides:
namespace:
resource: namespace
pod:
resource: pod
name:
matches: ^(.*)_seconds_total
as: ${1}_core_per_second
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)
ConfigReloader:
image:
repository: registry-vpc.cn-hangzhou.aliyuncs.com/acs/configmap-reload
tag: v0.0.1
InstallBackendApp:
Type: 'ALIYUN::CS::ClusterApplication'
DependsOn: AckMetricsAdapter
Properties:
ClusterId:
Ref: AckCluster
YamlContent:
Fn::Sub: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: coffee
spec:
replicas: 2
selector:
matchLabels:
app: coffee
template:
metadata:
labels:
app: coffee
spec:
containers:
- name: coffee
image: registry.${ALIYUN::Region}.aliyuncs.com/acs-sample/nginxdemos:latest
ports:
- containerPort: 80
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
name: coffee-svc
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
app: coffee
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tea
spec:
replicas: 2
selector:
matchLabels:
app: tea
template:
metadata:
labels:
app: tea
spec:
containers:
- name: tea
image: registry.${ALIYUN::Region}.aliyuncs.com/acs-sample/nginxdemos:latest
ports:
- containerPort: 80
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
name: tea-svc
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
app: tea
type: NodePort
AlbConfig:
Type: 'ALIYUN::CS::ClusterApplication'
DependsOn: InstallBackendApp
Properties:
ClusterId:
Ref: AckCluster
YamlContent:
Fn::Sub: |-
apiVersion: alibabacloud.com/v1
kind: AlbConfig
metadata:
name: k8s-hpa-alb-config
spec:
config:
name: k8s-hpa-alb
addressType: Internet
zoneMappings:
- vSwitchId: ${VSwitch1}
- vSwitchId: ${VSwitch2}
accessLogConfig:
logProject: ${SlsProject}
logStore: "alb_k8s_hpa_sls_logstore"
listeners:
- port: 80
protocol: HTTP
IngressClass:
Type: 'ALIYUN::CS::ClusterApplication'
DependsOn: AlbConfig
Properties:
ClusterId:
Ref: AckCluster
YamlContent:
Fn::Sub: |-
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: k8s-hpa-alb-ingress-class
spec:
controller: ingress.k8s.alibabacloud/alb
parameters:
apiGroup: alibabacloud.com
kind: AlbConfig
name: k8s-hpa-alb-config
Ingress:
Type: 'ALIYUN::CS::ClusterApplication'
DependsOn: IngressClass
Properties:
ClusterId:
Ref: AckCluster
YamlContent:
Fn::Sub: |-
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: k8s-hpa-alb-ingress
spec:
ingressClassName: k8s-hpa-alb-ingress-class
rules:
- http:
paths:
- path: /tea
pathType: ImplementationSpecific
backend:
service:
name: tea-svc
port:
number: 80
- path: /coffee
pathType: ImplementationSpecific
backend:
service:
name: coffee-svc
port:
number: 80
Hpa:
Type: 'ALIYUN::CS::ClusterApplication'
DependsOn: WaitAlbIngress
Properties:
ClusterId:
Ref: AckCluster
YamlContent:
Fn::Sub: |-
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: k8s-alb-tea-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: tea
minReplicas: 2
maxReplicas: 10
metrics:
- type: External
external:
metric:
name: sls_alb_ingress_qps
selector:
matchLabels:
sls.project: ${SlsProject}
sls.logstore: "alb_k8s_hpa_sls_logstore"
sls.ingress.route: "default-tea-svc-80"
target:
type: AverageValue
averageValue: 2
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
- resource:
name: memory
target:
averageUtilization: 80
type: Utilization
type: Resource
WaitAlbIngress:
Type: 'ALIYUN::ROS::Sleep'
DependsOn: Ingress
Properties:
CreateDuration: 120
IngressInfo:
Type: 'DATASOURCE::CS::ClusterApplicationResources'
DependsOn: WaitAlbIngress
Properties:
ClusterId:
Ref: AckCluster
Kind: Ingress
Namespace: default
JsonPath: $.items.[0].status.loadBalancer.ingress.[0].hostname
FirstMatch: true
Outputs:
TeaUrl:
Description:
zh-cn: tea服務訪問地址。
en: The addresses of tea service.
Value:
'Fn::Sub': http://${IngressInfo}/tea
CoffeeUrl:
Description:
zh-cn: coffee服務訪問地址。
en: The addresses of coffee service.
Value:
'Fn::Sub': http://${IngressInfo}/coffee
Metadata:
'ALIYUN::ROS::Interface':
ParameterGroups:
- Parameters:
- SlsProjectName
- ManagedKubernetesClusterName
- ZoneId1
- ZoneId2
- InstanceType
- InstancePassword
TemplateTags:
- acs:technical-solution:micro:通過HPA實現容器應用的水平Auto Scaling-tech_solu_125
Hidden:
- CommonName{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "建立託管Kubernetes叢集,配置VPC、節點池、HPA及Log Service,實現容器應用的自動調整與監控。",
"en": "Create a managed Kubernetes cluster, configure Virtual Private Cloud (VPC), node pools, Horizontal Pod Autoscaler (HPA), and logging services to enable automatic scaling and monitoring of containerized applications."
},
"Parameters": {
"CommonName": {
"Type": "String",
"Default": "k8s-hpa-cluster"
},
"SlsProjectName": {
"Type": "String",
"Label": {
"en": "Name of sls project",
"zh-cn": "記錄項目的名稱"
},
"Description": {
"en": "The name contains 3 to 36 characters. It must start and end with a lowercase letter or number. The value can contain lowercase letters, digits, and hyphens (-).",
"zh-cn": "長度為3~36個字元。必須以小寫英文字母或數字開頭和結尾。可包含小寫英文字母、數字和短劃線(-)。"
},
"AssociationProperty": "AutoCompleteInput",
"AssociationPropertyMetadata": {
"Length": 5,
"Prefix": "k8s-hpa-sls-project-",
"CharacterClasses": [
{
"Class": "lowercase",
"min": 1
}
]
}
},
"ManagedKubernetesClusterName": {
"Type": "String",
"Label": {
"en": "Managed Kubernetes Cluster Name",
"zh-cn": "ACK託管版叢集名稱"
},
"AssociationProperty": "AutoCompleteInput",
"AssociationPropertyMetadata": {
"Length": 5,
"Prefix": "k8s-hpa-cluster-",
"CharacterClasses": [
{
"Class": "lowercase",
"min": 1
}
]
}
},
"ZoneId1": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId2"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "可用性區域1"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "可用性區域2"
}
},
"InstanceType": {
"Type": "CommaDelimitedList",
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"SystemDiskCategory": "cloud_essd",
"CreateACKClusterParams": {
"NetworkPlugin": "terway-eniip"
}
},
"Label": {
"en": "Instance Type",
"zh-cn": "執行個體規格"
}
},
"InstancePassword": {
"NoEcho": true,
"Type": "String",
"Description": {
"en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)"
},
"Label": {
"en": "Instance Password",
"zh-cn": "執行個體密碼"
},
"ConstraintDescription": {
"en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)"
},
"AssociationProperty": "ALIYUN::ECS::Instance::Password",
"Default": null
}
},
"Resources": {
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/8",
"VpcName": {
"Fn::Sub": "${CommonName}-vpc"
}
}
},
"VSwitch1": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "10.0.0.0/24",
"ZoneId": {
"Ref": "ZoneId1"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
}
}
},
"VSwitch2": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "10.0.1.0/24",
"ZoneId": {
"Ref": "ZoneId2"
},
"VSwitchName": {
"Fn::Sub": "${CommonName}-vsw"
}
}
},
"SecurityGroup": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupName": {
"Fn::Sub": "${CommonName}-sg"
},
"SecurityGroupIngress": [
{
"PortRange": "443/443",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
},
{
"PortRange": "80/80",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
}
]
}
},
"SlsProject": {
"Type": "ALIYUN::SLS::Project",
"Properties": {
"Name": {
"Ref": "SlsProjectName"
}
}
},
"AliyunCSManagedAutoScalerRole": {
"Type": "ALIYUN::RAM::Role",
"Properties": {
"RoleName": "AliyunCSManagedAutoScalerRole",
"Description": "CS使用此角色來訪問您在其他雲產品中的資源。",
"AssumeRolePolicyDocument": {
"Version": "1",
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": [
"cs.aliyuncs.com"
]
}
}
]
},
"MaxSessionDuration": 3600,
"IgnoreExisting": true,
"DeletionForce": true,
"PolicyAttachments": {
"System": [
"AliyunCSManagedAutoScalerRolePolicy"
]
}
}
},
"AckCluster": {
"Type": "ALIYUN::CS::ManagedKubernetesCluster",
"DependsOn": "AliyunCSManagedAutoScalerRole",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"VSwitchIds": [
{
"Ref": "VSwitch1"
},
{
"Ref": "VSwitch2"
}
],
"PodVswitchIds": [
{
"Ref": "VSwitch1"
},
{
"Ref": "VSwitch1"
}
],
"Name": {
"Ref": "ManagedKubernetesClusterName"
},
"KubernetesVersion": "1.31.1-aliyun.1",
"ServiceCidr": "192.168.0.0/16",
"ClusterSpec": "ack.pro.small",
"LoadBalancerSpec": "slb.s2.small",
"IsEnterpriseSecurityGroup": true,
"SnatEntry": true,
"NumOfNodes": 0,
"EndpointPublicAccess": true,
"Platform": "AliyunLinux",
"Addons": [
{
"Name": "ack-node-local-dns"
},
{
"Name": "terway-eniip",
"Config": "{\"IPVlan\":\"false\",\"NetworkPolicy\":\"false\",\"ENITrunking\":\"false\"}"
},
{
"Name": "csi-plugin"
},
{
"Name": "csi-provisioner"
},
{
"Name": "storage-operator",
"Config": "{\"CnfsOssEnable\":\"false\",\"CnfsNasEnable\":\"false\"}"
},
{
"Name": "nginx-ingress-controller",
"Disabled": true
},
{
"Name": "logtail-ds",
"Config": "{\"IngressDashboardEnabled\":\"true\"}"
},
{
"Name": "alb-ingress-controller",
"Version": "",
"Config": {
"Fn::Sub": "{\"albIngress\":{\"AddressType\":\"Internet\",\"ZoneMappings\":{\"${ZoneId1}\":[\"${VSwitch1}\"], \"${ZoneId2}\":[\"${VSwitch2}\"]},\"CreateDefaultALBConfig\":true}}"
}
},
{
"Name": "ack-helm-manager"
},
{
"Name": "arms-prometheus"
}
],
"ProxyMode": "ipvs",
"DeleteOptions": [
{
"ResourceType": "ALB",
"DeleteMode": "delete"
},
{
"ResourceType": "SLB",
"DeleteMode": "delete"
},
{
"ResourceType": "SLS_Data",
"DeleteMode": "delete"
},
{
"ResourceType": "SLS_ControlPlane",
"DeleteMode": "delete"
},
{
"ResourceType": "PrivateZone",
"DeleteMode": "delete"
}
]
}
},
"NodePools": {
"Type": "ALIYUN::CS::ClusterNodePool",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"NodePoolInfo": {
"Name": "k8s-hpa-cluster-nodepool"
},
"ScalingGroup": {
"VSwitchIds": [
{
"Ref": "VSwitch1"
},
{
"Ref": "VSwitch2"
}
],
"ZoneIds": [
{
"Ref": "ZoneId1"
},
{
"Ref": "ZoneId2"
}
],
"SystemDiskCategory": "cloud_essd",
"SystemDiskPerformanceLevel": "PL0",
"SystemDiskSize": 40,
"InstanceTypes": {
"Ref": "InstanceType"
},
"LoginPassword": {
"Ref": "InstancePassword"
},
"Platform": "AliyunLinux",
"ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd"
},
"KubernetesConfig": {
"Runtime": "containerd",
"RuntimeVersion": "1.6.28"
},
"AutoScaling": {
"Enable": true,
"MinInstances": 2,
"MaxInstances": 10
}
}
},
"Sleep": {
"Type": "ALIYUN::ROS::Sleep",
"DependsOn": "NodePools",
"Properties": {
"CreateDuration": 300
}
},
"AckMetricsAdapter": {
"Type": "ALIYUN::CS::ClusterHelmApplication",
"DependsOn": "Sleep",
"Properties": {
"Namespace": "kube-system",
"ChartUrl": "https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/ack-alibaba-cloud-metrics-adapter-1.3.3.tgz",
"ClusterId": {
"Ref": "AckCluster"
},
"Name": "ack-alibaba-cloud-metrics-adapter",
"ChartValues": {
"AlibabaCloudMetricsAdapter": {
"commonLabels": "",
"replicas": 1,
"resources": {
"metricsAdapterDeployment": {
"resources": {
"limits": {
"cpu": 0.5,
"memory": "1Gi"
},
"requests": {
"cpu": "100m",
"memory": "200Mi"
}
}
},
"configReloader": {
"resources": {
"limits": {
"cpu": "20m",
"memory": "30Mi"
},
"requests": {
"cpu": "20m",
"memory": "30Mi"
}
}
}
},
"listenPort": 443,
"costWeights": {
"cpu": "1.0",
"memory": "0.0"
},
"image": {
"repository": "registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/alibaba-cloud-metrics-adapter-amd64",
"tag": "v0.2.7-f1ee5c3-aliyun",
"pullPolicy": "Always"
},
"nameOverride": "",
"fullnameOverride": "",
"service": {
"type": "ClusterIP"
},
"serviceAccountName": "ack-alibaba-cloud-metrics-adapter",
"annotations": {},
"nodeSelector": {},
"tolerations": [],
"env": [
{
"AccessKeyId": ""
},
{
"AccessKeySecret": ""
},
{
"Region": ""
}
],
"affinity": {},
"prometheus": {
"enabled": true,
"url": {},
"metricsRelistInterval": "1m",
"logLevel": 5,
"adapter": {
"rules": {
"default": false,
"custom": [
{
"seriesQuery": "container_memory_working_set_bytes{namespace!=\"\",pod!=\"\"}",
"resources": {
"overrides": {
"namespace": {
"resource": "namespace"
},
"pod": {
"resource": "pod"
}
}
},
"name": {
"matches": "^(.*)_bytes",
"as": "${1}_bytes_per_second"
},
"metricsQuery": "sum(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)"
},
{
"seriesQuery": "container_cpu_usage_seconds_total{namespace!=\"\",pod!=\"\"}",
"resources": {
"overrides": {
"namespace": {
"resource": "namespace"
},
"pod": {
"resource": "pod"
}
}
},
"name": {
"matches": "^(.*)_seconds_total",
"as": "${1}_core_per_second"
},
"metricsQuery": "sum(rate(<<.Series>>{<<.LabelMatchers>>}[1m])) by (<<.GroupBy>>)"
}
]
}
}
}
},
"ConfigReloader": {
"image": {
"repository": "registry-vpc.cn-hangzhou.aliyuncs.com/acs/configmap-reload",
"tag": "v0.0.1"
}
}
}
}
},
"InstallBackendApp": {
"Type": "ALIYUN::CS::ClusterApplication",
"DependsOn": "AckMetricsAdapter",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"YamlContent": {
"Fn::Sub": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: coffee\nspec:\n replicas: 2\n selector:\n matchLabels:\n app: coffee\n template:\n metadata:\n labels:\n app: coffee\n spec:\n containers:\n - name: coffee\n image: registry.${ALIYUN::Region}.aliyuncs.com/acs-sample/nginxdemos:latest\n ports:\n - containerPort: 80\n resources:\n limits:\n cpu: 500m\n memory: 1Gi\n requests:\n cpu: 500m\n memory: 512Mi\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: coffee-svc\nspec:\n ports:\n - port: 80\n targetPort: 80\n protocol: TCP\n selector:\n app: coffee\n type: NodePort\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: tea\nspec:\n replicas: 2\n selector:\n matchLabels:\n app: tea\n template:\n metadata:\n labels:\n app: tea\n spec:\n containers:\n - name: tea\n image: registry.${ALIYUN::Region}.aliyuncs.com/acs-sample/nginxdemos:latest\n ports:\n - containerPort: 80\n resources:\n limits:\n cpu: 500m\n memory: 1Gi\n requests:\n cpu: 500m\n memory: 512Mi\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: tea-svc\nspec:\n ports:\n - port: 80\n targetPort: 80\n protocol: TCP\n selector:\n app: tea\n type: NodePort"
}
}
},
"AlbConfig": {
"Type": "ALIYUN::CS::ClusterApplication",
"DependsOn": "InstallBackendApp",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"YamlContent": {
"Fn::Sub": "apiVersion: alibabacloud.com/v1\nkind: AlbConfig\nmetadata:\n name: k8s-hpa-alb-config\nspec:\n config:\n name: k8s-hpa-alb\n addressType: Internet\n zoneMappings:\n - vSwitchId: ${VSwitch1}\n - vSwitchId: ${VSwitch2}\n accessLogConfig:\n logProject: ${SlsProject}\n logStore: \"alb_k8s_hpa_sls_logstore\"\n listeners:\n - port: 80\n protocol: HTTP"
}
}
},
"IngressClass": {
"Type": "ALIYUN::CS::ClusterApplication",
"DependsOn": "AlbConfig",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"YamlContent": {
"Fn::Sub": "apiVersion: networking.k8s.io/v1\nkind: IngressClass\nmetadata:\n name: k8s-hpa-alb-ingress-class\nspec:\n controller: ingress.k8s.alibabacloud/alb\n parameters:\n apiGroup: alibabacloud.com\n kind: AlbConfig\n name: k8s-hpa-alb-config"
}
}
},
"Ingress": {
"Type": "ALIYUN::CS::ClusterApplication",
"DependsOn": "IngressClass",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"YamlContent": {
"Fn::Sub": "apiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n name: k8s-hpa-alb-ingress\nspec:\n ingressClassName: k8s-hpa-alb-ingress-class\n rules:\n - http:\n paths:\n - path: /tea\n pathType: ImplementationSpecific\n backend:\n service:\n name: tea-svc\n port:\n number: 80\n - path: /coffee\n pathType: ImplementationSpecific\n backend:\n service:\n name: coffee-svc\n port: \n number: 80"
}
}
},
"Hpa": {
"Type": "ALIYUN::CS::ClusterApplication",
"DependsOn": "WaitAlbIngress",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"YamlContent": {
"Fn::Sub": "apiVersion: autoscaling/v2\nkind: HorizontalPodAutoscaler\nmetadata:\n name: k8s-alb-tea-hpa\nspec:\n scaleTargetRef:\n apiVersion: apps/v1\n kind: Deployment\n name: tea\n minReplicas: 2\n maxReplicas: 10\n metrics:\n - type: External\n external:\n metric:\n name: sls_alb_ingress_qps\n selector:\n matchLabels:\n sls.project: ${SlsProject}\n sls.logstore: \"alb_k8s_hpa_sls_logstore\" \n sls.ingress.route: \"default-tea-svc-80\"\n target:\n type: AverageValue\n averageValue: 2\n - resource:\n name: cpu\n target:\n averageUtilization: 80\n type: Utilization\n type: Resource\n - resource:\n name: memory\n target:\n averageUtilization: 80\n type: Utilization\n type: Resource"
}
}
},
"WaitAlbIngress": {
"Type": "ALIYUN::ROS::Sleep",
"DependsOn": "Ingress",
"Properties": {
"CreateDuration": 120
}
},
"IngressInfo": {
"Type": "DATASOURCE::CS::ClusterApplicationResources",
"DependsOn": "WaitAlbIngress",
"Properties": {
"ClusterId": {
"Ref": "AckCluster"
},
"Kind": "Ingress",
"Namespace": "default",
"JsonPath": "$.items.[0].status.loadBalancer.ingress.[0].hostname",
"FirstMatch": true
}
}
},
"Outputs": {
"TeaUrl": {
"Description": {
"zh-cn": "tea服務訪問地址。",
"en": "The addresses of tea service."
},
"Value": {
"Fn::Sub": "http://${IngressInfo}/tea"
}
},
"CoffeeUrl": {
"Description": {
"zh-cn": "coffee服務訪問地址。",
"en": "The addresses of coffee service."
},
"Value": {
"Fn::Sub": "http://${IngressInfo}/coffee"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"SlsProjectName",
"ManagedKubernetesClusterName",
"ZoneId1",
"ZoneId2",
"InstanceType",
"InstancePassword"
]
}
],
"TemplateTags": [
"acs:technical-solution:micro:通過HPA實現容器應用的水平Auto Scaling-tech_solu_125"
],
"Hidden": [
"CommonName"
]
}
}
}更多樣本,請參考包含此資源的公用模板。