Skip to content

Commit 4ecf65c

Browse files
authored
Merge pull request #178865 from zr-msft/zr-aks-edit-snat-port-callout
[AKS] editing for snat port exhaustion callouts
2 parents ccd1d2c + 7b7dcde commit 4ecf65c

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

articles/aks/load-balancer-standard.md

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -191,36 +191,48 @@ az aks create \
191191
### Configure the allocated outbound ports
192192

193193
> [!IMPORTANT]
194-
> If you have applications on your cluster which are expected to establish a large number of connection to small set of destinations, e.g. many frontend instances connecting to an SQL DB, you have a scenario very susceptible to encounter SNAT Port exhaustion (running out of ports to connect from). For these scenarios it is highly recommended to increase the allocated outbound ports and outbound frontend IPs on the load balancer. See below for information on how to properly calculate these values.
194+
> If you have applications on your cluster which can establish a large number of connections to small set of destinations, for example many instances of a frontend application connecting to a database, you may have a scenario very susceptible to encounter SNAT port exhaustion. SNAT port exhaustion happens when an application runs out of outbound ports to use to establish a connection to another application or host. If you have a scenario where you may encounter SNAT port exhaustion, it is highly recommended that you increase the allocated outbound ports and outbound frontend IPs on the load balancer to prevent SNAT port exhaustion. See below for information on how to properly calculate outbound ports and outbound frontend IP values.
195195
196-
Unless otherwise specified, AKS will use the default value of Allocated Outbound Ports that Standard Load Balancer defines when configuring it. This value is **null** on the AKS API or **0** on the SLB API as shown by the below command:
196+
By default, AKS sets *AllocatedOutboundPorts* on its load balancer to `0`, which enables [automatic outbound port assignment based on backend pool size][azure-lb-outbound-preallocatedports] when creating a cluster. For example, if a cluster has 50 or fewer nodes, 1024 ports are allocated to each node. As the number of nodes in the cluster is increased, fewer ports will be available per node. To show the *AllocatedOutboundPorts* value for the AKS cluster load balancer, use `az network lb outbound-rule list`. For example:
197197

198198
```azurecli-interactive
199199
NODE_RG=$(az aks show --resource-group myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv)
200200
az network lb outbound-rule list --resource-group $NODE_RG --lb-name kubernetes -o table
201201
```
202202

203-
The previous commands will list the outbound rule for your load balancer, for example:
203+
The following example output shows that automatic outbound port assignment based on backend pool size is enabled for the cluster:
204204

205205
```console
206206
AllocatedOutboundPorts EnableTcpReset IdleTimeoutInMinutes Name Protocol ProvisioningState ResourceGroup
207207
------------------------ ---------------- ---------------------- --------------- ---------- ------------------- -------------
208208
0 True 30 aksOutboundRule All Succeeded MC_myResourceGroup_myAKSCluster_eastus
209209
```
210210

211-
This output does not mean that the cluster has 0 ports but instead that it is using [automatic outbound port assignment based on backend pool size][azure-lb-outbound-preallocatedports]. For example, if a cluster has 50 or fewer nodes, 1024 ports are allocated to each node. As the number of nodes in the cluster is increased, fewer ports will be available per node.
211+
To configure a specific value for *AllocatedOutboundPorts* and outbound IP address when creating or updating a cluster, use `load-balancer-outbound-ports` and either `load-balancer-managed-outbound-ip-count`, `load-balancer-outbound-ips`, or `load-balancer-outbound-ip-prefixes`. Before setting a specific value or increasing an existing value for either for outbound ports and outbound IP address, you must calculate the appropriate number of outbound ports and IP address. Use the following equation for this calculation rounded to the nearest integer: `64,000 ports per IP / <outbound ports per node> * <number of outbound IPs> = <maximum number of nodes in the cluster>`.
212212

213-
To define or increase the number of Allocated Outbound ports, the appropriate values for number of outbound ports and number of IPs must be calculated. The number of outbound ports is fixed per instance to the value specified here. The value for outbound ports must be a multiple of 8.
213+
When calculating the number of outbound ports and IPs and setting the values, remember:
214+
* The number of outbound ports is fixed per node based on the value you set.
215+
* The value for outbound ports must be a multiple of 8.
216+
* Adding more IPs does not add more ports to any node. It provides capacity for more nodes in the cluster.
217+
* You must account for nodes that may be added as part of upgrades, including the count of nodes specified via [maxSurge values][maxsurge].
214218

