Skip to content

oc login should avoid clobbering kubeconfig contexts #283

@TheLonelyGhost

Description

@TheLonelyGhost

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions