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

kubeconfig: remove default namespace from crc-developer context #4420

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

anjannath
Copy link
Member

the 'developer' user don't have the required role-bindings to access the 'default' namespace and when user tries to access it we get:

Error from server (Forbidden): pods is forbidden: User "developer" cannot list resource "pods" in API group "" in the namespace "default"

fixes crc-org/snc#703

Copy link

openshift-ci bot commented Oct 28, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from anjannath. For more information see the Kubernetes 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

return err
}

developerToken, err := getTokenForUser("developer", "developer", ip, ca, clusterConfig, ingressHTTPSPort)
if err != nil {
return err
}
if err := addContext(cfg, clusterConfig.ClusterAPI, developerContext, "developer", developerToken); err != nil {
if err := addContext(cfg, clusterConfig.ClusterAPI, developerContext, "developer", developerToken, ""); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens with the namespace set to "" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

with an empty namespace in the context we still get the same error, but oc config get-contexts no longer shows a namespace for the crc-developer context

% oc config get-contexts
CURRENT   NAME            CLUSTER                AUTHINFO                         NAMESPACE
          crc-admin       api-crc-testing:6443   kubeadmin/api-crc-testing:6443   default
*         crc-developer   api-crc-testing:6443   developer/api-crc-testing:6443

Copy link
Member

Choose a reason for hiding this comment

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

It is not only that but now when user try to check project switch to any project then it provide better error message instead forbidden error, we should have that as part of commit log.

$ oc config get-contexts
CURRENT   NAME            CLUSTER                AUTHINFO                         NAMESPACE
          crc-admin       api-crc-testing:6443   kubeadmin/api-crc-testing:6443   default
*         crc-developer   api-crc-testing:6443   developer/api-crc-testing:6443   

$ oc project
No project has been set. Pass a project name to make that the default.

$ oc project demo
error: You are not a member of project "demo".
You are not a member of any projects. You can request a project to be created with the 'new-project' command.

Copy link
Contributor

Choose a reason for hiding this comment

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

These are good reasons for the change, thanks for the explanations. Can this be added to the commit log?

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, i've updated the commit log to contain the error messages shown after the changes in this PR

"foo/abcdd-api-com",
},
{
input{"https://api.crc.testing:6443", "kubeadmin", "kubeadm", "secretToken"},
input{"https://api.crc.testing:6443", "kubeadmin", "kubeadm", "secretToken", "default"},
"kubeadmin/api-crc-testing:6443",
},
Copy link
Member

Choose a reason for hiding this comment

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

@anjannath we should add one more test case which have empty string as namespace which make sure the context is added to kubeconfig but without namespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated the test

@anjannath anjannath force-pushed the con-dev branch 3 times, most recently from f9b00f5 to 5237225 Compare November 4, 2024 09:13
the 'developer' user don't have the required role-bindings to access
the 'default' namespace and when user tries to access it we get:

```
Error from server (Forbidden): pods is forbidden: User "developer" cannot list resource "pods" in API group "" in the namespace "default"
```
with the changes in this commit, we get a better error message:

```
$ oc config get-contexts
CURRENT   NAME            CLUSTER                AUTHINFO                         NAMESPACE
          crc-admin       api-crc-testing:6443   kubeadmin/api-crc-testing:6443   default
*         crc-developer   api-crc-testing:6443   developer/api-crc-testing:6443

$ oc project
No project has been set. Pass a project name to make that the default.

$ oc project demo
error: You are not a member of project "demo".
You are not a member of any projects. You can request a project to be created with the 'new-project' command.
```

fixes crc-org/snc#703
Copy link

openshift-ci bot commented Nov 4, 2024

@anjannath: The following test 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/e2e-crc aaf0e2e link true /test e2e-crc

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.

@praveenkumar praveenkumar merged commit 5b09ebf into crc-org:main Nov 4, 2024
25 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'developer' user doesn't have access to 'default' namespace
3 participants