Hi Folks…i observed in the OPAin Kubernetes - Labs that creating a configmap fo . . .

Dinesh Pola:
hi Folks…i observed in the OPAin Kubernetes - Labs that creating a configmap for OPA Policy (using the kubectl imperative command ) without the label (http://openpolicyagent.org/policy|openpolicyagent.org/policy: rego) is able to enforce rules. From the lecture video for OPA in Kubernetes, it was mentioned that the label is mandatory in the configmap <http://openpolicyagent.org/policy|openpolicyagent.org/policy>: rego
( I tried adding the label without looking at the hint first time :slightly_smiling_face: , was curious to try the solution provided and found this issue)
Can someone explain how is this possible without the label ?

Aibek:
Hey Dinesh, I had the same question as you at some point. If you check the default namespace in that lab, you will notice that it is opa , and not default .

From https://www.openpolicyagent.org/docs/latest/kubernetes-tutorial/#4-define-a-policy-and-load-it-into-opa-via-kubernetes:

Store the policy in Kubernetes as a ConfigMap. By default kube-mgmt will try to load policies out of configmaps in the opa namespace OR configmaps in other namespaces labelled <http://openpolicyagent.org/policy=rego|openpolicyagent.org/policy=rego>.

Dinesh Pola:
Thanks @Aibek for the reply.
The kubectl context was set to OPA.
Small correction: just verified the kubectl config where the namespace was set to opa. Its not the default namespace setting that was altered.