<p>Create a new NetworkPolicy named allow-port-from-namespace in the existing namespace snafu. Ensure that the new NetworkPolicy allows Pods
in namespace internal to connect to port 8080 of Pods in namespace snafu.Further ensure that the new NetworkPolicy: does not allow access
to Pods, which don't listen on port 8080 does not allow access from Pods,which are not in namespace internal.</p>
<p>Please help me with this question.</p>
<p>Also please verify if the below yaml(in the comment section) is correct and help me understand the second part of question
(Further ensure that the new NetworkPolicy: does not allow access to Pods, which don't listen on port 8080 does not allow access from Pods,which are not in namespace internal)</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-port-from-namespace
  namespace: snafu
spec:
  podSelector:
    matchLabels:
      role: db
  policyTypes:
  - Ingress
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          name: internal
    ports:
    - protocol: TCP
      port: 8080 
  


 
</code></pre>

Poo
<p>The second part mean you must <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/#default-deny-all-ingress-traffic" rel="nofollow noreferrer">isolate all the pods</a> in the namespace snafu by default which mean you need to change your <code>podSelector</code> field to:</p>
<pre><code>...
spec:
  podSelector: {}
...
</code></pre>
