Hi i have question about networkpolicy. If there is no label on namespaces and p . . .

YJ Song:
hi i have question about networkpolicy. If there is no label on namespaces and pods on both source and destination, should I create the labels myself to apply it? It seems that there’s no labels at all in the pods and namespaces in the real exam questions. Or is there a way to apply networkpolicy only with name of pods or namespaces?

Pratik Patel:
Yes you have to label namespace. Pod should be labelled already.

YJ Song:
no pods had no labels neither so thought there could be different way

AnasGoaln:
@Pratik Patel what do you mean by “label the namespace”, can we label the namespace??!.. I do not think so !!

Deepak Kumar Sahu:
@AnasGoaln: yes we can do it which can be used in namespaceSelector in netpol.

AnasGoaln:
I will check for this … thanks !!

Pratik Patel:
@AnasGoaln you can label namespace and you have to, in order to use namespaceselector in NetworkPolicy.

AnasGoaln:
I rechecked … you are absolutely right… thanks for the clarification !!