215-
Adding more IPs does not add more ports to any node - instead, it provides capacity for more nodes in the cluster. When performing this calculation, make sure to account for nodes that may be added as part of upgrades, including the count of nodes specified via [maxSurge values](upgrade-cluster.md#customize-node-surge-upgrade). The calculation for the number of IPs required is `(<maximum number of nodes in the cluster> * <outbound ports per node>) / 64000`, rounded up to the nearest integer.
219+
The following examples show how the number of outbound ports and IP addresses are affected by the values you set:
220+
- If the default values are used and the cluster has 48 nodes, each node will have 1024 ports available.
221+
- If the default values are used and the cluster scales from 48 to 52 nodes, each node will be updated from 1024 ports available to 512 ports available.
222+
- If outbound ports is set to 1,000 and outbound IP count is set to 2, then the cluster can support a maximum of 128 nodes: `64,000 ports per IP / 1,000 ports per node * 2 IPs = 128 nodes`.
223+
- If outbound ports is set to 1,000 and outbound IP count is set to 7, then the cluster can support a maximum of 448 nodes: `64,000 ports per IP / 1,000 ports per node * 7 IPs = 448 nodes`.
224+
- If outbound ports is set to 4,000 and outbound IP count is set to 2, then the cluster can support a maximum of 32 nodes: `64,000 ports per IP / 4,000 ports per node * 2 IPs = 32 nodes`.
225+
- If outbound ports is set to 4,000 and outbound IP count is set to 7, then the cluster can support a maximum of 112 nodes: `64,000 ports per IP / 4,000 ports per node * 7 IPs = 112 nodes`.
216226

217-
Examples:
218-
- If no values are supplied and the cluster has 48 nodes, each node will have 1024 ports available.
219-
- If no values are supplied and the cluster grows to 52 nodes, each node will now have 512 ports available.
220-
- If outbound ports is set to 1,000 and outbound IP count is set to 2, then the cluster can support a maximum of 128 nodes (64,000 ports per IP / 1,000 ports per node * 2 IPs = 128 nodes).
221-
- If outbound ports is set to 4,000 and outbound IP count is set to 7, then the cluster can support a maximum of 112 nodes (64,000 ports per IP / 4,000 ports per node * 7 IPs = 112 nodes).
227+
> [!IMPORTANT]
228+
> After calculating the number outbound ports and IPs, verify you have additional outbound port capacity to handle node surge during upgrades. It is critical to allocate sufficient excess ports for additional nodes needed for upgrade and other operations. AKS defaults to one buffer node for upgrade operations. If using [maxSurge values][maxsurge], multiply the outbound ports per node by your maxSurge value to determine the number of ports required. For example if you calculated you needed 4000 ports per node with 7 IP address on a cluster with a maximum of 100 nodes and a max surge of 2:
229+
> * 2 surge nodes * 4000 ports per node = 8000 ports needed for node surge during upgrades.
230+
> * 100 nodes * 4000 ports per node = 400,000 ports required for your cluster.
231+
> * 7 IPs * 64000 ports per IP = 448,000 ports available for your cluster.
232+
>
233+
> The above example shows the cluster has an excess capacity of 48,000 ports, which is sufficient to handle the 8000 ports needed for node surge during upgrades.
222234
223-
Once the values have been calculated, the following command can be used to apply them to the cluster:
235+
Once the values have been calculated and verified, you can apply those values using `load-balancer-outbound-ports` and either `load-balancer-managed-outbound-ip-count`, `load-balancer-outbound-ips`, or `load-balancer-outbound-ip-prefixes` when creating or updating a cluster. For example:
224236

225237
```azurecli-interactive
226238
az aks update \
@@ -230,25 +242,6 @@ az aks update \
230242
--load-balancer-outbound-ports 4000
231243
```
232244

233-
To check these values, assume our cluster has a maximum size of 100 nodes and calculate the number of ports required (400,000) vs. the number of ports available (448,000). This configuration would provide sufficient ports for a 100 node cluster with space for node surge during upgrades.
234-
235-
- 100 nodes * 4000 ports per node = 400,000 ports required
236-
- 7 IPs * 64000 ports per IP = 448,000 ports available.
237-
238-
> [!IMPORTANT]
239-
> You must [calculate your required quota and check the requirements][requirements] before customizing *allocatedOutboundPorts* to avoid connectivity or scaling issues. It is critical to allocate sufficient ports for additional nodes needed for upgrade and other operations. AKS defaults to one buffer node for upgrade. If using [maxSurge values](upgrade-cluster.md#customize-node-surge-upgrade), multiply the outbound ports per node by your maxSurge value to determine the number of ports required.
240-
241-
You can also use the **`load-balancer-outbound-ports`** 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:
242-
243-
```azurecli-interactive
244-
az aks create \
245-
--resource-group myResourceGroup \
246-
--name myAKSCluster \
247-
--load-balancer-sku standard \
248-
--load-balancer-managed-outbound-ip-count 2 \
249-
--load-balancer-outbound-ports 1024
250-
```
251-
252245
### Configure the load balancer idle timeout
253246

254247
When SNAT port resources are exhausted, outbound flows fail until existing flows release SNAT ports. Load Balancer reclaims SNAT ports when the flow closes and the AKS-configured load balancer uses a 30-minute idle timeout for reclaiming SNAT ports from idle flows.
@@ -424,4 +417,5 @@ Learn more about using Internal Load Balancer for Inbound traffic at the [AKS In
424417
[az-extension-update]: /cli/azure/extension#az_extension_update
425418
[use-multiple-node-pools]: use-multiple-node-pools.md
426419
[troubleshoot-snat]: #troubleshooting-snat
427-
[service-tags]: ../virtual-network/network-security-groups-overview.md#service-tags
420+
[service-tags]: ../virtual-network/network-security-groups-overview.md#service-tags
421+
[maxsurge]: upgrade-cluster.md#customize-node-surge-upgrade

0 commit comments

Comments
 (0)