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

feat: allow the service account to be in a different namespace than t… #1952

Closed
wants to merge 1 commit into from

Conversation

machine424
Copy link

@machine424 machine424 commented Dec 12, 2024

…he rolebinding for 'policy {add,remove}-[cluster]-role-to-user'

  • add tests

…he rolebinding for 'policy {add,remove}-[cluster]-role-to-user'
@machine424 machine424 marked this pull request as draft December 12, 2024 09:22
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 12, 2024
Copy link
Contributor

openshift-ci bot commented Dec 12, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: machine424
Once this PR has been reviewed and has the lgtm label, please assign atiratree for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@@ -178,6 +179,7 @@ func NewCmdAddRoleToUser(f kcmdutil.Factory, streams genericiooptions.IOStreams,
cmd.Flags().StringVar(&o.RoleBindingName, "rolebinding-name", o.RoleBindingName, "Name of the rolebinding to modify or create. If left empty creates a new rolebinding with a default name")
cmd.Flags().StringVar(&o.RoleNamespace, "role-namespace", o.RoleNamespace, "namespace where the role is located: empty means a role defined in cluster policy")
cmd.Flags().StringSliceVarP(&o.SANames, "serviceaccount", "z", o.SANames, "service account in the current namespace to use as a user")
cmd.Flags().StringVar(&o.SANamespace, "serviceaccount-namespace", o.SANamespace, "namespace where the service account is located: empty means the default namespace")
Copy link
Member

Choose a reason for hiding this comment

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

From user point of view, it is already very hard for users to use these commands (e.g. adm policy *) as the current flag set (and their interactions between each other) is already hard to understand. I'd not prefer adding a new flag that makes the case worse.
$ oc project test-proj
$ oc policy add-role-to-user view user1
can still be used to modify the default namespace as a workaround.

Copy link
Author

Choose a reason for hiding this comment

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

As I tried to explain in https://issues.redhat.com/browse/RFE-6272, the rolebinding namespace will be test-proj but the service account is forced to be from that same namespace, one may want it to be from another namespace and kube api allows that.
I don't think the workaround can help with that.

I think with more doc and examples we could improve the UX, like we do for other commands with "too many" flags.

use case:

I have a predefined Role in openshift-foo and I want to assign it to a serviceacount in namespace bar.
The Role and RoleBinding should both be in openshift-foo (kube api requirement) but I don't want the serviceacount to be in openshift-foo.

Copy link
Contributor

openshift-ci bot commented Dec 12, 2024

@machine424: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/verify 6b55228 link true /test verify
ci/prow/e2e-aws-ovn-serial 6b55228 link true /test e2e-aws-ovn-serial
ci/prow/e2e-aws-ovn-upgrade 6b55228 link true /test e2e-aws-ovn-upgrade
ci/prow/okd-scos-e2e-aws-ovn 6b55228 link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@machine424
Copy link
Author

Forgot about oc create rolebinding that seems to allow having the role/binding and the SA in different namespaces, I'll give that a shot.

@machine424 machine424 closed this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants