I am connecting Nodejs app with mongodb using kubernetes cluster. I want to ensure that mongo POD communicates only with Nodejs POD and deny any other POD traffic. When I apply the default deny policy and then apply the allow policy by app is not working.
I have come up with the following policies - why are they not working?
Default Deny Policy:
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: default-deny
namespace: default
spec:
podSelector:
matchLabels: {}
Network Policy:
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: access-nodejs
namespace: default
spec:
podSelector:
matchLabels:
app: nodejs-mongo
ingress:
- from:
- podSelector:
matchLabels:
run: mongo