I created a k8s cluster on vmwareworkstation (kubeadm) and now try on networkpolicy lab.
Here is my code:
# create new ns
kubectl create ns demo
# run new nginx pod
kubectl run nginx -n demo --image nginx
# expose pod by clusterIP
kubectl expose po nginx --port=80 -n demo
# run busybox to connect to nginx pod
kubectl run busybox --image busybox -n default --rm -ti /bin/sh
# busybox is not same namespace with nginx
wget -q --timeout=5 nginx -O - # return timeout since two pods not in same namespace
wget -q --timeout=5 -O -10.244.2.21 -O - # it works this time with IP of nginx pod.
Can somebody explain me what is going on here ? is that everything right with my k8s cluster ?
Thank you so much!