Skip to content

Commit 71d0112

Browse files
authored
Merge pull request #102389 from zr-msft/aks-alloc-port
[AKS] add AllocatedOutboundPorts and IdleTimeoutInMinutes callout
2 parents 76fe693 + 3bb797e commit 71d0112

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

articles/aks/load-balancer-standard.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2424

2525
[!INCLUDE [cloud-shell-try-it.md](../../includes/cloud-shell-try-it.md)]
2626

27-
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0.74 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
27+
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0.81 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
2828

2929
## Before you begin
3030

31-
This article assumes you have a AKS cluster with the *Standard* SKU Azure Load Balancer. If you need an AKS cluster, see the AKS quickstart [using the Azure CLI][aks-quickstart-cli] or [using the Azure portal][aks-quickstart-portal].
31+
This article assumes you have an AKS cluster with the *Standard* SKU Azure Load Balancer. If you need an AKS cluster, see the AKS quickstart [using the Azure CLI][aks-quickstart-cli] or [using the Azure portal][aks-quickstart-portal].
3232

3333
The AKS cluster service principal needs also permission to manage network resources if you use an existing subnet or resource group. In general, assign the *Network contributor* role to your service principal on the delegated resources. For more information on permissions, see [Delegate AKS access to other Azure resources][aks-sp].
3434

@@ -65,7 +65,7 @@ You can also configure the load balancer to be internal and not expose a public
6565

6666
When using a *Standard* SKU load balancer with managed outbound public IPs, which are created by default, you can scale the number of managed outbound public IPs using the *load-balancer-managed-ip-count* parameter.
6767

68-
To update an existing cluster run the following command. This parameter can also be set at cluster create-time to have multiple managed outbound public IPs.
68+
To update an existing cluster, run the following command. This parameter can also be set at cluster create-time to have multiple managed outbound public IPs.
6969

7070
```azurecli-interactive
7171
az aks update \
@@ -160,9 +160,14 @@ az aks create \
160160
--load-balancer-outbound-ip-prefixes <publicIpPrefixId1>,<publicIpPrefixId2>
161161
```
162162

163-
## Show the outbound rule for your load balancer
163+
## Configure outbound allocated ports and idle timeout
164164

165-
To show the outbound rule created in the load balancer, use [az network lb outbound-rule list][az-network-lb-outbound-rule-list] and specify the node resource group of your AKS cluster:
165+
> [!WARNING]
166+
> The following section is intended for advanced scenarios of larger scale networking or for addressing SNAT exhaustion issues with the default configurations. You must have an accurate inventory of available quota for VMs and IP addresses before changing *AllocatedOutboundPorts* or *IdleTimeoutInMinutes* from their default value in order to maintain healthy clusters.
167+
>
168+
> Altering the values for *AllocatedOutboundPorts* and *IdleTimeoutInMinutes* may significantly change the behavior of the outbound rule for your load balancer. Review the [Load Balancer outbound rules][azure-lb-outbound-rules-overview], [load Balancer outbound rules][azure-lb-outbound-rules], and [outbound connections in Azure][azure-lb-outbound-connections] before updating these values to fully understand the impact of your changes.
169+
170+
Outbound allocated ports and their idle timeouts are used for [SNAT][azure-lb-outbound-connections]. By default, the *Standard* SKU load balancer uses [automatic assignment for the number of outbound ports based on backend pool size][azure-lb-outbound-preallocatedports] and a 30-minute idle timeout for each port. To see these values, use [az network lb outbound-rule list][az-network-lb-outbound-rule-list] to show the outbound rule for the load balancer:
166171

167172
```azurecli-interactive
168173
NODE_RG=$(az aks show --resource-group myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv)
@@ -177,7 +182,46 @@ AllocatedOutboundPorts EnableTcpReset IdleTimeoutInMinutes Name
177182
0 True 30 aksOutboundRule All Succeeded MC_myResourceGroup_myAKSCluster_eastus
178183
```
179184

