refactor(charts): Change generation of RBAC templates#1520
refactor(charts): Change generation of RBAC templates#1520viccuad merged 7 commits intokubewarden:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1520 +/- ##
=======================================
Coverage 75.52% 75.52%
=======================================
Files 170 170
Lines 20902 20898 -4
=======================================
- Hits 15786 15783 -3
+ Misses 4904 4902 -2
- Partials 212 213 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
91c845d to
4e819cd
Compare
|
Also, I got a bit confused by the names:
I would like, if possible, to end up with something like sbomscanner:
In our case we would have 4 files:
|
I'm fine splitting role and rolebindings. I actually did that while I was working on this PR. But I've changed that because I would like to avoid two role files. The |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 28 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4c1795a to
8892c00
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 30 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 31 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \ | ||
| output:crd:artifacts:config=charts/kubewarden-crds/templates \ |
There was a problem hiding this comment.
make manifests now writes CRDs/RBAC into the Helm charts, but it no longer updates the existing kubebuilder/kustomize manifests under config/crd/bases and config/rbac (which are still referenced by config/**/kustomization.yaml). This can leave the kustomize install path stale/out-of-sync (e.g., config/rbac/role.yaml still lacks the webhook get verb). Either keep generating to config/ as well, or remove/deprecate the config/ kustomize overlays to avoid drift.
| paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \ | |
| output:crd:artifacts:config=charts/kubewarden-crds/templates \ | |
| paths="./api/policies/v1" paths="./internal/controller" paths="./cmd/controller" \ | |
| output:crd:artifacts:config=config/crd/bases \ | |
| output:crd:artifacts:config=charts/kubewarden-crds/templates \ | |
| output:rbac:artifacts:config=config/rbac \ |
There was a problem hiding this comment.
We plan to remove the config directory in the future. So, we can ignore this comment for now.
6d68425 to
2519539
Compare
Split the monolithic rbac.yaml into dedicated files for controller roles, bindings, metrics, and audit scanner. Redirect controller-gen output directly into chart templates with sed post-processing for Helm labels, annotations, and namespace templating. Rename CRD files to include the API group prefix and fix CRD comments. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
Clean up main.go imports and add kubebuilder RBAC markers for controller-level permissions (leases, configmaps, events, tokenreviews, subjectaccessreviews). Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
Fix error handling in getPolicies() which was only returning errors for IsNotFound, silently swallowing all other error types. Now all errors are properly propagated. Add explicit namespace scoping to List calls for ReplicaSets and Pods in isPolicyUniquelyReachable() to avoid unnecessary cluster-wide lookups. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
The controller calls Get() on ValidatingWebhookConfiguration and MutatingWebhookConfiguration during reconciliation and deletion, but the kubebuilder RBAC markers were missing the 'get' verb. With caching enabled this went unnoticed because list/watch cache served the reads. Add 'get' to the markers and regenerate the chart RBAC manifest. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
Add helm unit tests that validate the generated CRD and RBAC manifests. CRD tests verify resource type, name, and API group. RBAC tests verify that ClusterRoles and Roles include the expected Helm labels and that additionalLabels and additionalAnnotations are correctly propagated. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
Add a new additionalEnvironmentVariables Helm value that allows users to inject arbitrary environment variables into the controller deployment. Includes schema validation and helm unit tests. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
Pin the kwctl-installer GitHub Action to v4.6.1 for reproducible e2e test environments. Add a CI step that runs 'make manifests' and verifies the generated chart files are up to date. Fix autolabeler workflow permissions to use job-level scoping. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assited-by: Github Copilot
Description
Updates the controller-gen command used to generated the RBAC manifests into the charts/kubewarden-controller directory. This commit also adds the kubebuilder markers to add the missing permissions in the controller roles that was added using manully created roles definitions.
Fix #1483