RBAC: remove the monitoring.coreos.com wildcard, keep the narrower markers
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
What
Two markers grant the operator write access to every monitoring.coreos.com resource, which it never uses:
internal/controller/operator/vmagent_controller.go:78internal/controller/operator/vmsingle_controller.go:84
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=*,verbs=*
That wildcard also subsumes the 12 narrower markers in prom*_controller.go, so config/rbac/role.yaml ends up with three rules where the first makes the other two dead:
- apiGroups: [monitoring.coreos.com]
resources: ['*']
verbs: ['*'] # subsumes both rules below
- apiGroups: [monitoring.coreos.com]
resources: [alertmanagerconfigs, podmonitors, probes, prometheusrules, scrapeconfigs, servicemonitors]
verbs: [get, list, watch]
- apiGroups: [monitoring.coreos.com]
resources: [alertmanagerconfigs/status, podmonitors/status, probes/status, prometheusrules/status, scrapeconfigs/status, servicemonitors/status]
verbs: [get, patch, update]
Nothing misbehaves today - RBAC is additive. This is an over-grant, not a bug.
Why fix it
The operator only reads Prometheus objects and updates their /status. Verified on master:
promrule_controller.go:67,96-var instance promv1.PrometheusRule,For(&promv1.PrometheusRule{})- zero
rclient.Create/Update/Patch/Deletecalls on anypromv1orpromv1alpha1type outside tests
So the wildcard is the part to drop. The narrower markers already describe real usage accurately and should stay.
One thing the wildcard does supply
The Prometheus converters set BlockOwnerDeletion: true on the converted VM CRD, with the Prometheus object as owner:
factory/converter/apis.go:76(PrometheusRule),:139(ServiceMonitor),:417(PodMonitor),:501(Probe)factory/converter/v1alpha1/apis.go:126(AlertmanagerConfig),:182(ScrapeConfig)
Under the OwnerReferencesPermissionEnforcement admission plugin, setting such an ownerRef requires update on the owner's /finalizers subresource - prometheusrules/finalizers, servicemonitors/finalizers, and so on. No marker declares those; only the wildcard supplies them today.
This is gated on EnabledPrometheusConverterOwnerReferences (internal/config/config.go:753), which defaults to false. So it affects only users who set VM_ENABLEDPROMETHEUSCONVERTEROWNERREFERENCES=true and run that admission plugin - but for them, removing the wildcard alone would break conversion.
Proposed change
- Remove the two
resources=*,verbs=*markers. - Add explicit finalizer markers for the six convertible owner types, so the case above keeps working:
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=alertmanagerconfigs/finalizers;podmonitors/finalizers;probes/finalizers;prometheusrules/finalizers;scrapeconfigs/finalizers;servicemonitors/finalizers,verbs=update
make manifests, confirmconfig/rbac/role.yamlkeeps read +/status+/finalizersand loses the wildcard.- Exercise conversion with
VM_ENABLEDPROMETHEUSCONVERTEROWNERREFERENCES=trueon a cluster runningOwnerReferencesPermissionEnforcement. No existing test covers that path, and a missing finalizer or watch permission does not surface as a clean 403 - a denied watch parks the controller-runtime informer, so the operator hangs silently.
Context
Raised in review of VictoriaMetrics/helm-charts#3207, which derives the chart's ClusterRole from this generated artifact. The redundancy was spotted there first; the chart cannot fix it, since .github/workflows/crds.yaml copies this file verbatim on release, so the correction has to happen in the markers here.
- Dominant language
- Go
- Stars
- 603
- Forks
- 242
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 57
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from VictoriaMetrics/operator
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
VictoriaMetrics/operator#2854 ·
Maintainers usually reply within 1 day
-
VLAgent `spec.k8sCollector.includePodLabels: false` has no effectPossibly taken @Haleygo claimed this 25 days ago. Openbug waiting for release
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
VictoriaMetrics/operator#2772 · 1 assignee ·
Maintainers usually reply within 1 day
-
Bug: VMRule `spec.groups[].tenant` should accept an integer, not only a stringPossibly taken @megative claimed this 40 days ago. Openenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
VictoriaMetrics/operator#2608 · 5 comments ·
Maintainers usually reply within 1 day
-
VMAlert datasource bearer token isn't documentedMay be free again @Haleygo claimed this 35 days ago, and no pull request is open. Opendocs
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
VictoriaMetrics/operator#2365 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
VictoriaMetrics/operator#2845 ·
Maintainers usually reply within 1 day
All issues in VictoriaMetrics/operator
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
uselagoon/lagoon-cli#501 · 1 reaction ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
slavakurilyak/awesome-ai-agents#1026 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Tarektouati/made#197 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100