从 Azure 上的 AMLS 使用内部负载均衡器预配 AKS

Provision AKS with internal load balancer from AMLS on Azure

我想提供一个连接到 vnet 并在 Azure 上具有内部负载平衡器的 AKS 群集。我正在使用 here 中的代码,如下所示:

import azureml.core
from azureml.core.compute import AksCompute, ComputeTarget

# Verify that cluster does not exist already
try:
    aks_target = AksCompute(workspace=ws, name=aks_cluster_name)
    print("Found existing aks cluster")

except:
    print("Creating new aks cluster")

    # Subnet to use for AKS
    subnet_name = "default"
    # Create AKS configuration
    prov_config=AksCompute.provisioning_configuration(load_balancer_type="InternalLoadBalancer")
    # Set info for existing virtual network to create the cluster in
    prov_config.vnet_resourcegroup_name = "myvnetresourcegroup"
    prov_config.vnet_name = "myvnetname"
    prov_config.service_cidr = "10.0.0.0/16"
    prov_config.dns_service_ip = "10.0.0.10"
    prov_config.subnet_name = subnet_name
    prov_config.docker_bridge_cidr = "172.17.0.1/16"

    # Create compute target
    aks_target = ComputeTarget.create(workspace = ws, name = "myaks", provisioning_configuration = prov_config)
    # Wait for the operation to complete
    aks_target.wait_for_completion(show_output = True)

但是,我收到以下错误

K8s failed to assign an IP for Load Balancer after waiting for an hour.

这是因为 AKS 群集还没有 vnet 资源组的 'network contributor' 角色吗?使它起作用的唯一方法是首先在 AMLS 之外创建 AKS,将网络贡献者角色授予 vnet 资源组,然后将 AKS 群集附加到 AMLS 并随后配置内部负载均衡器吗?

我能够通过首先创建一个没有内部负载均衡器的 AKS 资源,然后按照以下代码单独更新负载均衡器来实现它:

import azureml.core
from azureml.core.compute.aks import AksUpdateConfiguration
from azureml.core.compute import AksCompute

# ws = workspace object. Creation not shown in this snippet
aks_target = AksCompute(ws,"myaks")

# Change to the name of the subnet that contains AKS
subnet_name = "default"
# Update AKS configuration to use an internal load balancer
update_config = AksUpdateConfiguration(None, "InternalLoadBalancer", subnet_name)
aks_target.update(update_config)
# Wait for the operation to complete
aks_target.wait_for_completion(show_output = True)

不需要网络贡献者角色。