I was trying to test Pod network policies between different kubernetes namespaces . By default, if no policies exist in a namespace, then all ingress and egress traffic is allowed to and from pods in that namespace. Does this apply between namespace also ?
I created a Pod in default namespace using below command
kubectl run myhttpd --image="docker.io/library/nginx:latest" --restart=Never --port 80
Now from a different namespace, I was trying to access the port 80 , but it is timing out.
kubectl config set-context --current --namespace=mywebapp
kubectl run myhttpd --rm -it --image=busybox --restart=Never -- /bin/sh
If you don't see a command prompt, try pressing enter.
# wget --spider --timeout=1 100.64.9.198
Connecting to 100.64.9.198 (100.64.9.198:80)
wget: download timed out
Even ping was not responding
$ kubectl run myhttpd --rm -it --image=busybox --restart=Never -- /bin/sh
If you don't see a command prompt, try pressing enter.
/ # ping 100.64.9.198
PING 100.64.9.198 (100.64.9.198): 56 data bytes
^C
--- 100.64.9.198 ping statistics ---
11 packets transmitted, 0 packets received, 100% packet loss
So it looks by default all ingress and egress traffic is not allowed between pods in different namespaces .
Can somebody please confirm if my understanding is correct ?