Hi guys, I have creates a NP to allow flow from NS:APP to NS:DN on port 9200 and . . .

praveen bhat:
hi guys,
I have creates a NP to allow flow from NS:APP to NS:DN on port 9200 and restricted all other traffic using below yaml:
apiVersion: http://networking.k8s.io/v1|networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
namespace: db
spec:
podSelector: {}
policyTypes:

  • Ingress

ingress:

  • from:
  • namespaceSelector:
    matchLabels:
    ns: app
    ports:
  • protocol: TCP
    port: 9200

Md Ishaq R:
i think the port:9200 is not aligned correctly

Md Ishaq R:
align it correctly under the - protocol: TCP

praveen bhat:
ports:

  • protocol: TCP
    port: 9200

praveen bhat:
is this not right?

praveen bhat:
if its an indentation issue then I would get a syntax error

Fayaz Rehman:
apiVersion: http://networking.k8s.io/v1|networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: iso-pol
spec:
podSelector: {}
policyTypes:

  • Ingress
    ingress:
  • from:
    • namespaceSelector:
      matchLabels:
      iso: late
    • podSelector: {}
      ports:
    • protocol: TCP
      port: 80

Fayaz Rehman:
This works for me - you may ne missing -from in your yaml file. Also label your namespace and use it in the yaml file. Finally, k apply -f net-your.yaml -n your-namespace