<p>Is there a way to isolate one namespace from accessing other namespace but still be able to go outside the cluster
I have 10 namespaces, I want that pods within this 1 namespace are not be able to talk to other namespaces but still be able to go outside the cluster to external resources
while this is applied to only 1 namespace the other 9 namespaces can talk to each other</p>

user3805888
<p>Try this one</p>
<pre><code>kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  namespace: default //your 1 namespaces on which you want to deny all traffic.
  name: deny-from-other-namespaces
spec:
  podSelector:
    matchLabels:
  ingress:
 - from:
    - podSelector: {}
</code></pre>
<p><strong>Note a few things about this manifest:</strong></p>
<ul>
<li>namespace: default deploys it to the default namespace.Please change it as per your need.</li>
<li>It applies the policy to ALL pods in default namespace as the<br />
spec.podSelector.matchLabels is empty and therefore selects all pods.</li>
<li>It allows traffic from ALL pods in the default namespace, as<br />
spec.ingress.from.podSelector is empty and therefore selects all
pods.
Here is an awesome on network policy github <a href="https://github.com/ahmetb/kubernetes-network-policy-recipes" rel="nofollow noreferrer">repo</a> from which i have taken this example.</li>
</ul>
