-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix namespace-scoped install #212
Conversation
Motivation There are some problems when installing in namespace-scoped mode: - Though the docs mentioned that the RBAC should be changed, the install script currently applies the controller ClusterRole and ClusterRoleBinding (including namespace resource permission) regardless of whether the --namespace-scope-mode option is provided - The combination of the NAMESPACE_SCOPE=true env var and namespace resource permissions results in a broken/conflicted state where the controller will "mostly" operate in cluster scoped mode and watch / delete resources in other namespaces Modifications - Split RBAC manifests into cluster-scope and namespace-scope variants, the latter including Role/RoleBinding instead of Cluster level equivalents - Have install script apply the appropriate RBAC based on the namespace-scope-mode cli setting (in addition to setting the controller env var as is already done) - Change the controller init logic to always use namespace mode if the env var is set - Update documentation accordingly Result Namespace scoped install works properly, won't touch any other namespaces Signed-off-by: Nick Hill <[email protected]>
scripts/delete.sh
Outdated
# Determine whether a modelmesh-controller-rolebinding clusterrolebinding exists and is | ||
# associated with the service account in this namespace. If not, don't delete the cluster level RBAC. | ||
set +e | ||
crb_ns=$(oc get clusterrolebinding modelmesh-controller-rolebinding -o json | jq -r .subjects[0].namespace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we stay with kubectl instead of oc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @chinhuang007 good catch, now fixed.
Signed-off-by: Nick Hill <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks, @njhill !
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chinhuang007, njhill The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Motivation
There are some problems when installing in namespace-scoped mode:
ClusterRole
andClusterRoleBinding
(including namespace resource permission) regardless of whether the--namespace-scope-mode
option is providedNAMESPACE_SCOPE=true
env var and namespace resource permissions results in a broken/conflicted state where the controller will "mostly" operate in cluster scoped mode and watch / delete resources in other namespacesModifications
Role
/RoleBinding
instead of Cluster level equivalentsResult
Namespace scoped install works properly, won't touch any other namespaces.
It would probably also be good to add some safeguard checks to detect/prohibit cluster scope installs in more than one namespace, but that's outside of the scope of this PR.