You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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].
28
28
29
29
## Before you begin
30
30
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].
32
32
33
33
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].
34
34
@@ -65,7 +65,7 @@ You can also configure the load balancer to be internal and not expose a public
65
65
66
66
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.
67
67
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.
## Configure outbound allocated ports and idle timeout
164
164
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:
166
171
167
172
```azurecli-interactive
168
173
NODE_RG=$(az aks show --resource-group myResourceGroup --name myAKSCluster --query nodeResourceGroup -o tsv)
@@ -177,7 +182,46 @@ AllocatedOutboundPorts EnableTcpReset IdleTimeoutInMinutes Name
177
182
0 True 30 aksOutboundRule All Succeeded MC_myResourceGroup_myAKSCluster_eastus
178
183
```
179
184
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:
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.
181
225
182
226
## Restrict access to specific IP ranges
183
227
@@ -237,9 +281,12 @@ Learn more about Kubernetes services at the [Kubernetes services documentation][
0 commit comments