180-
In the example output, *AllocatedOutboundPorts* is 0. The value for *AllocatedOutboundPorts* means that SNAT port allocation reverts to automatic assignment based on backend pool size. See [Load Balancer outbound rules][azure-lb-outbound-rules] and [Outbound connections in Azure][azure-lb-outbound-connections] for more details.
185+
The example output shows the default value for *AllocatedOutboundPorts* and *IdleTimeoutInMinutes*. A value of 0 for *AllocatedOutboundPorts* sets the number of outbound ports using automatic assignment for the number of outbound ports based on backend pool size. For example, if the cluster has 50 or less nodes, 1024 ports for each node are allocated.
186+
187+
Consider changing the setting of *allocatedOutboundPorts* or *IdleTimeoutInMinutes* if you expect to face SNAT exhaustion based on the above default configuration. Each additional IP address enables 64,000 additional ports for allocation, however the Azure Standard Load Balancer does not automatically increase the ports per node when more IP addresses are added. You can change these values by setting the *load-balancer-outbound-ports* and *load-balancer-idle-timeout* parameters. For example:
188+
189+
```azurecli-interactive
190+
az aks update \
191+
--resource-group myResourceGroup \
192+
--name myAKSCluster \
193+
--load-balancer-outbound-ports 0 \
194+
--load-balancer-idle-timeout 30
195+
```
196+
197+
> [!IMPORTANT]
198+
> You must [calculate your required quota][calculate-required-quota] before customizing *allocatedOutboundPorts* to avoid connectivity or scaling issues. The value you specify for *allocatedOutboundPorts* must also be a multiple of 8.
199+
200+
You can also use the *load-balancer-outbound-ports* and *load-balancer-idle-timeout* parameters when creating a cluster, but you must also specify either *load-balancer-managed-outbound-ip-count*, *load-balancer-outbound-ips*, or *load-balancer-outbound-ip-prefixes* as well. For example:
201+
202+
```azurecli-interactive
203+
az aks create \
204+
--resource-group myResourceGroup \
205+
--name myAKSCluster \
206+
--vm-set-type VirtualMachineScaleSets \
207+
--node-count 1 \
208+
--load-balancer-sku standard \
209+
--generate-ssh-keys \
210+
--load-balancer-managed-outbound-ip-count 2 \
211+
--load-balancer-outbound-ports 0 \
212+
--load-balancer-idle-timeout 30
213+
```
214+
215+
When altering the *load-balancer-outbound-ports* and *load-balancer-idle-timeout* parameters from their default, it affects the behavior of the load balancer profile, which impacts the entire cluster.
216+
217+
### Required quota for customizing allocatedOutboundPorts
218+
You must have enough outbound IP capacity based on the number of your node VMs and desired allocated outbound ports. To validate you have enough outbound IP capacity, use the following formula:
219+
220+
*outboundIPs* \* 64,000 \> *nodeVMs* \* *desiredAllocatedOutboundPorts*.
221+
222+
For example, if you have 3 *nodeVMs*, and 50,000 *desiredAllocatedOutboundPorts*, you need to have at least 3 *outboundIPs*. It is recommended that you incorporate additional outbound IP capacity beyond what you need. Additionally, you must account for the cluster autoscaler and the possibility of node pool upgrades when calculating outbound IP capacity. For the cluster autoscaler, review the current node count and the maximum node count and use the higher value. For upgrading, account for an additional node VM for every node pool that allows upgrading.
223+
224+
When setting *IdleTimeoutInMinutes* to a different value than the default of 30 minutes, consider how long your workloads will need an outbound connection. Also consider the default timeout value for a *Standard* SKU load balancer used outside of AKS is 4 minutes. An *IdleTimeoutInMinutes* value that more accurately reflects your specific AKS workload can help decrease SNAT exhaustion caused by tying up connections no longer being used.
181225

182226
## Restrict access to specific IP ranges
183227

@@ -237,9 +281,12 @@ Learn more about Kubernetes services at the [Kubernetes services documentation][
237281
[azure-lb-comparison]: ../load-balancer/concepts-limitations.md#skus
238282
[azure-lb-outbound-rules]: ../load-balancer/load-balancer-outbound-rules-overview.md#snatports
239283
[azure-lb-outbound-connections]: ../load-balancer/load-balancer-outbound-connections.md#snat
284+
[azure-lb-outbound-preallocatedports]: ../load-balancer/load-balancer-outbound-connections.md#preallocatedports
285+
[azure-lb-outbound-rules-overview]: ../load-balancer/load-balancer-outbound-rules-overview.md
240286
[install-azure-cli]: /cli/azure/install-azure-cli
241287
[internal-lb-yaml]: internal-lb.md#create-an-internal-load-balancer
242288
[kubernetes-concepts]: concepts-clusters-workloads.md
243289
[use-kubenet]: configure-kubenet.md
244290
[az-extension-add]: /cli/azure/extension#az-extension-add
245291
[az-extension-update]: /cli/azure/extension#az-extension-update
292+
[calculate-required-quota]: #required-quota-for-customizing-allocatedoutboundports

0 commit comments

Comments
 (0)