parent
f313a39e9e
commit
e6888722ec
|
@ -35,9 +35,9 @@ To see how Kubernetes network policy works, start off by creating an `nginx` dep
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ kubectl run nginx --image=nginx --replicas=2
|
$ kubectl run nginx --image=nginx --replicas=2
|
||||||
deployment "nginx" created
|
deployment.apps/nginx created
|
||||||
$ kubectl expose deployment nginx --port=80
|
$ kubectl expose deployment nginx --port=80
|
||||||
service "nginx" exposed
|
service/nginx exposed
|
||||||
```
|
```
|
||||||
|
|
||||||
This runs two `nginx` pods in the default namespace, and exposes them through a service called `nginx`.
|
This runs two `nginx` pods in the default namespace, and exposes them through a service called `nginx`.
|
||||||
|
@ -45,12 +45,12 @@ This runs two `nginx` pods in the default namespace, and exposes them through a
|
||||||
```console
|
```console
|
||||||
$ kubectl get svc,pod
|
$ kubectl get svc,pod
|
||||||
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||||
svc/kubernetes 10.100.0.1 <none> 443/TCP 46m
|
service/kubernetes 10.100.0.1 <none> 443/TCP 46m
|
||||||
svc/nginx 10.100.0.16 <none> 80/TCP 33s
|
service/nginx 10.100.0.16 <none> 80/TCP 33s
|
||||||
|
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
po/nginx-701339712-e0qfq 1/1 Running 0 35s
|
pod/nginx-701339712-e0qfq 1/1 Running 0 35s
|
||||||
po/nginx-701339712-o00ef 1/1 Running 0 35s
|
pod/nginx-701339712-o00ef 1/1 Running 0 35s
|
||||||
```
|
```
|
||||||
|
|
||||||
## Test the service by accessing it from another pod
|
## Test the service by accessing it from another pod
|
||||||
|
@ -96,7 +96,7 @@ Use kubectl to create a NetworkPolicy from the above nginx-policy.yaml file:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ kubectl create -f nginx-policy.yaml
|
$ kubectl create -f nginx-policy.yaml
|
||||||
networkpolicy "access-nginx" created
|
networkpolicy.networking.k8s.io/access-nginx created
|
||||||
```
|
```
|
||||||
|
|
||||||
## Test access to the service when access label is not defined
|
## Test access to the service when access label is not defined
|
||||||
|
|
Loading…
Reference in New Issue