Skip to content

Commit 6c53331

Browse files
Merge pull request #179345 from phealy/pahealy/aks-nat-gateway
AKS NAT Gateway - Add user assigned NAT gateway example
2 parents 35c0976 + 852356d commit 6c53331

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

articles/aks/nat-gateway.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ az group create --name myresourcegroup --location southcentralus
5555
```
5656

5757
```azurecli-interactive
58-
az aks create --resource-group myresourcegroup
59-
--name natcluster \
58+
az aks create \
59+
--resource-group myresourcegroup \
60+
--name natcluster \
6061
--node-count 3 \
6162
--outbound-type managedNATGateway \
6263
--nat-gateway-managed-outbound-ip-count 2 \
@@ -76,6 +77,76 @@ az aks update \
7677
--nat-gateway-managed-outbound-ip-count 5
7778
```
7879

80+
## Create an AKS cluster with a user-assigned NAT Gateway
81+
To create an AKS cluster with a user-assigned NAT Gateway, use `--outbound-type userAssignedNATGateway` when running `az aks create`. This configuration requires bring-your-own networking (via [Kubenet][byo-vnet-kubenet] or [Azure CNI][byo-vnet-azure-cni]) and that the NAT Gateway is preconfigured on the subnet. The following commands create the required resources for this scenario. Make sure to run them all in the same session so that the values stored to variables are still available for the `az aks create` command.
82+
83+
1. Create the resource group:
84+
```azurecli-interactive
85+
az group create --name myresourcegroup \
86+
--location southcentralus
87+
```
88+
89+
2. Create a managed identity for network permissions and store the ID to `$IDENTITY_ID` for later use:
90+
```azurecli-interactive
91+
IDENTITY_ID=$(az identity create \
92+
--resource-group myresourcegroup \
93+
--name natclusterid \
94+
--location southcentralus \
95+
--query id \
96+
--output tsv)
97+
```
98+
99+
3. Create a public IP for the NAT gateway:
100+
```azurecli-interactive
101+
az network public-ip create \
102+
--resource-group myresourcegroup \
103+
--name mynatgatewaypip \
104+
--location southcentralus \
105+
--sku standard
106+
```
107+
108+
4. Create the NAT gateway:
109+
```azurecli-interactive
110+
az network nat gateway create \
111+
--resource-group myresourcegroup \
112+
--name mynatgateway \
113+
--location southcentralus \
114+
--public-ip-addresses mynatgatewaypip
115+
```
116+
117+
5. Create a virtual network:
118+
```azurecli-interactive
119+
az network vnet create \
120+
--resource-group myresourcegroup \
121+
--name myvnet \
122+
--location southcentralus \
123+
--address-prefixes 172.16.0.0/20
124+
```
125+
126+
6. Create a subnet in the virtual network using the NAT gateway and store the ID to `$SUBNET_ID` for later use:
127+
```azurecli-interactive
128+
SUBNET_ID=$(az network vnet subnet create \
129+
--resource-group myresourcegroup \
130+
--vnet-name myvnet \
131+
--name natcluster \
132+
--address-prefixes 172.16.0.0/22 \
133+
--nat-gateway mynatgateway \
134+
--query id \
135+
--output tsv)
136+
```
137+
138+
7. Create an AKS cluster using the subnet with the NAT gateway and the managed identity:
139+
```azurecli-interactive
140+
az aks create \
141+
--resource-group myresourcegroup \
142+
--name natcluster \
143+
--location southcentralus \
144+
--network-plugin azure \
145+
--vnet-subnet-id $SUBNET_ID \
146+
--outbound-type userAssignedNATGateway \
147+
--enable-managed-identity \
148+
--assign-identity $IDENTITY_ID
149+
```
79150
80151
## Next Steps
81152
- For more information on Azure NAT Gateway, see [Azure NAT Gateway][nat-docs].
@@ -87,3 +158,5 @@ az aks update \
87158
[nat-docs]: ../virtual-network/nat-gateway/nat-overview.md
88159
[az-feature-list]: /cli/azure/feature#az_feature_list
89160
[az-provider-register]: /cli/azure/provider#az_provider_register
161+
[byo-vnet-azure-cni]: configure-azure-cni.md
162+
[byo-vnet-kubenet]: configure-kubenet.md

0 commit comments

Comments
 (0)