From 367b55a2511ea66112b9991f9585497c1f331c18 Mon Sep 17 00:00:00 2001 From: RAC Date: Fri, 13 Nov 2026 20:24:11 +0530 Subject: [PATCH] fix(chart): let the runner read CRDs and common custom resources The CRDs tab lists the cluster's CRDs and, per CRD, its objects through get_resource. The runner had no read on customresourcedefinitions and almost no CR groups, so both lists failed with "forbidden" on every install. runner.customResourceRead (opt-in, default false; both modes) renders one file: - get/list/watch on customresourcedefinitions - a ClusterRoleBinding to the built-in `view` role (no Secrets by default), which covers built-ins and every operator that aggregates to view - named VictoriaMetrics and prometheus-operator kinds, which do not aggregate to view; vmusers and vmalertmanagers are left out because they can carry credentials inline The Secrets RBAC CI gate now also renders with the opt-in on. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/helm-dev-lint.yml | 2 + .../runner-custom-resource-read.yaml | 106 ++++++++++++++++++ charts/nudgebee-agent/values.yaml | 6 + 3 files changed, 114 insertions(+) create mode 100644 charts/nudgebee-agent/templates/runner-custom-resource-read.yaml diff --git a/.github/workflows/helm-dev-lint.yml b/.github/workflows/helm-dev-lint.yml index 574c740f..9f70c322 100644 --- a/.github/workflows/helm-dev-lint.yml +++ b/.github/workflows/helm-dev-lint.yml @@ -455,6 +455,8 @@ jobs: check '' check '' --set runner.enableWritePermissions=true check '' --set runner.readOnly=true + check '' --set runner.customResourceRead=true + check '' --set runner.customResourceRead=true --set runner.readOnly=true check 'ClusterRole/nudgebee-agent-runner-scanner-pullsecrets-read:get Role/nudgebee-agent-runner-scanner-pullsecrets:create,delete,patch,update' \ --set runner.scannerAutoCopyPullSecrets=true check 'ClusterRole/nudgebee-agent-runner-helm-releases:list' --set runner.helmReleaseDiscovery=true diff --git a/charts/nudgebee-agent/templates/runner-custom-resource-read.yaml b/charts/nudgebee-agent/templates/runner-custom-resource-read.yaml new file mode 100644 index 00000000..5a5d985c --- /dev/null +++ b/charts/nudgebee-agent/templates/runner-custom-resource-read.yaml @@ -0,0 +1,106 @@ +{{- /* +Opt-in (runner.customResourceRead): read access behind the UI's CRDs tab, +which lists the cluster's CRDs and, per CRD, its objects (get_resource, +all namespaces). Read-only and rendered in both standard and read-only mode. + + - customresourcedefinitions: the CRD list itself. + - The built-in `view` ClusterRole: read on built-in kinds plus every CRD + whose operator labels its roles aggregate-to-view (cert-manager, Argo, + Elastic, ...). The default `view` grants no Secrets; anything a cluster + later aggregates into `view` is granted to the runner too. + - Named VictoriaMetrics and prometheus-operator kinds, whose operators do + not aggregate to `view` and which Nudgebee itself runs. Named, not `*`: + vmusers (password/bearerToken may be inline) and vmalertmanagers + (configRawYaml may embed receiver credentials) are left out on purpose. + +CRDs outside these stay unreadable; grant them with +runner.customClusterRoleRules. Secret-bearing kinds are refused by the +runner itself (pkg/kube/secretpolicy.go) whatever RBAC allows. +*/}} +{{- if .Values.runner.customResourceRead }} +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ include "nudgebee-agent.fullname" . }}-runner-custom-resource-read +rules: + - apiGroups: + - "apiextensions.k8s.io" + resources: + - customresourcedefinitions + verbs: + - get + - list + - watch + - apiGroups: + - "operator.victoriametrics.com" + resources: + - vlagents + - vlclusters + - vlogs + - vlsingles + - vmagents + - vmalertmanagerconfigs + - vmalerts + - vmanomalies + - vmanomalyconfigs + - vmauths + - vmclusters + - vmdistributed + - vmnodescrapes + - vmpodscrapes + - vmprobes + - vmrules + - vmscrapeconfigs + - vmservicescrapes + - vmsingles + - vmstaticscrapes + - vtclusters + - vtsingles + verbs: + - get + - list + - watch + - apiGroups: + - "monitoring.coreos.com" + resources: + - alertmanagerconfigs + - alertmanagers + - podmonitors + - probes + - prometheusagents + - prometheuses + - prometheusrules + - scrapeconfigs + - servicemonitors + - thanosrulers + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "nudgebee-agent.fullname" . }}-runner-custom-resource-read +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "nudgebee-agent.fullname" . }}-runner-custom-resource-read +subjects: + - kind: ServiceAccount + name: {{ include "nudgebee-agent.fullname" . }}-runner-service-account + namespace: {{ .Release.Namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "nudgebee-agent.fullname" . }}-runner-view +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: view +subjects: + - kind: ServiceAccount + name: {{ include "nudgebee-agent.fullname" . }}-runner-service-account + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/charts/nudgebee-agent/values.yaml b/charts/nudgebee-agent/values.yaml index 1f667e8a..2226fdc9 100644 --- a/charts/nudgebee-agent/values.yaml +++ b/charts/nudgebee-agent/values.yaml @@ -287,6 +287,12 @@ runner: # cluster. Off by default: the upgrade check then reports Helm release # compatibility as unknown. Also applies under runner.readOnly. helmReleaseDiscovery: false + # Read access for the UI's CRDs tab: the CRD list, the built-in `view` + # ClusterRole (no Secrets by default), and named VictoriaMetrics / prometheus-operator + # kinds. Read-only; also applies under runner.readOnly. Off by default: the + # CRDs tab then shows "not allowed" until this is enabled. See + # templates/runner-custom-resource-read.yaml for what is left out and why. + customResourceRead: false customClusterRoleRules: [] imagePullSecrets: [] # Extra volumes on the runner pod. The common use is trusting a private CA