Cria um node pool para um cluster.
Sintaxe
{
"Type": "ALIYUN::CS::ClusterNodePool",
"Properties": {
"TeeConfig": Map,
"ClusterId": String,
"NodePoolInfo": Map,
"KubernetesConfig": Map,
"Count": Integer,
"Management": Map,
"SystemDiskEncrypted": Boolean,
"AutoScaling": Map,
"ScalingGroup": Map
}
}
Propriedades
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrições |
ClusterId | String | Sim | Não | ID do cluster. | Chame a API DescribeClustersV1 para consultar o ID do cluster. |
ScalingGroup | Map | Sim | Sim | Configuração do grupo de dimensionamento do node pool. | Chame a API DescribeClusterNodePools para consultar a configuração do grupo de dimensionamento do node pool. Para mais informações, consulte Sintaxe de ScalingGroup e Propriedades de ScalingGroup. |
AutoScaling | Map | Não | Não | Configuração de auto scaling. | Para mais informações, consulte Sintaxe de AutoScaling e Propriedades de AutoScaling. |
Count | Integer | Não | Sim | Número de nós no node pool. | Nenhuma |
KubernetesConfig | Map | Não | Sim | Configuração do cluster. | Para mais informações, consulte Sintaxe de KubernetesConfig e Propriedades de KubernetesConfig. |
Management | Map | Não | Não | Configuração do node pool gerenciado. | Para mais informações, consulte Sintaxe de Management e Propriedades de Management. |
NodePoolInfo | Map | Não | Não | Configuração do node pool. | Para mais informações, consulte Sintaxe de NodePoolInfo e Propriedades de NodePoolInfo. |
SystemDiskEncrypted | Boolean | Não | Sim | Define se o disco do sistema deve ser criptografado. | Valores válidos:
Padrão: false. |
TeeConfig | Map | Não | Não | Configuração para um cluster Kubernetes de computação confidencial. | Para mais informações, consulte Sintaxe de TeeConfig e Propriedades de TeeConfig. |
Sintaxe de TeeConfig
"TeeConfig": {
"TeeEnable": Boolean
}
Propriedades de TeeConfig
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
TeeEnable | Boolean | Sim | Não | Indica se o cluster Kubernetes de computação confidencial está ativado. | Valores válidos:
|
Sintaxe de NodePoolInfo
"NodePoolInfo": {
"ResourceGroupId": String,
"Name": String
}
Propriedades de NodePoolInfo
|
Propriedade |
Tipo |
Obrigatório |
Atualização permitida |
Descrição |
Restrição |
|
Name |
String |
Sim |
Não |
Nome do node pool. |
Nenhuma |
|
ResourceGroupId |
String |
Não |
Não |
ID do grupo de recursos ao qual o node pool pertence. |
Nenhuma |
Sintaxe de KubernetesConfig
"KubernetesConfig": {
"CpuPolicy": String,
"Runtime": String,
"CmsEnabled": Boolean,
"UserData": String,
"NodeNameMode": String,
"RuntimeVersion": String,
"Labels": List,
"Unschedulable": Boolean,
"Taints": List
}
Propriedades de KubernetesConfig
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
Runtime | String | Sim | Sim | Nome do runtime de contêiner. | Nenhuma |
RuntimeVersion | String | Sim | Sim | Versão do runtime de contêiner. | Nenhuma |
CpuPolicy | String | Não | Sim | Política de gerenciamento de CPU para os nós. | Políticas suportadas quando a versão do cluster é 1.12.6 ou posterior:
|
CmsEnabled | Boolean | Não | Sim | Indica se o Cloud Monitor deve ser instalado nos nós ECS. | Após instalar o Cloud Monitor, visualize métricas de monitoramento das instâncias ECS criadas no console do Cloud Monitor. Recomendamos ativar este recurso. Valores válidos:
|
NodeNameMode | String | Não | Não | Nome personalizado do nó. | O nome do nó consiste em três partes: prefixo + substring do endereço IP do nó + sufixo.
|
Labels | List | Não | Sim | Rótulos para os nós do cluster Kubernetes. | Para mais informações, consulte Sintaxe de Labels e Propriedades de Labels. |
UserData | String | Não | Sim | Dados personalizados para os nós. | Nenhuma |
Unschedulable | Boolean | Não | Sim | Indica se os nós recém-adicionados devem ser agendados. | Valores válidos:
|
Taints | List | Não | Não | Configuração de taints. | Para mais informações, consulte Sintaxe de Taints e Propriedades de Taints. |
Sintaxe de Labels
"Labels": [
{
"Value": String,
"Key": String
}
]
Propriedades de Labels
|
Propriedade |
Tipo |
Obrigatório |
Atualização permitida |
Descrição |
Restrição |
|
Value |
String |
Sim |
Sim |
Valor da tag. |
Nenhuma |
|
Key |
String |
Sim |
Sim |
Chave da tag. |
Nenhuma |
Sintaxe de Taints
"Taints": [
{
"Value": String,
"Effect": String,
"Key": String
}
]
Propriedades de Taints
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
Value | String | Sim | Não | Valor do taint. | Nenhuma |
Key | String | Sim | Não | Nome do taint. | Nenhuma |
Effect | String | Não | Não | Política de agendamento. | Valores válidos:
|
Sintaxe de Management
"Management": {
"UpgradeConfig": Map,
"AutoRepair": Boolean,
"Enable": Boolean
}
Propriedades de Management
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
Enable | Boolean | Sim | Não | Indica se o node pool gerenciado está ativado. | Valores válidos:
|
AutoRepair | Boolean | Não | Não | Indica se o reparo automático está ativado. | Este parâmetro só tem efeito quando Enable está definido como true. Valores válidos:
|
UpgradeConfig | Map | Não | Não | Configuração para atualizações automáticas. | Esta propriedade só tem efeito quando Enable está definido como true. Para mais informações, consulte Sintaxe de UpgradeConfig e Propriedades de UpgradeConfig. |
Sintaxe de UpgradeConfig
"UpgradeConfig": {
"AutoUpgrade": Boolean,
"SurgePercentage": Integer,
"Surge": Integer,
"MaxUnavailable": Integer
}
Propriedades de UpgradeConfig
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
AutoUpgrade | Boolean | Não | Não | Indica se as atualizações automáticas estão ativadas. | Valores válidos:
|
SurgePercentage | Integer | Não | Não | Porcentagem de nós extras. | Especifique SurgePercentage ou Surge, mas não ambos. |
Surge | Integer | Não | Não | Número de nós extras. | Especifique SurgePercentage ou Surge, mas não ambos. |
MaxUnavailable | Integer | Não | Não | Número máximo de nós indisponíveis. | Valores válidos: 1 a 1000. Valor padrão: 1. |
Sintaxe de AutoScaling
"AutoScaling": {
"EipBandwidth": Integer,
"Type": String,
"IsBondEip": Boolean,
"MinInstances": Integer,
"Enable": Boolean,
"MaxInstances": Integer,
"EipInternetChargeType": String
}
Propriedades de AutoScaling
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
Enable | Boolean | Sim | Não | Indica se o auto scaling está ativado. | Valores válidos:
|
EipBandwidth | Integer | Não | Não | Largura de banda de pico do EIP. | Nenhuma |
EipInternetChargeType | String | Não | Não | Método de faturamento do EIP. | Valores válidos:
|
IsBondEip | Boolean | Não | Não | Indica se um EIP deve ser vinculado. | Valores válidos:
|
MinInstances | Integer | Não | Não | Número mínimo de instâncias no grupo de dimensionamento. | Nenhuma |
MaxInstances | Integer | Não | Não | Número máximo de instâncias no grupo de dimensionamento. | Nenhuma |
Type | String | Não | Não | Tipo de auto scaling. | Valores válidos (por tipo de instância):
|
Sintaxe de 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
}
Propriedades de ScalingGroup
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
InstanceTypes | List | Não | Sim | Tipos de instância para instâncias spot. | Nenhuma |
SystemDiskSize | Integer | Sim | Sim | Tamanho do disco do sistema para os nós. | Unidade: GiB. Valores válidos: 40 a 500. |
VSwitchIds | List | Sim | Sim | IDs dos vSwitches. | Nenhuma |
AutoRenew | Boolean | Não | Sim | Indica se a renovação automática está ativada para os nós no node pool. | Este parâmetro só tem efeito quando InstanceChargeType está definido como PrePaid. Valores válidos:
|
AutoRenewPeriod | Integer | Não | Sim | Período de renovação automática para os nós no node pool. | Este parâmetro só tem efeito quando InstanceChargeType está definido como PrePaid e AutoRenew como true. Nesse caso, AutoRenewPeriod é obrigatório. Quando PeriodUnit está definido como Month, os valores válidos são:
|
CompensateWithOnDemand | Boolean | Não | Sim | Quando MultiAzPolicy está definido como COST_OPTIMIZED, especifica se instâncias sob demanda devem ser criadas automaticamente caso não seja possível criar instâncias spot suficientes devido a restrições de preço ou estoque. | Valores válidos:
|
DataDisks | List | Não | Sim | Configuração de disco de dados para os nós no node pool. | Para mais informações, consulte Sintaxe de DataDisks e Propriedades de DataDisks. |
InstanceChargeType | String | Não | Sim | Método de faturamento para os nós no node pool. | Valores válidos:
|
ImageId | String | Não | Sim | ID da imagem personalizada. | A imagem fornecida pelo sistema é usada por padrão. |
OnDemandPercentageAboveBaseCapacity | Integer | Não | Sim | Porcentagem de instâncias sob demanda entre as instâncias que excedem OnDemandBaseCapacity. | Valores válidos: 0 a 100. |
OnDemandBaseCapacity | Integer | Não | Sim | Número mínimo de instâncias sob demanda necessário no grupo de dimensionamento. | Valores válidos: 0 a 1000. Se o número de instâncias sob demanda for menor que este valor, a criação de instâncias sob demanda terá prioridade. |
Platform | String | Não | Sim | Sistema operacional. | Valores válidos:
|
Period | Integer | Não | Sim | Período de renovação automática para os nós no node pool. Este parâmetro só tem efeito quando você seleciona assinatura e renovação automática. | Quando PeriodUnit está definido como Month, os valores válidos são:
|
PeriodUnit | String | Não | Sim | Ciclo de faturamento para os nós no node pool. | Especifique este parâmetro quando InstanceChargeType estiver definido como PrePaid. Valores válidos:
|
LoginPassword | String | Não | Sim | Senha de logon SSH. | Especifique KeyPair ou LoginPassword, mas não ambos. Requisitos de senha: Deve ter de 8 a 30 caracteres e conter pelo menos três dos seguintes tipos de caracteres: letras, dígitos e caracteres especiais |
MultiAzPolicy | String | Não | Sim | Política de dimensionamento para grupos de dimensionamento multizona. | Valores válidos:
|
KeyPair | String | Não | Sim | Nome do par de chaves para logon sem senha. | Especifique KeyPair ou LoginPassword, mas não ambos. Nota Se você criar um node pool gerenciado, apenas KeyPair é suportado. |
SecurityGroupId | String | Não | Sim | ID do grupo de segurança. | Nenhuma |
SpotInstanceRemedy | Boolean | Não | Sim | Indica se instâncias spot devem ser usadas. | Valores válidos:
Para mais informações, consulte Create spot instances. |
SystemDiskPerformanceLevel | String | Não | Sim | Define o nível de desempenho para o disco em nuvem. | Valores válidos:
Para mais informações, consulte Enterprise SSD. |
SpotStrategy | String | Não | Sim | Tipo de instância spot. | Valores válidos:
Para mais informações, consulte Use spot instances. |
SpotPriceLimit | List | Não | Sim | Preço horário máximo para as instâncias. | O número máximo de casas decimais é 3. Este parâmetro só tem efeito quando SpotStrategy está definido como SpotWithPriceLimit. Para mais informações, consulte Sintaxe de SpotPriceLimit e Propriedades de SpotPriceLimit. |
SpotInstancePools | Integer | Não | Sim | Número de tipos de instância disponíveis. O grupo de dimensionamento cria instâncias spot nesses tipos de instância de forma otimizada para custos. | Valores válidos: 1 a 10. |
ScalingPolicy | String | Não | Sim | Modo de dimensionamento para o grupo de dimensionamento. | Valores válidos:
|
SystemDiskCategory | String | Não | Sim | Tipo do disco do sistema para os nós. | Valores válidos:
|
InternetChargeType | String | Não | Sim | Método de faturamento para acesso à rede pública. | Valores válidos:
|
InternetMaxBandwidthOut | Integer | Não | Sim | Largura de banda pública de saída máxima. | Unidade: Mbit/s. Valores válidos: 1 a 100 Mbit/s. |
RdsInstances | List | Não | Sim | IDs das instâncias RDS. | Nenhuma |
Tags | List | Não | Sim | Adicione tags apenas a instâncias ECS. | As chaves de tag não podem ser duplicadas. O comprimento máximo de uma chave de tag é de 128 caracteres. Chaves e valores de tag não podem começar com Para mais informações, consulte Sintaxe de Tags e Propriedades de Tags. |
ZoneIds | List | Não | Sim | IDs das zonas. | Nenhuma |
SocEnabled | Boolean | Não | Não | Indica se o endurecimento de segurança MLPS está ativado. | Nenhuma |
ImageType | String | Não | Não | Tipo da imagem do sistema operacional. | Especifique este parâmetro ou o parâmetro Platform. |
InstancePatterns | List | Não | Sim | Configurações de atributos da instância. | Para mais informações, consulte Propriedades de InstancePatterns. |
SecurityHardeningOs | Boolean | Não | Não | Endurecimento de segurança do Alibaba Cloud OS. | Valores válidos:
Valor padrão: |
Sintaxe de InstancePatterns
"InstancePatterns": [
{
"CpuArchitectures": List,
"MaxCpuCores": Integer,
"MinMemorySize": Integer,
"Memory": Integer,
"InstanceFamilyLevel": String,
"MinCpuCores": Integer,
"Cores": Integer,
"InstanceTypeFamilies": List,
"InstanceCategories": List,
"ExcludedInstanceTypes": List,
"MaxMemorySize": Integer
}
]
Propriedades de InstancePatterns
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
CpuArchitectures | List | Não | Não | Arquitetura de CPU da instância. | Valores válidos:
|
MaxCpuCores | Integer | Não | Não | Número máximo de núcleos vCPU para o tipo de instância. | Nenhuma |
MinMemorySize | Integer | Não | Não | Tamanho mínimo de memória para o tipo de instância. | Unidade: GiB. |
Memory | Integer | Não | Não | Tamanho de memória para o tipo de instância. | Unidade: GiB. |
InstanceFamilyLevel | String | Não | Não | Nível da família de instâncias. | Nenhuma |
MinCpuCores | Integer | Não | Não | Número mínimo de núcleos vCPU para o tipo de instância. | Nenhuma |
Cores | Integer | Não | Não | Número de núcleos vCPU para o tipo de instância. | Nenhuma |
InstanceTypeFamilies | List | Não | Não | Famílias de instâncias a serem usadas. | Nenhuma |
InstanceCategories | List | Não | Não | Classificação da instância. | Nenhuma |
ExcludedInstanceTypes | List | Não | Não | Tipos de instância a serem excluídos. | Nenhuma |
MaxMemorySize | Integer | Não | Não | Tamanho máximo de memória para o tipo de instância. | Unidade: GiB. |
Sintaxe de DataDisks
"DataDisks": [
{
"Category": String,
"Encrypted": Boolean,
"PerformanceLevel": String,
"Size": Integer,
"AutoSnapshotPolicyId": String,
"Categories": List
}
]
Propriedades de DataDisks
Propriedade | Tipo | Obrigatório | Atualização permitida | Descrição | Restrição |
AutoSnapshotPolicyId | String | Não | Sim | ID da política de snapshot automático. Os discos passam por backup automático de acordo com a política. | Padrão: vazio. Nenhum backup automático é realizado. |
Category | String | Não | Sim | Tipo do disco de dados. | Valores válidos:
|
Encrypted | Boolean | Não | Sim | Indica se o disco de dados deve ser criptografado. | Valores válidos:
|
PerformanceLevel | String | Não | Sim | Nível de desempenho do disco. | Valores válidos:
Para mais informações, consulte Enterprise SSD. |
Size | Integer | Não | Sim | Tamanho do disco de dados. | Valores válidos: 40 a 32768. Valor padrão: 120. Unidade: GiB. |
Categories | List | Não | Não | Lista de tipos de disco de dados. | Nenhuma |
Sintaxe de SpotPriceLimit
"SpotPriceLimit": [
{
"PriceLimit": Number,
"InstanceType": String
}
]
Propriedades de SpotPriceLimit
|
Propriedade |
Tipo |
Obrigatório |
Atualização permitida |
Descrição |
Restrição |
|
PriceLimit |
Number |
Sim |
Sim |
Limite de preço da instância preemptível. |
Nenhuma |
|
InstanceType |
String |
Sim |
Sim |
Tipo da instância preemptível. |
Nenhuma |
Sintaxe de Tags
"Tags": [
{
"Value": String,
"Key": String
}
]
Propriedades de Tags
|
Nome da propriedade |
Tipo |
Obrigatório |
Atualização permitida |
Descrição |
Restrição |
|
Value |
String |
Sim |
Sim |
Valor da tag. |
Nenhuma |
|
Key |
String |
Sim |
Sim |
Chave da tag. |
Nenhuma |
Valores de retorno
Fn::GetAtt
NodePoolId: ID do node pool do cluster.
Exemplos
Exemplo 1: Criar um node pool com parâmetros fixos.
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"
]
}
}
}
}Exemplo 2: Criar um node pool com parâmetros dinâmicos.
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: Availability Zone 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: Availability Zone 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: Instance Type
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: >-
The logon password for the server. The password must be 8 to 30 characters in length and contain characters from at least three of the following categories: uppercase letters, lowercase letters, digits, and special characters from the following set: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
Label:
en: Instance Password
zh-cn: Instance Password
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 'The password must be 8 to 30 characters in length and contain characters from at least three of the following categories: uppercase letters, lowercase letters, digits, and special characters from the following set: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
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: The endpoint of the coffee service.
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": "Zone 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": "Zone 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": "Instance Type"
}
},
"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": "Server logon password. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
},
"Label": {
"en": "Instance Password",
"zh-cn": "Instance Password"
},
"ConstraintDescription": {
"en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/"
},
"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": "The endpoint of the coffee service.",
"en": "The addresses of coffee service."
},
"Value": {
"Ref": "NodePools"
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ClusterId",
"VpcId",
"ZoneId1",
"VSwitchId1",
"ZoneId2",
"VSwitchId2",
"InstanceType",
"InstancePassword"
]
}
]
}
}
}Exemplo 3: Criar um cluster Kubernetes gerenciado e configurar uma VPC e um node pool.
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: Create a managed Kubernetes cluster, configure a VPC, a node pool, a Horizontal Pod Autoscaler (HPA), and Simple Log Service to enable automatic scaling and monitoring for containerized applications.
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: Name of the SLS project
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: The name must be 3 to 36 characters in length. It must start and end with a lowercase letter or a digit. It can contain lowercase letters, digits, and hyphens (-).
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 managed cluster name
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: Zone 1
ZoneId2:
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
AssociationPropertyMetadata:
ExclusiveTo:
- ZoneId1
Label:
en: Availability Zone
zh-cn: Zone 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: Instance Type
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: >-
Server logon password. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
Label:
en: Instance Password
zh-cn: Instance Password
ConstraintDescription:
en: >-
Length 8-30, must contain three(Capital letters, lowercase letters,
numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)
zh-cn: 'The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
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: ACK uses this role to access your resources in other Alibaba Cloud services.
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: The endpoint of the tea service.
en: The addresses of tea service.
Value:
'Fn::Sub': http://${IngressInfo}/tea
CoffeeUrl:
Description:
zh-cn: The endpoint of the coffee service.
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:Implement horizontal scaling for containerized applications using HPA-tech_solu_125
Hidden:
- CommonName{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "Create a managed Kubernetes cluster, configure a VPC, a node pool, a Horizontal Pod Autoscaler (HPA), and Simple Log Service to enable automatic scaling and monitoring for containerized applications.",
"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": "Name of the SLS project"
},
"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": "The name must be 3 to 36 characters in length. It must start and end with a lowercase letter or a digit. It can contain lowercase letters, digits, and hyphens (-)."
},
"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 managed cluster name"
},
"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": "Zone 1"
}
},
"ZoneId2": {
"Type": "String",
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"AssociationPropertyMetadata": {
"ExclusiveTo": [
"ZoneId1"
]
},
"Label": {
"en": "Availability Zone",
"zh-cn": "Zone 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": "Instance Type"
}
},
"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": "Server logon password. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
},
"Label": {
"en": "Instance Password",
"zh-cn": "Instance Password"
},
"ConstraintDescription": {
"en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)",
"zh-cn": "The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
},
"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": "ACK uses this role to access your resources in other Alibaba Cloud services.",
"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": "The endpoint of the tea service.",
"en": "The addresses of tea service."
},
"Value": {
"Fn::Sub": "http://${IngressInfo}/tea"
}
},
"CoffeeUrl": {
"Description": {
"zh-cn": "The endpoint of the coffee service.",
"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:Implement horizontal scaling for containerized applications using HPA-tech_solu_125"
],
"Hidden": [
"CommonName"
]
}
}
}Para mais exemplos, consulte Modelos públicos que contêm este recurso.