Share via


az aks loadbalancer

Note

This reference is part of the aks-preview extension for the Azure CLI (version 2.61.0 or higher). The extension will automatically install the first time you run an az aks loadbalancer command. Learn more about extensions.

Commands to manage load balancer configurations in a managed Kubernetes cluster.

These commands enable the feature of multiple standard load balancers for Azure Kubernetes Service clusters.

Commands

Name Description Type Status
az aks loadbalancer add

Add a load balancer configuration to a managed Kubernetes cluster.

Extension GA
az aks loadbalancer delete

Delete a load balancer configuration from a managed Kubernetes cluster.

Extension GA
az aks loadbalancer list

List all load balancer configurations in a managed Kubernetes cluster.

Extension GA
az aks loadbalancer rebalance-nodes

Rebalance nodes across specific load balancers.

Extension GA
az aks loadbalancer show

Show details of a specific load balancer configuration in a managed Kubernetes cluster.

Extension GA
az aks loadbalancer update

Update a load balancer configuration in a managed Kubernetes cluster.

Extension GA

az aks loadbalancer add

Add a load balancer configuration to a managed Kubernetes cluster.

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]

Examples

Add a load balancer configuration with a specific primary agent pool

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

Add a load balancer configuration with service label selector

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

Add a load balancer configuration that doesn't automatically place services

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

Add a load balancer configuration with custom AKS API headers

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

Required Parameters

--cluster-name

Name of the managed cluster.

--name -n

Name of the load balancer configuration.

Load balancer name used for identification. There must be a configuration named "kubernetes" in the cluster.

--primary-agent-pool-name -p

Name of the primary agent pool for this load balancer.

Required field. A string value that must specify the ID of an existing agent pool. All nodes in the given pool will always be added to this load balancer.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

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

Send custom headers to the AKS API.

When specified, format should be Key1=Value1,Key2=Value2.

--allow-service-placement -a

Whether to automatically place services on the load balancer.

If not supplied, the default value is true. If set to false manually, both the external and internal load balancer will not be selected for services unless they explicitly target it.

Property Value
Accepted values: false, true
--node-selector -d

Node label selector for nodes that can be members of this load balancer.

Nodes that match this selector will be possible members of this load balancer. Format as comma-separated key=value pairs.

--service-label-selector -l

Label selector for services that can be placed on this load balancer.

Only services that match this selector can be placed on this load balancer. Format as comma-separated key=value pairs or expressions like "key In value1,value2".

--service-namespace-selector -s

Namespace label selector for services that can be placed on this load balancer.

Services created in namespaces that match the selector can be placed on this load balancer. Format as comma-separated key=value pairs.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az aks loadbalancer delete

Delete a load balancer configuration from a managed Kubernetes cluster.

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

Examples

Delete a load balancer configuration

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

Required Parameters

--cluster-name

Name of the managed cluster.

--name -n

Name of the load balancer configuration to delete.

The "kubernetes" load balancer cannot be deleted as it's required for cluster operation.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az aks loadbalancer list

List all load balancer configurations in a managed Kubernetes cluster.

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

Examples

List all load balancer configurations

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

List all load balancer configurations in table format

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

Required Parameters

--cluster-name

Name of the managed cluster.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az aks loadbalancer rebalance-nodes

Rebalance nodes across specific load balancers.

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

Required Parameters

--name -n

Name of the managed cluster.

--resource-group -g

Name of resource group.

Optional Parameters

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

Space-separated list of load balancer names to rebalance. If not specified, all load balancers will be rebalanced.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az aks loadbalancer show

Show details of a specific load balancer configuration in a managed Kubernetes cluster.

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

Examples

Show details of a specific load balancer configuration

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

Show details of a load balancer configuration in table format

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

Required Parameters

--cluster-name

Name of the managed cluster.

--name -n

Name of the load balancer configuration to show.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False

az aks loadbalancer update

Update a load balancer configuration in a managed Kubernetes cluster.

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]

Examples

Update a load balancer configuration's primary agent pool

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

Update a load balancer configuration to disable automatic service placement

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

Update a load balancer configuration with new service selector

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

Update a load balancer configuration with custom AKS API headers

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

Required Parameters

--cluster-name

Name of the managed cluster.

--name -n

Name of the load balancer configuration to update.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

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

Send custom headers to the AKS API.

When specified, format should be Key1=Value1,Key2=Value2.

--allow-service-placement -a

Whether to automatically place services on the load balancer.

If set to false, both the external and internal load balancer will not be selected for services unless they explicitly target it.

Property Value
Accepted values: false, true
--node-selector -d

Node label selector for nodes that can be members of this load balancer.

Nodes that match this selector will be possible members of this load balancer. Format as comma-separated key=value pairs.

--primary-agent-pool-name -p

Name of the primary agent pool for this load balancer.

A string value that must specify the ID of an existing agent pool. All nodes in the given pool will always be added to this load balancer.

--service-label-selector -l

Label selector for services that can be placed on this load balancer.

Only services that match this selector can be placed on this load balancer. Format as comma-separated key=value pairs or expressions like "key In value1,value2".

--service-namespace-selector -s

Namespace label selector for services that can be placed on this load balancer.

Services created in namespaces that match the selector can be placed on this load balancer. Format as comma-separated key=value pairs.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False