Skip to content

Commit

Permalink
Use run-pod/v1 in kubectl run command for 04-deny-traffic-from-other-…
Browse files Browse the repository at this point in the history
…namespaces.md (#53)

* Replace deprecated API based deployment with new

* Update cleanup to use pod instead of deployment
  • Loading branch information
yamaszone committed Apr 7, 2020
1 parent 60f5b12 commit 7e1649a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions 04-deny-traffic-from-other-namespaces.md
Expand Up @@ -22,7 +22,7 @@ Create a new namespace called `secondary` and start a web service:
```sh
kubectl create namespace secondary

kubectl run web --namespace secondary --image=nginx \
kubectl run --generator=run-pod/v1 web --namespace secondary --image=nginx \
--labels=app=web --expose --port 80
```

Expand Down Expand Up @@ -61,7 +61,7 @@ Note a few things about this manifest:
Query this web service from the `default` namespace:
```sh
$ kubectl run test-$RANDOM --namespace=default --rm -i -t --image=alpine -- sh
$ kubectl run --generator=run-pod/v1 test-$RANDOM --namespace=default --rm -i -t --image=alpine -- sh
/ # wget -qO- --timeout=2 http://web.secondary
wget: download timed out
```
Expand All @@ -71,15 +71,15 @@ It blocks the traffic from `default` namespace!
Any pod in `secondary` namespace should work fine:
```sh
$ kubectl run test-$RANDOM --namespace=secondary --rm -i -t --image=alpine -- sh
$ kubectl run --generator=run-pod/v1 test-$RANDOM --namespace=secondary --rm -i -t --image=alpine -- sh
/ # wget -qO- --timeout=2 http://web.secondary
<!DOCTYPE html>
<html>
```
### Cleanup
kubectl delete deployment web -n secondary
kubectl delete pod web -n secondary
kubectl delete service web -n secondary
kubectl delete networkpolicy deny-from-other-namespaces -n secondary
kubectl delete namespace secondary

0 comments on commit 7e1649a

Please sign in to comment.