<p>I want to block all traffic from other namespaces with a simple Network Policy. But it doesn't give the result I want. Am I doing something wrong?</p>
<pre><code>k get namespaces
prod              Active   39m
qa                Active   39m

k get networkpolicies.networking.k8s.io -n prod
NAME                         POD-SELECTOR   AGE
block-other-namespace        &lt;none&gt;         25m

k get -o wide pods --all-namespaces
prod          curl-pod    1/1     Running   0          47m   10.244.2.2     minikube-m03
prod          web         1/1     Running   0          47m   10.244.1.3     minikube-m02
qa            curl-pod    1/1     Running   0          47m   10.244.1.2     minikube-m02
</code></pre>
<p>The Network Policies yaml file is as follows.</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  namespace: prod                         
  name: block-other-namespace
spec:
  podSelector: {}                          
  ingress:
    - from:
        - podSelector: {}
</code></pre>
<p>However, I can send requests to the pod in the qa namespace with the pod in the prod namespace.</p>
<pre><code>kubectl -n qa exec curl-pod -- curl -I http://10.244.1.3
0HTTP/1.1 200 OK
Server: nginx/1.23.2
Date: Sun, 13 Nov 2022 08:34:35 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Wed, 19 Oct 2022 07:56:21 GMT
Connection: keep-alive
ETag: &quot;634fada5-267&quot;
Accept-Ranges: bytes
</code></pre>

j4nus
<p>I tried recreating your environment, and the network policy configuration set works for me. Please make sure you have a CNI with support for enforcing network policies installed.</p>
<p>You can check out the <a href="https://projectcalico.docs.tigera.io/getting-started/kubernetes/quickstart" rel="nofollow noreferrer">calico installation guide</a>
or install it in a one liner:</p>
<pre><code>kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/calico.yaml
</code></pre>
<hr />
<p>Also, we faced these kinds of issues at Otterize when manually configuring network policies to control access between pods. We ended up building a solution of our own and open-sourced it - <a href="https://docs.otterize.com/quick-tutorials/k8s-network-policies" rel="nofollow noreferrer">https://docs.otterize.com/quick-tutorials/k8s-network-policies</a></p>
