I have several namespaces in a cluster and I need to do the following:
- traffic from namespace 1 to namespace 2 goes only to one pod
- traffic from namespace 2 to namespace 1 goes only to one pod.
- traffic from and to the other namespaces would go unimpeded.
There is an idea to hang a certain label on all pods of namespace 1, except for the necessary pod and on all pods of namespace 2 to hang another label, except for the necessary pod and prohibit traffic between namespaces by labels.
How can this be implemented using kubernetes network policies?
i think you can Achieve 1.Create a NetworkPolicy in namespace 1 that allows ingress traffic only from the specific pod in namespace 2, and denies all other ingress traffic 2.Create a NetworkPolicy in namespace 2 that allows ingress traffic only from the specific pod in namespace 1, and denies all other ingress traffic 3.For all other namespaces, create a NetworkPolicy that allows all ingress and egress traffic tell me if you need yaml samples