Skip to content

feat(chart): make runner.customResourceRead groups configurable, read-only - #729

Open
RamanKharchee wants to merge 1 commit into
mainfrom
fix/runner-custom-resource-groups
Open

RamanKharchee wants to merge 1 commit into
mainfrom
fix/runner-custom-resource-groups

Conversation

@RamanKharchee

@RamanKharchee RamanKharchee commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This follows up #728, as suggested in its review. The CRDs tab's extra read grants were hardcoded in the template, so reading another CRD (Traefik, for example) needed a chart release. The only other route was a custom rule, which accepts any verb. Now an install can list extra API groups in values. Those grants are always read-only, and any group or resource that would reach Secrets fails the install.

Decision: runner.customResourceRead becomes a map (enabled, viewRole, groups) in place of a bool. It is a map rather than a list because Helm merges maps but replaces lists, so adding one group keeps the defaults. The bool has not shipped in any release or rc, so it is replaced outright, with no compatibility code. Setting the old runner.customResourceRead=true now fails with a message naming the new key.

Look at: the guards at the top of runner-custom-resource-read.yaml. The rules rendered when enabled are identical to #728's.

Type of change

  • New feature (non-breaking)

Chart version

  • No version bump needed: 0.1.33 is not released yet (only an rc)

Test plan

  1. helm template with --set runner.customResourceRead.enabled=true --set-json 'runner.customResourceRead.groups={"traefik.io":["ingressroutes"]}'. The role reads traefik.io and still reads the VictoriaMetrics and prometheus-operator groups.
  2. Same with --set-json 'runner.customResourceRead.groups={"x.io":["secrets"]}'. The render fails with "is not allowed".
  3. Same with the old --set runner.customResourceRead=true. The render fails and names runner.customResourceRead.enabled=true.
  • helm lint charts/nudgebee-agent passes
  • ct lint (left to CI)
  • helm template output reviewed (detail below)
Engineering detail

Renders checked locally:

case result
default nothing rendered
enabled=true, standard and read-only mode 3 objects; ClusterRole rules equal #728's (compared as parsed sets)
enabled=true + --set-json groups={"traefik.io":[...]} apiextensions.k8s.io, monitoring.coreos.com, operator.victoriametrics.com, traefik.io
-f with groups.monitoring.coreos.com: null monitoring.coreos.com dropped, the rest kept
viewRole=false 2 objects, no view binding
groups "", "*", resource "*", resource secrets each fails: ... is not allowed
runner.customResourceRead: false or null nothing rendered (no error)
a group given as a string, not a list fails: ... must be a list of resources
old bool runner.customResourceRead=true (via --set and -f) fails: runner.customResourceRead is a map: set runner.customResourceRead.enabled=true .... Without this guard, Helm failed with only a template position.

CI Secrets gate script: no grants for the default, enableWritePermissions, customResourceRead.enabled, and customResourceRead.enabled + readOnly renders. The gate's two opt-in cases now use .enabled=true.

The nudgebee-enterprise UI banner pointed at runner.customResourceRead: true. That text is updated in the companion app PR.

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the runner.customResourceRead configuration in the Helm chart from a boolean to a map structure, allowing users to toggle the built-in view ClusterRole binding and dynamically configure API groups and resources to read. The review feedback points out two important issues: first, the type check for runner.customResourceRead will incorrectly fail when explicitly set to false or nil to disable the feature; second, a validation check is needed to ensure that the resources specified under groups are lists rather than strings to prevent template rendering errors.

Comment on lines +25 to +28
{{- if not (kindIs "map" $cr) }}
{{- fail "runner.customResourceRead is a map: set runner.customResourceRead.enabled=true (not runner.customResourceRead=true)" }}
{{- end }}
{{- if $cr.enabled }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current check {{- if not (kindIs "map" $cr) }} will trigger a template rendering failure even if runner.customResourceRead is explicitly set to false or nil (e.g., to disable the feature or override values). This is because kindIs "map" false is false.

To prevent false positives and allow users to explicitly disable the feature using false or nil, we should only fail if the value is truthy and not a map (such as true or a string). We also need to guard the .enabled check to avoid evaluating it on non-map values.

{{- if and (not (kindIs "map" $cr)) $cr }}
{{- fail "runner.customResourceRead is a map: set runner.customResourceRead.enabled=true (not runner.customResourceRead=true)" }}
{{- end }}
{{- if and (kindIs "map" $cr) $cr.enabled }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Reproduced it first: customResourceRead: false (via -f and --set) and null both failed with the "is a map" message. Now only a truthy non-map (true, a string) fails, and the .enabled check runs only on a map. Re-rendered: false, null and the default render nothing, true still fails with the hint, and enabled=true renders the same 3 objects.

Comment on lines +43 to +44
{{- if $resources }}
{{- if or (eq $group "") (eq $group "*") }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If a user misconfigures runner.customResourceRead.groups by providing a single string instead of a list of resources (e.g., monitoring.coreos.com: alertmanagers), Go's template engine will range over the string's characters, resulting in invalid resource names like a, l, e, r, t...

We should add a validation check to ensure that $resources is a list/slice before iterating over it.

  {{- if $resources }}
  {{- if not (kindIs "slice" $resources) }}
  {{- fail (printf "runner.customResourceRead.groups.%s must be a list of resources" $group) }}
  {{- end }}
  {{- if or (eq $group "") (eq $group "*") }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the kindIs "slice" guard. One correction: with traefik.io: ingressroutes, the template doesn't iterate characters. Helm fails the render with only a position (runner-custom-resource-read.yaml:47:12). It now fails with runner.customResourceRead.groups.traefik.io must be a list of resources.

…-only

Follow-up to #728. The VictoriaMetrics and prometheus-operator kinds
were hardcoded in the template, so a CRD outside `view` (Traefik, for
example) needed a chart release, and the only other route,
runner.customClusterRoleRules, accepts any verb.

runner.customResourceRead becomes a map (unreleased, so no shim):
- enabled (default false): the opt-in; CRD list read
- viewRole (default true): the built-in `view` binding
- groups: API group -> resources, always get/list/watch. A map so an
  install adds a group without repeating the defaults (Helm merges maps,
  replaces lists) and drops one with `<group>: null`. The core group,
  "*" and "secrets" fail the render, since the CI Secrets gate only
  sees the chart's own values.

The enabled render's rules are unchanged from #728.

Suggested-by: mayankpande88
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RamanKharchee
RamanKharchee force-pushed the fix/runner-custom-resource-groups branch from ba4a1b2 to 71a4a65 Compare November 13, 2026 15:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant