启用 Windows 节点池功能

> 适用于:Azure 本地版本 2509 或更高版本上的 AKS。

虚拟硬盘(VHD)充当 AKS 群集中 Kubernetes 节点的基本操作系统映像。 从 Azure 本地版本 2509 开始,默认情况下,Azure 本地实例上仅下载 Azure Linux VHD。 Azure Linux VHD 用于在 AKS Arc 群集上创建默认的 Linux 节点池。 对于基于 Windows 的工作负载,AKS Arc 支持 Windows Server 2019 和 Windows Server 2022 映像,可用于创建相应的 Windows 节点池;但是,这些 VHD 默认不可用,必须先下载,然后才能创建基于 Windows 的节点池。 默认情况下禁用 Windows 节点池功能可确保不必要地下载基于 Windows 的 OS 映像,并帮助节省带宽和存储空间。

重要

在 Azure 本地版本 2509 及更高版本中默认禁用 Windows 节点池功能后,如果你有 Windows 节点池,并且你尝试发出命令(或aksarc upgradeaksarc updateaksarc nodepool updateaksarc nodepool add)失败,并显示一条错误消息,指出“Windows 节点池功能已禁用”。然后,在继续执行这些作之前,系统会显式要求你启用此功能。

先决条件

开始创建 Windows 节点池之前,请确保满足以下先决条件:

  • Azure 本地已部署。 仅当部署了 Azure 本地版本 2509 或更高版本时,本文才适用。 从版本 2509 开始,Windows VHD 默认处于禁用状态。 如果使用的是早期版本,可以继续 创建 Windows 节点池
  • 用于更新 Azure 本地配置的 Azure RBAC 权限。 请确保具有以下角色。 有关详细信息,请参阅 部署所需的权限
    • Azure 本地管理员
    • 读取者
  • 自定义位置。 自定义位置的名称。 自定义位置是在 Azure 本地部署期间配置的。 如果使用的是 Azure 门户,请转到 Azure 本地系统资源的 “概述 ”页。 在 “概要” 部分中,应会看到群集的自定义位置名称。
  • Azure 资源组。 用于部署 Azure Local 的 Azure 资源组。
  • 直接或通过远程 PowerShell 访问 Azure 本地实例上的至少一个节点。

在 AKS Arc 群集上启用 Windows 节点池功能

若要在 AKS Arc 群集上启用 Windows 节点池功能,请使用 Support.AksArc PowerShell 模块。 本模块提供 AKS Arc 环境中的诊断和修正工具。 通过运行其命令,可以激活 Windows 节点池功能并启动所需 Windows VHD 的下载,从而可以创建基于 Windows 的节点池。

步骤 1:连接到 Azure 本地节点

按照客户端计算机上的这些步骤连接到其中一个 Azure 本地节点。

  1. 在用于连接到系统的客户端上以管理员身份运行 PowerShell。

  2. 在 Azure Local 实例上的一台计算机上打开远程 PowerShell 会话。 运行以下命令,并在出现提示时输入您的计算机的凭据:

    $cred = Get-Credential
    Enter-PSSession -ComputerName "<Computer IP>" -Credential $cred 
    

    注释

    使用部署用户帐户凭据登录。 这是在准备 Active Directory 时创建的帐户,用于部署 Azure 本地。

    展开此部分以查看示例输出。

    下面是示例输出:

    cmdlet Get-Credential at command pipeline position 1
    Supply values for the following parameters:
    Credential
    
    Enter-PSSession -ComputerName "100.100.100.10" -Credential $cred
    
    [100.100.100.10]: PS C:\Users\Administrator\Documents>
    

步骤 2:在群集上启用 Windows 节点池功能

在远程 PowerShell 会话中,登录到 Azure 本地实例所在的订阅:

az login --use-device-code --tenant <Azure tenant ID>
az account set -s <subscription ID>

使用以下命令安装 Support.AksArc 模块:

Install-Module -Name Support.AksArc
Import-Module Support.AksArc -Force

然后,可以运行以下命令来启用 Windows 节点池功能并下载与 Windows 相关的 VHD:

