Repository navigation
fix(alloy): narrow the collector RBAC to required permissions - #93
Merged
Merged
Conversation
The Alloy subchart grants cluster-wide read access to secrets and configmaps by default, and several rules the collector config does not use. A token read from an Alloy pod on any node can list every Secret in the cluster. Override alloy.rbac.rules and alloy.rbac.clusterRules. Keep only get, list and watch on pods and nodes (pod and node discovery) and get on nodes/metrics (cAdvisor scrape through the kubelet).
jtslear
force-pushed
the
skarbek/alloy-narrow-rbac
branch
from
October 16, 2026 15:04
9faf960 to
d5b613a
Compare
jtslear
marked this pull request as ready for review
October 16, 2026 15:30
dannykopping
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Narrow the Alloy
ClusterRoleto the permissions the collector config uses:pods: get, list, watch (pod discovery)nodes: get, list, watch (node discovery)nodes/metrics: get (cAdvisor scrape through the kubelet)Review of coder/dogfood#702 (v0.8.0 bump), finding CRF-8, deferred to Linear PLE-21: https://github.com/coder/dogfood/pull/702#discussion_r4267633852
The Alloy subchart default grants cluster-wide get/list/watch on
secretsandconfigmaps, and rules forpodlogs,prometheusrules,alertmanagerconfigs,podmonitors,servicemonitors,probes,scrapeconfigs,events,replicasetsand/metrics. The collector config uses none of them. A token read from an Alloy pod on any node can list every Secret in the cluster. The grant also exists withgrafana-agent, so this is not new, but it is now fixed for every user of the chart and not only dogfood.Behaviour change
Users who add components through
alloy.extraBlocksthat need more access must overridealloy.rbac.rulesandalloy.rbac.clusterRules. Added toCHANGELOG.md.Test
Kind cluster testing at baseline is
main: 12 rules, includingsecretsandconfigmaps.ClusterRole alloyrulespods,nodes,nodes/metricsonlykubectl auth can-i --list --as=system:serviceaccount:coder-observability:alloynodesandpodsget/list/watch,nodes/metricsget; nothing forsecretsorconfigmapscan-i list secrets -A,can-i list configmaps -Anoforbiddenorunauthorizedlinesupseries incoder-observability, 10 pods withup == 1container_memory_working_set_bytesseries fresh within 60sNotes
compiled/resources.yamlandREADME.mdregenerated withmake buildandmake readme.kubectl auth can-i list nodes/podsprintedyesin this cluster, which--listdoes not support. I treat it as acan-iquirk with subresources and did not rely on it.