你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az aks loadbalancer

Note

此参考是 Azure CLI(版本 2.61.0 或更高版本)的 aks-preview 扩展的一部分。 该扩展将在首次运行 az aks loadbalancer 命令时自动安装。 了解更多关于扩展的信息。

用于管理托管 Kubernetes 群集中的负载均衡器配置的命令。

这些命令为 Azure Kubernetes 服务群集启用多个标准负载均衡器的功能。

命令

名称 说明 类型 Status
az aks loadbalancer add

将负载均衡器配置添加到托管 Kubernetes 群集。

Extension GA
az aks loadbalancer delete

从托管 Kubernetes 群集中删除负载均衡器配置。

Extension GA
az aks loadbalancer list

列出托管 Kubernetes 群集中的所有负载均衡器配置。

Extension GA
az aks loadbalancer rebalance-nodes

跨特定负载均衡器重新平衡节点。

Extension GA
az aks loadbalancer show

显示托管 Kubernetes 群集中特定负载均衡器配置的详细信息。

Extension GA
az aks loadbalancer update

更新托管 Kubernetes 群集中的负载均衡器配置。

Extension GA

az aks loadbalancer add

将负载均衡器配置添加到托管 Kubernetes 群集。

az aks loadbalancer add --cluster-name
                        --name
                        --primary-agent-pool-name
                        --resource-group
                        [--aks-custom-headers]
                        [--allow-service-placement {false, true}]
                        [--node-selector]
                        [--service-label-selector]
                        [--service-namespace-selector]

示例

使用特定主代理池添加负载均衡器配置

az aks loadbalancer add -g MyResourceGroup -n secondary --cluster-name MyManagedCluster --primary-agent-pool-name nodepool1

使用服务标签选择器添加负载均衡器配置

az aks loadbalancer add -g MyResourceGroup -n app-lb --cluster-name MyManagedCluster --primary-agent-pool-name nodepool2 --service-label-selector app=frontend

添加不会自动放置服务的负载均衡器配置

az aks loadbalancer add -g MyResourceGroup -n restricted-lb --cluster-name MyManagedCluster --primary-agent-pool-name nodepool3 --allow-service-placement false

使用自定义 AKS API 标头添加负载均衡器配置

az aks loadbalancer add -g MyResourceGroup -n api-lb --cluster-name MyManagedCluster --primary-agent-pool-name nodepool1 --aks-custom-headers CustomHeader=Value

必需参数

--cluster-name

托管群集的名称。

--name -n

负载均衡器配置的名称。

用于标识的负载均衡器名称。 群集中必须有一个名为“kubernetes”的配置。

--primary-agent-pool-name -p

此负载均衡器的主代理池的名称。

必需字段。 一个字符串值,该值必须指定现有代理池的 ID。 给定池中的所有节点将始终添加到此负载均衡器。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--aks-custom-headers

将自定义标头发送到 AKS API。

指定时,格式应为 Key1=Value1,Key2=Value2。

--allow-service-placement -a

是否自动将服务放置在负载均衡器上。

如果未提供,则默认值为 true。 如果手动设置为 false,则不会为服务选择外部和内部负载均衡器,除非它们明确将其作为目标。

属性
接受的值: false, true
--node-selector -d

可成为此负载均衡器成员的节点的节点标签选择器。

与此选择器匹配的节点将是此负载均衡器的可能成员。 格式为逗号分隔键=值对。

--service-label-selector -l

可放置在此负载均衡器上的服务的标签选择器。

只有与此选择器匹配的服务可以放置在此负载均衡器上。 格式为逗号分隔键=值对或表达式,如“key In value1,value2”。

--service-namespace-selector -s

可放置在此负载均衡器上的服务的命名空间标签选择器。

可以在与选择器匹配的命名空间中创建的服务放置在此负载均衡器上。 格式为逗号分隔键=值对。

全局参数
--debug

增加日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 对完整调试日志使用 --debug。

属性
默认值: False

az aks loadbalancer delete

从托管 Kubernetes 群集中删除负载均衡器配置。

az aks loadbalancer delete --cluster-name
                           --name
                           --resource-group

示例

删除负载均衡器配置

az aks loadbalancer delete -g MyResourceGroup -n secondary --cluster-name MyManagedCluster

必需参数

--cluster-name

托管群集的名称。

--name -n

要删除的负载均衡器配置的名称。

无法删除“kubernetes”负载均衡器,因为群集作需要它。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

全局参数
--debug