Invoke-SupportAksArcRemediation_EnableWindowsNodepool -Verbose

这将启用 Windows 节点池功能并开始下载 Windows VHD。 这可能需要一些时间,具体取决于 Azure 本地实例上可用的网络带宽。

步骤 3:检查 Windows VHD 是否已准备就绪

运行以下命令,检查是否已下载并准备好使用 Windows VHD:

$customlocationName = <The custom location name for Azure Local>
$resourceGroup = <The Azure resource group in which Azure Local is deployed>

az aksarc get-versions --resource-group $resourceGroup --custom-location $customlocationName

对于您打算使用的 Kubernetes 版本,请查找标有osType=WindowsosSKU字段的正确 Windows SKU,并确保ready状态是true

...
         "1.29.4": { 
            "readiness": [ 
              { 
                "errorMessage": null, 
                "osSku": "CBLMariner", 
                "osType": "Linux", 
                "ready": true 
              }, 
              { 
                "errorMessage": null, 
                "osSku": "Windows2019", 
                "osType": "Windows", 
                "ready": true 
              }, 
              { 
                "errorMessage": null, 
                "osSku": "Windows2022", 
                "osType": "Windows", 
                "ready": true 
              } 
            ], 
            "upgrades": null 
          } 
...

VHD 显示为 readytrue 后,即可创建 Windows 节点池,并部署基于 Windows 的工作负载。

在 AKS Arc 群集上禁用 Windows 节点池功能

如果不再需要在 AKS Arc 群集上使用 Windows 节点池,则可以禁用 Windows 节点池功能。 禁用此功能会从 Azure 本地实例中删除 Windows VHD,并将阻止对 Windows 节点池执行任何进一步的操作。 如果有现有的 Windows 节点池,必须先删除它们,然后才能禁用此功能。

步骤 1:删除现有的 Windows 节点池

如果打算在群集上禁用 Windows 节点池功能,建议删除已有的任何 Windows 节点池。 可以从 Azure 门户或使用 CLI 删除 Windows 节点池,如下所示:

az aksarc nodepool delete --name "<nodepool-name>" --cluster-name "<cluster-name>" --resource-group $resourceGroup 

步骤 2:禁用群集上的 Windows 节点池功能

若要禁用 Windows 节点池功能,必须访问 Azure 本地节点。 首先, 连接到 Azure 本地节点

在远程 PowerShell 会话中,先登录到 Azure,然后登录到包含 Azure 本地实例的订阅。

az login --use-device-code --tenant <Azure tenant ID>
az account set -s <subscription ID>

使用以下命令安装 Support.AksArc 模块:

Install-Module -Name Support.AksArc
Import-Module Support.AksArc -Force

然后,可以运行以下命令来禁用 Windows 节点池功能,并从 Azure 本地实例中删除与 Windows 相关的 VHD。

Invoke-SupportAksArcRemediation_DisableWindowsNodepool -Verbose

此命令禁用 Windows 节点池功能并删除现有的 Windows VHD。

步骤 3:验证 Windows VHD 是否不再可用

接下来,运行以下命令,检查 Windows 节点池是否已禁用。 可以看到该 errorMessage 参数显示 Windows 节点池功能已禁用,并且对于每个 Kubernetes 版本,该 ready 参数显示为 false

az aksarc get-versions --resource-group $resourceGroup --custom-location $customlocationName
...
     - patchVersion: 1.29.4 
          readiness: 
          - osSku: CBLMariner 
            osType: Linux 
            ready: true 
          - errorMessage: Windows nodepool feature is disabled 
            isDisabled: true 
            osSku: Windows2019 
            osType: Windows 
            ready: false 
          - errorMessage: Windows nodepool feature is disabled 
            isDisabled: true 
            osSku: Windows2022 
            osType: Windows 
            ready: false 
....

可以验证是否已从 Azure 本地存储路径中删除 Windows VHD。 删除可能需要一段时间,因此在检查前等待大约 30 分钟。 必须检查所有存储路径,因为 Windows VHD 以轮循机制方式分配给存储路径,具体取决于可用的存储容量。

后续步骤