Skip to content

Commit 9c92412

Browse files
authored
Merge pull request #193293 from erik-ha-msft/erikha-aks-network-policies
[AKS] - Update use-network-policies.md
2 parents a07de93 + 1cbad54 commit 9c92412

File tree

1 file changed

+51
-9
lines changed

1 file changed

+51
-9
lines changed

articles/aks/use-network-policies.md

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ titleSuffix: Azure Kubernetes Service
44
description: Learn how to secure traffic that flows in and out of pods by using Kubernetes network policies in Azure Kubernetes Service (AKS)
55
services: container-service
66
ms.topic: article
7-
ms.date: 03/16/2021
7+
ms.date: 03/29/2022
88

99
---
1010

@@ -100,7 +100,7 @@ az network vnet create \
100100
--subnet-prefix 10.240.0.0/16
101101
102102
# Create a service principal and read in the application ID
103-
SP=$(az ad sp create-for-rbac --role Contributor --output json)
103+
SP=$(az ad sp create-for-rbac --output json)
104104
SP_ID=$(echo $SP | jq -r .appId)
105105
SP_PASSWORD=$(echo $SP | jq -r .password)
106106
@@ -239,7 +239,13 @@ kubectl run backend --image=mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine --la
239239
Create another pod and attach a terminal session to test that you can successfully reach the default NGINX webpage:
240240

241241
```console
242-
kubectl run --rm -it --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 network-policy --namespace development
242+
kubectl run --rm -it --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 network-policy --namespace development
243+
```
244+
245+
Install `wget`:
246+
247+
```console
248+
apt-get update && apt-get install -y wget
243249
```
244250

245251
At the shell prompt, use `wget` to confirm that you can access the default NGINX webpage:
@@ -295,7 +301,13 @@ kubectl apply -f backend-policy.yaml
295301
Let's see if you can use the NGINX webpage on the back-end pod again. Create another test pod and attach a terminal session:
296302

297303
```console
298-
kubectl run --rm -it --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 network-policy --namespace development
304+
kubectl run --rm -it --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 network-policy --namespace development
305+
```
306+
307+
Install `wget`:
308+
309+
```console
310+
apt-get update && apt-get install -y wget
299311
```
300312

301313
At the shell prompt, use `wget` to see if you can access the default NGINX webpage. This time, set a timeout value to *2* seconds. The network policy now blocks all inbound traffic, so the page can't be loaded, as shown in the following example:
@@ -352,7 +364,13 @@ kubectl apply -f backend-policy.yaml
352364
Schedule a pod that is labeled as *app=webapp,role=frontend* and attach a terminal session:
353365

354366
```console
355-
kubectl run --rm -it frontend --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 --labels app=webapp,role=frontend --namespace development
367+
kubectl run --rm -it frontend --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 --labels app=webapp,role=frontend --namespace development
368+
```
369+
370+
Install `wget`:
371+
372+
```console
373+
apt-get update && apt-get install -y wget
356374
```
357375

358376
At the shell prompt, use `wget` to see if you can access the default NGINX webpage:
@@ -382,7 +400,13 @@ exit
382400
The network policy allows traffic from pods labeled *app: webapp,role: frontend*, but should deny all other traffic. Let's test to see whether another pod without those labels can access the back-end NGINX pod. Create another test pod and attach a terminal session:
383401

384402
```console
385-
kubectl run --rm -it --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 network-policy --namespace development
403+
kubectl run --rm -it --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 network-policy --namespace development
404+
```
405+
406+
Install `wget`:
407+
408+
```console
409+
apt-get update && apt-get install -y wget
386410
```
387411

388412
At the shell prompt, use `wget` to see if you can access the default NGINX webpage. The network policy blocks the inbound traffic, so the page can't be loaded, as shown in the following example:
@@ -415,7 +439,13 @@ kubectl label namespace/production purpose=production
415439
Schedule a test pod in the *production* namespace that is labeled as *app=webapp,role=frontend*. Attach a terminal session:
416440

417441
```console
418-
kubectl run --rm -it frontend --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 --labels app=webapp,role=frontend --namespace production
442+
kubectl run --rm -it frontend --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 --labels app=webapp,role=frontend --namespace production
443+
```
444+
445+
Install `wget`:
446+
447+
```console
448+
apt-get update && apt-get install -y wget
419449
```
420450

421451
At the shell prompt, use `wget` to confirm that you can access the default NGINX webpage:
@@ -479,7 +509,13 @@ kubectl apply -f backend-policy.yaml
479509
Schedule another pod in the *production* namespace and attach a terminal session:
480510

481511
```console
482-
kubectl run --rm -it frontend --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 --labels app=webapp,role=frontend --namespace production
512+
kubectl run --rm -it frontend --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 --labels app=webapp,role=frontend --namespace production
513+
```
514+
515+
Install `wget`:
516+
517+
```console
518+
apt-get update && apt-get install -y wget
483519
```
484520

485521
At the shell prompt, use `wget` to see that the network policy now denies traffic:
@@ -501,7 +537,13 @@ exit
501537
With traffic denied from the *production* namespace, schedule a test pod back in the *development* namespace and attach a terminal session:
502538

503539
```console
504-
kubectl run --rm -it frontend --image=mcr.microsoft.com/aks/fundamental/base-ubuntu:v0.0.11 --labels app=webapp,role=frontend --namespace development
540+
kubectl run --rm -it frontend --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 --labels app=webapp,role=frontend --namespace development
541+
```
542+
543+
Install `wget`:
544+
545+
```console
546+
apt-get update && apt-get install -y wget
505547
```
506548

507549
At the shell prompt, use `wget` to see that the network policy allows the traffic:

0 commit comments

Comments
 (0)