增加日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 对完整调试日志使用 --debug。

属性
默认值: False

az aks loadbalancer list

列出托管 Kubernetes 群集中的所有负载均衡器配置。

az aks loadbalancer list --cluster-name
                         --resource-group

示例

列出所有负载均衡器配置

az aks loadbalancer list -g MyResourceGroup --cluster-name MyManagedCluster

列出表格式的所有负载均衡器配置

az aks loadbalancer list -g MyResourceGroup --cluster-name MyManagedCluster -o table

必需参数

--cluster-name

托管群集的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

全局参数
--debug

增加日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 对完整调试日志使用 --debug。

属性
默认值: False

az aks loadbalancer rebalance-nodes

跨特定负载均衡器重新平衡节点。

az aks loadbalancer rebalance-nodes --name
                                    --resource-group
                                    [--lb-names --load-balancer-names]

必需参数

--name -n

托管群集的名称。

--resource-group -g

资源组的名称。

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--lb-names --load-balancer-names

要重新平衡的负载均衡器名称的空间分隔列表。 如果未指定,将重新均衡所有负载均衡器。

全局参数
--debug

增加日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 对完整调试日志使用 --debug。

属性
默认值: False

az aks loadbalancer show

显示托管 Kubernetes 群集中特定负载均衡器配置的详细信息。

az aks loadbalancer show --cluster-name
                         --name
                         --resource-group

示例

显示特定负载均衡器配置的详细信息

az aks loadbalancer show -g MyResourceGroup -n secondary --cluster-name MyManagedCluster

以表格式显示负载均衡器配置的详细信息

az aks loadbalancer show -g MyResourceGroup -n kubernetes --cluster-name MyManagedCluster -o table

必需参数

--cluster-name

托管群集的名称。

--name -n

要显示的负载均衡器配置的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

全局参数
--debug

增加日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 对完整调试日志使用 --debug。

属性
默认值: False

az aks loadbalancer update

更新托管 Kubernetes 群集中的负载均衡器配置。

az aks loadbalancer update --cluster-name
                           --name
                           --resource-group
                           [--aks-custom-headers]
                           [--allow-service-placement {false, true}]
                           [--node-selector]
                           [--primary-agent-pool-name]
                           [--service-label-selector]
                           [--service-namespace-selector]

示例

更新负载均衡器配置的主代理池

az aks loadbalancer update -g MyResourceGroup -n secondary --cluster-name MyManagedCluster --primary-agent-pool-name nodepool2

更新负载均衡器配置以禁用自动服务放置

az aks loadbalancer update -g MyResourceGroup -n app-lb --cluster-name MyManagedCluster --allow-service-placement false

使用新的服务选择器更新负载均衡器配置

az aks loadbalancer update -g MyResourceGroup -n app-lb --cluster-name MyManagedCluster --service-label-selector tier=frontend,environment=production

使用自定义 AKS API 标头更新负载均衡器配置

az aks loadbalancer update -g MyResourceGroup -n api-lb --cluster-name MyManagedCluster --aks-custom-headers CustomHeader=Value

必需参数

--cluster-name

托管群集的名称。

--name -n

要更新的负载均衡器配置的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

可选参数

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--aks-custom-headers

将自定义标头发送到 AKS API。

指定时,格式应为 Key1=Value1,Key2=Value2。

--allow-service-placement -a

是否自动将服务放置在负载均衡器上。

如果设置为 false,则不会为服务选择外部和内部负载均衡器,除非它们明确将其作为目标。

属性
接受的值: false, true
--node-selector -d

可成为此负载均衡器成员的节点的节点标签选择器。

与此选择器匹配的节点将是此负载均衡器的可能成员。 格式为逗号分隔键=值对。

--primary-agent-pool-name -p

此负载均衡器的主代理池的名称。

一个字符串值,该值必须指定现有代理池的 ID。 给定池中的所有节点将始终添加到此负载均衡器。

--service-label-selector -l

可放置在此负载均衡器上的服务的标签选择器。

只有与此选择器匹配的服务可以放置在此负载均衡器上。 格式为逗号分隔键=值对或表达式,如“key In value1,value2”。

--service-namespace-selector -s

可放置在此负载均衡器上的服务的命名空间标签选择器。

可以在与选择器匹配的命名空间中创建的服务放置在此负载均衡器上。 格式为逗号分隔键=值对。

全局参数
--debug

增加日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 对完整调试日志使用 --debug。

属性
默认值: False