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/limit-egress-traffic.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ The following information provides an example architecture of the deployment:
40
40
41
41
Define a set of environment variables to be used in resource creations.
42
42
43
-
```bash
43
+
```azurecli-interactive
44
44
PREFIX="aks-egress"
45
45
RG="${PREFIX}-rg"
46
46
LOC="eastus"
@@ -66,13 +66,13 @@ Provision a virtual network with two separate subnets: one for the cluster and o
66
66
67
67
1. Create a resource group using the [`az group create`][az-group-create] command.
68
68
69
-
```azurecli
69
+
```azurecli-interactive
70
70
az group create --name $RG --location $LOC
71
71
```
72
72
73
73
2. Create a virtual network with two subnets to host the AKS cluster and the Azure Firewall using the [`az network vnet create`][az-network-vnet-create] and [`az network vnet subnet create`][az-network-vnet-subnet-create] commands.
74
74
75
-
```azurecli
75
+
```azurecli-interactive
76
76
# Dedicated virtual network with AKS subnet
77
77
az network vnet create \
78
78
--resource-group $RG \
@@ -104,19 +104,19 @@ You need to configure Azure Firewall inbound and outbound rules. The main purpos
104
104
105
105
1. Create a standard SKU public IP resource using the [`az network public-ip create`][az-network-public-ip-create] command. This resource will be used as the Azure Firewall frontend address.
2. Register the [Azure Firewall preview CLI extension](https://github.com/Azure/azure-cli-extensions/tree/main/src/azure-firewall) to create an Azure Firewall using the [`az extension add`][az-extension-add] command.
112
112
113
-
```azurecli
113
+
```azurecli-interactive
114
114
az extension add --name azure-firewall
115
115
```
116
116
117
117
3. Create an Azure Firewall and enable DNS proxy using the [`az network firewall create`][az-network-firewall-create] command and setting the `--enable-dns-proxy` to `true`.
@@ -155,13 +155,13 @@ Azure automatically routes traffic between Azure subnets, virtual networks, and
155
155
156
156
1. Create an empty route table to be associated with a given subnet using the [`az network route-table create`][az-network-route-table-create] command. The route table will define the next hop as the Azure Firewall created above. Each subnet can have zero or one route table associated to it.
157
157
158
-
```azurecli
158
+
```azurecli-interactive
159
159
az network route-table create -g $RG -l $LOC --name $FWROUTE_TABLE_NAME
160
160
```
161
161
162
162
2. Create routes in the route table for the subnets using the [`az network route-table route create`][az-network-route-table-route-create] command.
@@ -204,7 +204,7 @@ To learn more about Azure Firewall, see the [Azure Firewall documentation](../fi
204
204
205
205
To associate the cluster with the firewall, the dedicated subnet for the cluster's subnet must reference the route table created above. Use the [`az network vnet subnet update`][az-network-vnet-subnet-update] command to associate the route table to AKS.
@@ -216,7 +216,7 @@ Now, you can deploy an AKS cluster into the existing virtual network. You will u
216
216
217
217
The target subnet to be deployed into is defined with the environment variable, `$SUBNETID`. Set the value for the subnet ID using the following command:
218
218
219
-
```azurecli
219
+
```azurecli-interactive
220
220
SUBNETID=$(az network vnet subnet show -g $RG --vnet-name $VNET_NAME --name $AKSSUBNET_NAME --query id -o tsv)
221
221
```
222
222
@@ -238,7 +238,7 @@ You'll define the outbound type to use the UDR that already exists on the subnet
238
238
239
239
Create an AKS cluster using a system-assigned managed identity with the CNI network plugin using the [`az aks create`][az-aks-create] command.
240
240
241
-
```azurecli
241
+
```azurecli-interactive
242
242
az aks create -g $RG -n $AKSNAME -l $LOC \
243
243
--node-count 3 \
244
244
--network-plugin azure \
@@ -278,7 +278,7 @@ If you don't have user-assigned identities, follow the steps in this section. If
278
278
279
279
2. Create a kubelet managed identity using the [`az identity create`][az-identity-create] command.
280
280
281
-
```azurecli
281
+
```azurecli-interactive
282
282
az identity create --name myKubeletIdentity --resource-group $RG
283
283
```
284
284
@@ -306,7 +306,7 @@ If you don't have user-assigned identities, follow the steps in this section. If
306
306
307
307
Create an AKS cluster with your existing identities in the subnet using the [`az aks create`][az-aks-create] command, provide the resource ID of the managed identity for the control plane by including the `assign-kubelet-identity` argument.
308
308
309
-
```azurecli
309
+
```azurecli-interactive
310
310
az aks create -g $RG -n $AKSNAME -l $LOC \
311
311
--node-count 3 \
312
312
--network-plugin kubenet \
@@ -326,19 +326,19 @@ If you used authorized IP ranges for your cluster in the previous step, you need
326
326
327
327
1. Retrieve your IP address using the following command:
328
328
329
-
```bash
329
+
```azurecli-interactive
330
330
CURRENT_IP=$(dig @resolver1.opendns.com ANY myip.opendns.com +short)
331
331
```
332
332
333
333
2. Add the IP address to the approved ranges using the [`az aks update`][az-aks-update] command.
334
334
335
-
```azurecli
335
+
```azurecli-interactive
336
336
az aks update -g $RG -n $AKSNAME --api-server-authorized-ip-ranges $CURRENT_IP/32
337
337
```
338
338
339
339
3. Configure `kubectl` to connect to your AKS cluster using the [`az aks get-credentials`][az-aks-get-credentials] command.
340
340
341
-
```azurecli
341
+
```azurecli-interactive
342
342
az aks get-credentials -g $RG -n $AKSNAME
343
343
```
344
344
@@ -352,7 +352,7 @@ You can now start exposing services and deploying applications to this cluster.
352
352
353
353
2. Deploy the service using the `kubectl apply` command.
0 commit comments