Hi Guys : In a Network Policy , I want to limit access ONLY the pods in between . . .

Roshan Ranasinghe:
Hi Guys : In a Network Policy , I want to limit access ONLY the pods in between Dev and Prod (has a label purpose=prod ) namespaces in a given port 8001… Could you please verify the bellow ?

apiVersion: http://networking.k8s.io/v1|networking.k8s.io/v1
kind: NetworkPolicymetadata: name: my-pol
namespace: dev
spec:
podSelector: {}
policyTypes:

  • Ingress
    ingress:
  • from:
    • namespaceSelector:
      matchLabels:
      purpose: prod
    • podSelector: {}
      ports:
    • protocol: TCP
      port: 8001

Nada Nour:
i think you need to remove the podSelector in the from statement

J B P:
agreed with @Nada Nour

Roshan Ranasinghe:
Thanks Guys…

AB:
This network policy will behave like - Any pod in dev namespace will connect to any pod and namespaces that label with ‘purpose: prob’ over 8001 port.