Repository navigation
fix(manifests): do not grant the manager create on runtimes and OptimizationJobs in the Helm chart - #4271
Conversation
…izationJobs in the Helm chart Signed-off-by: Aarushi Tandon <aarushi.tandon0@gmail.com>
|
/area deployment |
harshrajdebug
left a comment
There was a problem hiding this comment.
I checked this against current master (4669ad8).
- No +kubebuilder:rbac marker grants create on clustertrainingruntimes, trainingruntimes or optimizationjobs, and the manager code never creates them. The runtime controllers only merge-patch existing runtimes, the OptimizationJob controller patches its own status and server-side applies its Deployment and Service, and the runtime snapshot is a ConfigMap. The bundled runtimes are installed by the installer and cleanup Jobs under their own ServiceAccount and ClusterRole, which keep their create.
- With helm v3.18.6 and helm-unittest 1.1.1, the versions pinned in the Makefile, the chart tests pass (22 suites, 98 tests). With only the old clusterrole.yaml template, exactly the three new assertions fail.
- Comparing the chart's rules with manifests/base/rbac/role.yaml by API group and resource gives 26 entries on each side, with 3 verb mismatches before this change and none after. The rules block has no template directives, so it renders as written.
- Merged into current master, the two still match. #4202, which adds optimizationjobs/finalizers to the same file, merges cleanly with this PR in either order, with 27 entries and no mismatches. #4254 and #4269, which also edit this ClusterRole, merge with it as well and leave no mismatches.
The new tests pin the two trainer.kubeflow.org rules. Apart from those and the tokenreviews and subjectaccessreviews rules, the test file asserts no rule, so drift in the others, such as the finalizers and status rule or the jobsets rule, would still pass. The check proposed in #4270, comparing the rendered ClusterRole with role.yaml in CI, would cover the whole file and could be a follow-up.
andreyvelich
left a comment
There was a problem hiding this comment.
I think, this is valid fix since controller doesn't need create RBAC for OptimizationJob or Runtimes.
/ok-to-test
/cc @aniket2405 @akshaychitneni @robert-bell
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
What this PR does / why we need it
Problem
manifests/base/rbac/role.yamlis generated bycontroller-genfrom the+kubebuilder:rbacmarkers. It deliberately splits thetrainer.kubeflow.orgresources into two rules:trainjobsreceivescreate, because the OptimizationJob controller creates TrainJobs.clustertrainingruntimes,trainingruntimes, andoptimizationjobsreceive onlyget,list,patch,update, andwatch.The Helm chart's hand-maintained ClusterRole previously combined all four resources into a single rule that included
create. Consequently, a Helm-installed controller manager could also create ClusterTrainingRuntimes, TrainingRuntimes, and OptimizationJobs cluster-wide, despite not requiring those permissions.This caused an RBAC inconsistency between the Helm and Kustomize installation paths and violated the principle of least privilege.
Installing bundled runtimes does not depend on these permissions. The runtime installer and cleanup Jobs use their own ServiceAccount and ClusterRole (
charts/kubeflow-trainer/templates/runtimes/rbac.yaml), while the controller-manager ClusterRole is bound only to the manager ServiceAccount.Changes
This PR:
Corrects the Helm ClusterRole by splitting the combined
trainer.kubeflow.orgrule into two rules matching the generated RBAC manifest:clustertrainingruntimes,trainingruntimes, andoptimizationjobs:get,list,patch,update,watch.trainjobs:create,get,list,patch,update,watch.Updates the Helm unit tests to assert both corrected rules.
Adds a
notContainsassertion against the previous over-permissive combined rule, preventing the same regression from silently passing CI.The result is consistent controller-manager permissions across Helm and Kustomize installations.
No functional behavior changes: this PR only removes unnecessary
createpermissions that the controller manager does not use.Verification
make helm-unittest— all 22 suites and 98 tests pass.helm templateand comparing its permissions againstmanifests/base/rbac/role.yamlconfirms:Expected Outcome
trainjobsreceives thecreatepermission among the affected resources.Which issue(s) this PR fixes
Fixes #4270
Checklist
Documentation: Not applicable. This change only narrows unused RBAC permissions in the Helm chart to match the generated manifests. There are no user-facing API, CLI, or behavior changes requiring documentation.