Skip to content
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

Merged
merged 2 commits into from
Aug 20, 2022
Merged

fix: Fix namespace-scoped install #212

merged 2 commits into from
Aug 20, 2022

Conversation

njhill
Copy link
Member

@njhill njhill commented Aug 19, 2022

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.

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.

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]>
# 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)
Copy link
Contributor

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?

Copy link
Member Author

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]>
Copy link
Contributor

@chinhuang007 chinhuang007 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, thanks, @njhill !

@kserve-oss-bot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@chinhuang007
Copy link
Contributor

/lgtm

@kserve-oss-bot kserve-oss-bot merged commit a125958 into main Aug 20, 2022
@njhill njhill deleted the ns-scope-fix branch October 11, 2022 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants