Skip to content

Commit 48bc3d3

Browse files
committed
Update azurecli commands to azurecli-interactive
1 parent 03117e3 commit 48bc3d3

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

articles/aks/limit-egress-traffic.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The following information provides an example architecture of the deployment:
4040

4141
Define a set of environment variables to be used in resource creations.
4242

43-
```bash
43+
```azurecli-interactive
4444
PREFIX="aks-egress"
4545
RG="${PREFIX}-rg"
4646
LOC="eastus"
@@ -66,13 +66,13 @@ Provision a virtual network with two separate subnets: one for the cluster and o
6666

6767
1. Create a resource group using the [`az group create`][az-group-create] command.
6868

69-
```azurecli
69+
```azurecli-interactive
7070
az group create --name $RG --location $LOC
7171
```
7272
7373
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.
7474
75-
```azurecli
75+
```azurecli-interactive
7676
# Dedicated virtual network with AKS subnet
7777
az network vnet create \
7878
--resource-group $RG \
@@ -104,19 +104,19 @@ You need to configure Azure Firewall inbound and outbound rules. The main purpos
104104
105105
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.
106106
107-
```azurecli
107+
```azurecli-interactive
108108
az network public-ip create -g $RG -n $FWPUBLICIP_NAME -l $LOC --sku "Standard"
109109
```
110110
111111
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.
112112
113-
```azurecli
113+
```azurecli-interactive
114114
az extension add --name azure-firewall
115115
```
116116
117117
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`.
118118
119-
```azurecli
119+
```azurecli-interactive
120120
az network firewall create -g $RG -n $FWNAME -l $LOC --enable-dns-proxy true
121121
```
122122
@@ -128,13 +128,13 @@ You need to configure Azure Firewall inbound and outbound rules. The main purpos
128128
129129
4. Create an Azure Firewall IP configuration using the [`az network firewall ip-config create`][az-network-firewall-ip-config-create] command.
130130
131-
```azurecli
131+
```azurecli-interactive
132132
az network firewall ip-config create -g $RG -f $FWNAME -n $FWIPCONFIG_NAME --public-ip-address $FWPUBLICIP_NAME --vnet-name $VNET_NAME
133133
```
134134

135135
5. Once the previous command succeeds, save the firewall frontend IP address for configuration later.
136136

137-
```azurecli
137+
```azurecli-interactive
138138
FWPUBLIC_IP=$(az network public-ip show -g $RG -n $FWPUBLICIP_NAME --query "ipAddress" -o tsv)
139139
FWPRIVATE_IP=$(az network firewall show -g $RG -n $FWNAME --query "ipConfigurations[0].privateIPAddress" -o tsv)
140140
```
@@ -155,13 +155,13 @@ Azure automatically routes traffic between Azure subnets, virtual networks, and
155155
156156
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.
157157
158-
```azurecli
158+
```azurecli-interactive
159159
az network route-table create -g $RG -l $LOC --name $FWROUTE_TABLE_NAME
160160
```
161161
162162
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.
163163
164-
```azurecli
164+
```azurecli-interactive
165165
az network route-table route create -g $RG --name $FWROUTE_NAME --route-table-name $FWROUTE_TABLE_NAME --address-prefix 0.0.0.0/0 --next-hop-type VirtualAppliance --next-hop-ip-address $FWPRIVATE_IP
166166
167167
az network route-table route create -g $RG --name $FWROUTE_NAME_INTERNET --route-table-name $FWROUTE_TABLE_NAME --address-prefix $FWPUBLIC_IP/32 --next-hop-type Internet
@@ -184,7 +184,7 @@ This section covers three network rules and an application rule you can use to c
184184
185185
1. Create the network rules using the [`az network firewall network-rule create`][az-network-firewall-network-rule-create] command.
186186
187-
```azurecli
187+
```azurecli-interactive
188188
az network firewall network-rule create -g $RG -f $FWNAME --collection-name 'aksfwnr' -n 'apiudp' --protocols 'UDP' --source-addresses '*' --destination-addresses "AzureCloud.$LOC" --destination-ports 1194 --action allow --priority 100
189189
190190
az network firewall network-rule create -g $RG -f $FWNAME --collection-name 'aksfwnr' -n 'apitcp' --protocols 'TCP' --source-addresses '*' --destination-addresses "AzureCloud.$LOC" --destination-ports 9000
@@ -194,7 +194,7 @@ This section covers three network rules and an application rule you can use to c
194194
195195
2. Create the application rule using the [`az network firewall application-rule create`][az-network-firewall-application-rule-create] command.
196196
197-
```azurecli
197+
```azurecli-interactive
198198
az network firewall application-rule create -g $RG -f $FWNAME --collection-name 'aksfwar' -n 'fqdn' --source-addresses '*' --protocols 'http=80' 'https=443' --fqdn-tags "AzureKubernetesService" --action allow --priority 100
199199
```
200200
@@ -204,7 +204,7 @@ To learn more about Azure Firewall, see the [Azure Firewall documentation](../fi
204204
205205
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.
206206
207-
```azurecli
207+
```azurecli-interactive
208208
az network vnet subnet update -g $RG --vnet-name $VNET_NAME --name $AKSSUBNET_NAME --route-table $FWROUTE_TABLE_NAME
209209
```
210210

@@ -216,7 +216,7 @@ Now, you can deploy an AKS cluster into the existing virtual network. You will u
216216

