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

oc login should avoid clobbering kubeconfig contexts #283

Open
TheLonelyGhost opened this issue Feb 4, 2020 · 10 comments
Open

oc login should avoid clobbering kubeconfig contexts #283

TheLonelyGhost opened this issue Feb 4, 2020 · 10 comments

Comments

@TheLonelyGhost
Copy link

TheLonelyGhost commented Feb 4, 2020

Default behavior of oc login https://openshift.example.com --username=thelonelyghost --password='hunter2' is to do the following:

  • Setup a new (or if exists, update) cluster in the kubeconfig by the name of openshift-example-com:443
  • Setup a new (or if exists, update) user in the kubeconfig by the name of thelonelyghost/openshift-example-com:443
  • Setup a new (or if exists, update) context in the kubeconfig by the name of default/openshift-example-com:443/thelonelyghost.
  • Set the current context to be default/openshift-example-com:443/thelonelyghost

This is fine for initial setup, but periodically I'm forced to login again to refresh the bearer token stored in the user section of the kubeconfig. When I do that, I must run the same oc login command again. Here's the problem:

If I re-run that command, it clobbers any changes I've made to human-facing names of the cluster, the context, or the user that have zero functional effect on the file. If I renamed the default/openshift-example-com:443/thelonelyghost context to be more user-friendly, such as company-prod, logging in again adds an additional context of default/openshift-example-com:443/thelonelyghost back again. It does not update credentials in-place, it adds them if they're not named exactly what is expected.

I've written a tool in python named oc-replacement to re-authenticate in-place as I desire, but it would be much more desirable for this to be default behavior or even an option with the oc command line tool.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 27, 2020
@TheLonelyGhost
Copy link
Author

/remove-lifecycle stale

@openshift-ci-robot openshift-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 1, 2020
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 30, 2020
@TheLonelyGhost
Copy link
Author

/remove-lifecycle stale

@openshift-ci-robot openshift-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 3, 2021
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 3, 2021
@TheLonelyGhost
Copy link
Author

/lifecycle frozen

@openshift-ci-robot openshift-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 5, 2021
@OddKMS
Copy link

OddKMS commented Dec 15, 2023

I'm hoping that this gets a bit of attention - it is quite annoying to have to deal with.

In addition, this completely mangles the kube-ps1 addon as it uses the separate config fields (context name, user name, cluster name, etc) to build up its output.

Using a normal kubeconfig it would look like this:
(⎈ |contextname:namespace)

Instead when using oc login the result is this:
(⎈ |namespacename/fullyqualifiedclusterservername:port/longformusername:namespace)

On the whole it is not a serious issue, but when have we devs ever let that stop us from complaining about something?

@reitzig
Copy link

reitzig commented Jan 16, 2024

What's curious is that certificate-authority is taken from an existing cluster with matching server, but then a new cluster is created anyway. So, there's some reading of the config file going on already.

My main pain point is indeed the long cluster names and longer context names that bloat (and kill) my shell prompt (in smaller windows).

@flippyboy
Copy link

I have created a support case with Red Hat about this and got the following reply:
After careful analysis, we've determined that resolving this problem requires a significant effort which we're not able to allocate to this issue at the moment.

If others with active support agreements feel that this is important to them, you can reference this when creating your own support request. If more people create requests, maybe it will get enough attention.

@ardaguclu
Copy link
Member

/remove-lifecycle frozen

@openshift-ci openshift-ci bot removed the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Feb 20, 2025
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

No branches or pull requests

7 participants