How can we find all network policies associate to a pod?

221 views Asked by At

Is there a way to find out all ingress and egress policies that a pod could be affected from?

I haven't written any netpol for a pod, but my pod lives in a huge cluster with many other netpolicies. Based on the timeout errors that I see, I suspect that there are some netpolicies that are getting applied to my pod.

How do I see the list of network policies that affect my little pod?

Thank you

p.s: My question is the inverse of How do i know which pods are covered by a network policy in k8s I would like to know list of netpolicies for a pod.

1

There are 1 answers

1
James S On

Try to run:

kubectl describe networkpolicy <network-policy-name>

Check the label used for the Pod Selector. Then list the pods by their pod selector name

kubectl get pods -l <pod selector name>

It should list the pods that are part of the network policy that you described