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
Copy file name to clipboardExpand all lines: articles/aks/nat-gateway.md
+75-2Lines changed: 75 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,8 +55,9 @@ az group create --name myresourcegroup --location southcentralus
55
55
```
56
56
57
57
```azurecli-interactive
58
-
az aks create --resource-group myresourcegroup
59
-
--name natcluster \
58
+
az aks create \
59
+
--resource-group myresourcegroup \
60
+
--name natcluster \
60
61
--node-count 3 \
61
62
--outbound-type managedNATGateway \
62
63
--nat-gateway-managed-outbound-ip-count 2 \
@@ -76,6 +77,76 @@ az aks update \
76
77
--nat-gateway-managed-outbound-ip-count 5
77
78
```
78
79
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
+
```
79
150
80
151
## Next Steps
81
152
- For more information on Azure NAT Gateway, see [Azure NAT Gateway][nat-docs].
0 commit comments