【问题标题】:Add nodepool to an existing AKS cluster via ARM template通过 ARM 模板将节点池添加到现有 AKS 群集
【发布时间】:2021-09-20 07:47:45
【问题描述】:

我有一个现有的 AKS 集群(我知道它的名称和其他详细信息)

是否可以使用 ARM 模板向现有 AKS 群集添加额外的节点池?

【问题讨论】:

    标签: azure azure-resource-manager azure-aks arm-template azure-sdk-.net


    【解决方案1】:

    是否可以使用 ARM 模板向现有 AKS 群集添加额外的节点池?

    是的,可以向现有 AKS 群集添加额外的节点池。

    使用资源管理器模板管理节点池

    使用 Azure 资源管理器模板创建和管理资源时,通常可以更新模板中的设置并重新部署以更新资源。对于 AKS 中的节点池,一旦创建 AKS 群集,就无法更新初始节点池配置文件。此行为意味着您无法更新现有资源管理器模板、更改节点池和重新部署。相反,您必须创建一个单独的资源管理器模板,该模板仅更新现有 AKS 群集的节点池。

    创建一个模板,例如 aks-agentpools.json 并粘贴以下示例清单。此示例模板配置以下设置:

    • 更新名为 myagentpoolLinux 节点池以运行三个节点。
    • 设置节点池中的节点运行Kubernetes版本1.15.7
    • 将节点大小定义为Standard_DS2_v2

    根据需要编辑这些值,以根据需要更新、添加或删除节点池:

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "clusterName": {
                "type": "string",
                "metadata": {
                    "description": "The name of your existing AKS cluster."
                }
            },
            "location": {
                "type": "string",
                "metadata": {
                    "description": "The location of your existing AKS cluster."
                }
            },
            "agentPoolName": {
                "type": "string",
                "defaultValue": "myagentpool",
                "metadata": {
                    "description": "The name of the agent pool to create or update."
                }
            },
            "vnetSubnetId": {
                "type": "string",
                "defaultValue": "",
                "metadata": {
                    "description": "The Vnet subnet resource ID for your existing AKS cluster."
                }
            }
        },
        "variables": {
            "apiVersion": {
                "aks": "2020-01-01"
            },
            "agentPoolProfiles": {
                "maxPods": 30,
                "osDiskSizeGB": 0,
                "agentCount": 3,
                "agentVmSize": "Standard_DS2_v2",
                "osType": "Linux",
                "vnetSubnetId": "[parameters('vnetSubnetId')]"
            }
        },
        "resources": [
            {
                "apiVersion": "2020-01-01",
                "type": "Microsoft.ContainerService/managedClusters/agentPools",
                "name": "[concat(parameters('clusterName'),'/', parameters('agentPoolName'))]",
                "location": "[parameters('location')]",
                "properties": {
                    "maxPods": "[variables('agentPoolProfiles').maxPods]",
                    "osDiskSizeGB": "[variables('agentPoolProfiles').osDiskSizeGB]",
                    "count": "[variables('agentPoolProfiles').agentCount]",
                    "vmSize": "[variables('agentPoolProfiles').agentVmSize]",
                    "osType": "[variables('agentPoolProfiles').osType]",
                    "storageProfile": "ManagedDisks",
                    "type": "VirtualMachineScaleSets",
                    "vnetSubnetID": "[variables('agentPoolProfiles').vnetSubnetId]",
                    "orchestratorVersion": "1.15.7"
                }
            }
        ]
    }
    

    使用az deployment group create 命令部署此模板,如下例所示。系统会提示您输入现有的 AKS 群集名称和位置:

    --Azure CLI

    az deployment group create \
        --resource-group myResourceGroup \
        --template-file aks-agentpools.json
    

    更多详情可以参考这个Manage Node Pools in an existing AKS Cluster using ARM


    另外,

    将专用系统节点池添加到现有 AKS 群集

    您可以将一个或多个系统节点池添加到现有 AKS 群集。

    以下命令添加了一个模式类型系统的专用节点池,默认计数为三个节点。

    az aks nodepool add \
        --resource-group myResourceGroup \
        --cluster-name myAKSCluster \
        --name systempool \
        --node-count 3 \
        --node-taints CriticalAddonsOnly=true:NoSchedule \
        --mode System
    

    有关添加专用系统的更多详细信息,请参阅此 [documentation-of-usingSystemPools-in-existing-AKS-Cluster]

    如需了解使用 ARM 模板 创建 Azure 节点池 中的每个命令详细信息,请参阅此 [MSFT Documentation],您可以清楚地了解关于每个命令。

    如果您想[使用 azure 命令工具在现有 AKS 群集中创建新节点池]

    ,请参阅此内容

    如果您想 [Deploy AKS with Node Pools and AAD authentication using ARM Templates],请参阅此处。

    【讨论】:

    猜你喜欢
    • 2020-09-13
    • 1970-01-01
    • 2021-01-08
    • 2021-09-15
    • 2015-11-26
    • 2012-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多