217217
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:
218218

219-
```azurecli
219+
```azurecli-interactive
220220
SUBNETID=$(az network vnet subnet show -g $RG --vnet-name $VNET_NAME --name $AKSSUBNET_NAME --query id -o tsv)
221221
```
222222

@@ -238,7 +238,7 @@ You'll define the outbound type to use the UDR that already exists on the subnet
238238
239239
Create an AKS cluster using a system-assigned managed identity with the CNI network plugin using the [`az aks create`][az-aks-create] command.
240240

241-
```azurecli
241+
```azurecli-interactive
242242
az aks create -g $RG -n $AKSNAME -l $LOC \
243243
--node-count 3 \
244244
--network-plugin azure \
@@ -278,7 +278,7 @@ If you don't have user-assigned identities, follow the steps in this section. If
278278
279279
2. Create a kubelet managed identity using the [`az identity create`][az-identity-create] command.
280280
281-
```azurecli
281+
```azurecli-interactive
282282
az identity create --name myKubeletIdentity --resource-group $RG
283283
```
284284

@@ -306,7 +306,7 @@ If you don't have user-assigned identities, follow the steps in this section. If
306306

307307
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.
308308

309-
```azurecli
309+
```azurecli-interactive
310310
az aks create -g $RG -n $AKSNAME -l $LOC \
311311
--node-count 3 \
312312
--network-plugin kubenet \
@@ -326,19 +326,19 @@ If you used authorized IP ranges for your cluster in the previous step, you need
326326

327327
1. Retrieve your IP address using the following command:
328328

329-
```bash
329+
```azurecli-interactive
330330
CURRENT_IP=$(dig @resolver1.opendns.com ANY myip.opendns.com +short)
331331
```
332332
333333
2. Add the IP address to the approved ranges using the [`az aks update`][az-aks-update] command.
334334
335-
```azurecli
335+
```azurecli-interactive
336336
az aks update -g $RG -n $AKSNAME --api-server-authorized-ip-ranges $CURRENT_IP/32
337337
```
338338
339339
3. Configure `kubectl` to connect to your AKS cluster using the [`az aks get-credentials`][az-aks-get-credentials] command.
340340
341-
```azurecli
341+
```azurecli-interactive
342342
az aks get-credentials -g $RG -n $AKSNAME
343343
```
344344
@@ -352,7 +352,7 @@ You can now start exposing services and deploying applications to this cluster.
352352
353353
2. Deploy the service using the `kubectl apply` command.
354354
355-
```bash
355+
```azurecli-interactive
356356
kubectl apply -f https://raw.githubusercontent.com/Azure-Samples/aks-store-demo/main/aks-store-quickstart.yaml
357357
```
358358

@@ -366,32 +366,32 @@ To configure inbound connectivity, you need to write a DNAT rule to the Azure Fi
366366

367367
1. Get the internal IP address assigned to the load balancer using the `kubectl get services` command.
368368

369-
```bash
370-
kubectl get services
369+
```azurecli-interactive
370+
kubectl get services
371371
```
372372

373-
The IP address will be listed in the `EXTERNAL-IP` column, as shown in the following example output:
373+
The IP address will be listed in the `EXTERNAL-IP` column, as shown in the following example output:
374374

375-
```bash
375+
```output
376376
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
377377
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 9m10s
378378
order-service ClusterIP 10.0.104.144 <none> 3000/TCP 11s
379379
product-service ClusterIP 10.0.237.60 <none> 3002/TCP 10s
380380
rabbitmq ClusterIP 10.0.161.128 <none> 5672/TCP,15672/TCP 11s
381381
store-front LoadBalancer 10.0.89.139 20.39.18.6 80:32271/TCP 10s
382-
```
382+
```
383383

384384
2. Get the service IP using the `kubectl get svc voting-app` command.
385385

386-
```bash
387-
SERVICE_IP=$(kubectl get svc voting-app -o jsonpath='{.status.loadBalancer.ingress[*].ip}')
388-
```
386+
```azurecli-interactive
387+
SERVICE_IP=$(kubectl get svc voting-app -o jsonpath='{.status.loadBalancer.ingress[*].ip}')
388+
```
389389

390390
3. Add the NAT rule using the [`az network firewall nat-rule create`][az-network-firewall-nat-rule-create] command.
391391

392-
```azurecli
393-
az network firewall nat-rule create --collection-name exampleset --destination-addresses $FWPUBLIC_IP --destination-ports 80 --firewall-name $FWNAME --name inboundrule --protocols Any --resource-group $RG --source-addresses '*' --translated-port 80 --action Dnat --priority 100 --translated-address $SERVICE_IP
394-
```
392+
```azurecli-interactive
393+
az network firewall nat-rule create --collection-name exampleset --destination-addresses $FWPUBLIC_IP --destination-ports 80 --firewall-name $FWNAME --name inboundrule --protocols Any --resource-group $RG --source-addresses '*' --translated-port 80 --action Dnat --priority 100 --translated-address $SERVICE_IP
394+
```
395395

396396
## Validate connectivity
397397

@@ -407,7 +407,7 @@ On this page, you can view products, add them to your cart, and then place an or
407407

408408
To clean up Azure resources, delete the AKS resource group using the [`az group delete`][az-group-delete] command.
409409

410-
```azurecli
410+
```azurecli-interactive
411411
az group delete -g $RG
412412
```
413413

0 commit comments

Comments
 (0)