Hello, I am facing one issue with network policy. I have added a netpol to allow . . .

Somnath Pawar:
Hello, I am facing one issue with network policy. I have added a netpol to allow the DB api pod communication only from & to frontend pods with specific label. But somehow, other pods are also able to communicate the DB pod without having the expected label selector.

apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: NetworkPolicy
metadata:
  name: db-policy
  namespace: default
spec:
  podSelector:
    matchLabels:
      app: db
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              access: db-access
      ports:
        - protocol: TCP
          port: 3306

Am i doing anything wrong here? I read something about enabling --enable-network-policy flag so the network policies will take effect, but I am not sure where to on this. Can anyone help with the details?

unnivkn:
Hi @Somnath Pawar may I know how you defined traffic to frontend pods

unnivkn:
as per your code traffic is like this. fyi:

unnivkn:

unnivkn:
https://editor.cilium.io/?id=ghJjVZQ4gWDbE30N