openshift / openshift/origin

[RFE] oc CLI should preserve name of contexts

Open
#18,645 13 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/usability kind/feature lifecycle/frozen lifecycle/stale priority/P2 sig/master
Dominant language
Go
Stars
8.7k
Forks
4.8k
Avg merge
4d 10h
Merged PRs (30d)
53

Description

When working with OpenShift, it might happen that you connect to multiple clusters. These can be cloud clusters, on-premises, or even multiple profiles of minishift.
When you connect to a cluster, oc creates an entry for that context including cluster, user and namespace. These contexts that are created are given an automatic name by oc.

e.g.

default/console-cluster02-gce-pixy-io:8443/admin
default/127-0-0-1:8443/system:admin
devconfcz18/api-pro-us-east-1-openshift-com:443/jmorales@redhat.com

These names are difficult to handle and remember.

Kubernetes does promote giving these contexts a meaningful name in their documentation. But when you follow those practices in OpenShift, you run into many issues, which are what this issue/RFE wants to solve.

  • Login into an openshift cluster via "oc login" creates entries in .kube/config even if they exist with different name
  • "oc new-project" creates entries in .kube/config even if they exist with different name instead of just changing the current context's namespace
  • "oc project" creates entries in .kube/config even if they exist with different name instead of just changing the current context's namespace
  • "oc delete project" does not remove the namespace from the current context's context (or set a default)
  • "oc logout" does not unset the "current-context" but only remove the token.

There's probably other things that make "oc" misbehave with respect to keeping a sane .kube/config file.

There's references in k8s to make enhancements on the usability:

As well as references in other projects of the problem I described:

This RFE is to fix the behavior the "oc" client has with respect to using/interacting with .kube/config file.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how oc login, new-project, project, delete project, and logout read and write .kube/config, then compare that behavior with the referenced Kubernetes context guidance. Done means the CLI preserves meaningful existing context names and handles namespace and current-context changes consistently without creating avoidable duplicate entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
cli, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.