kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: whitelist-ingress-nginx
spec:
  podSelector:
    matchLabels:
      run: hello-app
  ingress:
    - from:
      - namespaceSelector:      # allows traffic from namespace with label app.kubernetes.io/name=ingress-nginx 
          matchLabels:
            app.kubernetes.io/name: ingress-nginx  
        podSelector:           # allows traffic from pods with label app.kubernetes.io/name=ingress-nginx
          matchLabels:
            app.kubernetes.io/name: ingress-nginx
