openshift / oc

The OpenShift Command Line, part of OKD
https://www.openshift.org
Apache License 2.0
196 stars 377 forks source link

oc login should avoid clobbering kubeconfig contexts #283

Open TheLonelyGhost opened 4 years ago

TheLonelyGhost commented 4 years ago

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

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 commented 3 years ago

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

TheLonelyGhost commented 3 years ago

/remove-lifecycle stale

openshift-bot commented 3 years ago

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

TheLonelyGhost commented 3 years ago

/remove-lifecycle stale

openshift-bot commented 3 years ago

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

TheLonelyGhost commented 3 years ago

/lifecycle frozen

OddKMS commented 9 months ago

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 commented 8 months ago

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 commented 1 month ago

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.