Skip to content

feat: customizable RBAC templates#563

Merged
yonahd merged 13 commits intoyonahd:mainfrom
sleeyax:feat/role-customizations
Feb 27, 2026
Merged

feat: customizable RBAC templates#563
yonahd merged 13 commits intoyonahd:mainfrom
sleeyax:feat/role-customizations

Conversation

@sleeyax
Copy link
Contributor

@sleeyax sleeyax commented Jan 28, 2026

What this PR does / why we need it?

This pull request refactors how RBAC resources are generated in the Helm chart, making the configuration more flexible for consumers of the chart.

See the linked issue for more context. For my use-case I can now install kor in our permission-limited cluster with the following config:

rbac:
    create: 'role'
    rules:
      - apiGroups:
          - ''
        resources:
          - secrets
          - persistentvolumeclaims
          - pods
        verbs:
          - get
          - list
          - watch
          - delete
      - apiGroups:
          - networking.k8s.io
        resources:
          - ingresses
        verbs:
          - get
          - list
          - watch
$ helm upgrade --install kor-test helm --set kor.enabled=true --set "kor.cronJob.args={pvc\,secret,--delete,--no-interactive,--include-namespaces=development,--skip-namespace-validation}"

PR Checklist

  • This PR modifies the helm chart

GitHub Issue

Closes #561

Notes for reviewers

Sorry for the messy commits. Took a bit of trial and error to land on a solution I'm satisfied with. Probably best to squash these changes.

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.56%. Comparing base (58fc28d) to head (d0b99f0).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #563   +/-   ##
=======================================
  Coverage   46.56%   46.56%           
=======================================
  Files          69       69           
  Lines        3930     3930           
=======================================
  Hits         1830     1830           
  Misses       1794     1794           
  Partials      306      306           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yonahd
Copy link
Owner

yonahd commented Jan 30, 2026

@sleeyax
Please run

docker run --rm --volume "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest 

To generate the Readme

@sleeyax sleeyax force-pushed the feat/role-customizations branch from f3d34c7 to 456de62 Compare February 2, 2026 14:27
@sleeyax
Copy link
Contributor Author

sleeyax commented Feb 3, 2026

@sleeyax Please run

docker run --rm --volume "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:latest 

To generate the Readme

done.

@yonahd
Copy link
Owner

yonahd commented Feb 12, 2026

@sleeyax can you fix the chart and pull the namespacing code to a separate pr?

@sleeyax
Copy link
Contributor Author

sleeyax commented Feb 13, 2026

@yonahd Sure. I'll pick this back up next week.

@sleeyax sleeyax force-pushed the feat/role-customizations branch from d06a92a to deaaac5 Compare February 19, 2026 11:56
Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

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

Looks good overall
One comment

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the Helm chart's RBAC resource generation to make it more flexible and customizable. It addresses issue #561, which requested the ability to customize ClusterRole resources for permission-limited clusters.

Changes:

  • Adds configurable RBAC generation with rbac.create field supporting multiple modes (true/false/"role"/"clusterrole")
  • Introduces customizable rbac.rules array allowing users to define their own RBAC permissions
  • Replaces hardcoded RBAC rules with proper API group to resource mappings, removing the overly permissive wildcard apiGroups: ["*"] pattern

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
charts/kor/values.yaml Adds new rbac configuration section with create and rules fields, providing default rules with proper API group mappings for all previously supported resources
charts/kor/templates/_helpers.tpl Adds three helper functions: kor.createRole, kor.createClusterRole for conditional resource creation, and kor.resourceRules for generating RBAC rules from values
charts/kor/templates/role.yaml Refactors to use new helper functions and removes hardcoded rules, making both Role and ClusterRole conditional and rule-customizable
charts/kor/templates/rolebinding.yaml Adds conditional rendering for RoleBinding and ClusterRoleBinding based on whether corresponding Role/ClusterRole are being created
charts/kor/Chart.yaml Bumps chart version from 0.2.13 to 0.2.14
charts/kor/README.md Updates documentation to reflect new version and adds documentation for new rbac.create and rbac.rules configuration options

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +82 to +91
{{- $create := .Values.rbac.create -}}
{{- if or (eq (toString $create) "true") (eq $create "role") }}true{{- end }}
{{- end }}

{{/*
Check if ClusterRole should be created
*/}}
{{- define "kor.createClusterRole" -}}
{{- $create := .Values.rbac.create -}}
{{- if or (eq (toString $create) "true") (eq $create "clusterrole") }}true{{- end }}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The helper function doesn't handle edge cases where rbac.create is set to an unexpected value (e.g., "ClusterRole" with different casing). Consider normalizing the value using lower to be case-insensitive, or provide validation to handle unexpected values gracefully. Currently, invalid values would silently result in no RBAC resources being created, which could cause the application to fail with permission errors.

Suggested change
{{- $create := .Values.rbac.create -}}
{{- if or (eq (toString $create) "true") (eq $create "role") }}true{{- end }}
{{- end }}
{{/*
Check if ClusterRole should be created
*/}}
{{- define "kor.createClusterRole" -}}
{{- $create := .Values.rbac.create -}}
{{- if or (eq (toString $create) "true") (eq $create "clusterrole") }}true{{- end }}
{{- $create := .Values.rbac.create | toString | lower -}}
{{- if or (eq $create "true") (eq $create "role") }}true{{- end }}
{{- end }}
{{/*
Check if ClusterRole should be created
*/}}
{{- define "kor.createClusterRole" -}}
{{- $create := .Values.rbac.create | toString | lower -}}
{{- if or (eq $create "true") (eq $create "clusterrole") }}true{{- end }}

Copilot uses AI. Check for mistakes.
@sleeyax
Copy link
Contributor Author

sleeyax commented Feb 23, 2026

@yonahd Do you actually care about the comments made by copilot? Seems like it's mostly nitpicking on things. Also most of it is no longer relevant now that I implemented your suggestion.

I would appreciate a final human review more.

yonahd
yonahd previously approved these changes Feb 26, 2026
Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Thanks for the contribution!

@yonahd
Copy link
Owner

yonahd commented Feb 26, 2026

@sleeyax I'd like to merge.
The Readme needs to be regenerated to pass CI

@sleeyax
Copy link
Contributor Author

sleeyax commented Feb 26, 2026

@sleeyax I'd like to merge.
The Readme needs to be regenerated to pass CI

You should have push permission to the branch. Otherwise I'll update it in 2 hours or so from now.

@sleeyax
Copy link
Contributor Author

sleeyax commented Feb 27, 2026

@yonahd I just regenerated the README.md. Hopefully the pipeline succeeds now.

@yonahd yonahd merged commit 2e69ecc into yonahd:main Feb 27, 2026
2 checks passed
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.

Feature (helm): make it possible to customize ClusterRole (specifically; cluster-scoped resources)

4 participants