kubewarden / kubewarden-controller

Manage admission policies in your Kubernetes cluster with ease
https://kubewarden.io
Apache License 2.0
182 stars 30 forks source link

Feature Request: Ability to add custom labels/annotations to resources created by the policyserver #651

Open brunorene opened 4 months ago

brunorene commented 4 months ago

Is your feature request related to a problem?

Sort of. I wanted to discover all pods concerning policy servers and for that I wanted to inject 1 label on all pods. I was unable to do it because everytime I patched the pods or the deployment created by the policy server, the label was removed.

Solution you'd like

Ability to add custom labels and possibly annotations to the deployments and pods generated by the policyserver.

Alternatives you've considered

I had to change my discovery process to target labels with wildcards, which is not ideal

Anything else?

No response

flavio commented 4 months ago

The Pods that belong to a Policy Server have the label kubewarden/policy-server set with the name of the PolicyServer object they are related with.

If you want to find all the KW Pods that are about PolicyServer (hence exclude the ones of the controller and the audit-scanner), you could do something like that:

kubectl get pods -l "kubewarden/policy-server" -n kubewarden
NAME                                     READY   STATUS    RESTARTS   AGE
policy-server-default-6746b5bc9b-n769r   1/1     Running   0          5m23s
policy-server-default-6746b5bc9b-vds7b   1/1     Running   0          97s
policy-server-testing-df999f7d8-wbwsd    1/1     Running   0          104s

Would that work?