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

Add kubectl config list-contexts #25383

Closed
janetkuo opened this issue May 10, 2016 · 9 comments · Fixed by #25463
Closed

Add kubectl config list-contexts #25383

janetkuo opened this issue May 10, 2016 · 9 comments · Fixed by #25463
Labels
area/kubectl priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@janetkuo
Copy link
Member

kubectl config list-contexts will list the available cluster names to switch.

@kubernetes/kubectl

@janetkuo janetkuo added priority/backlog Higher priority than priority/awaiting-more-evidence. area/kubectl team/ux labels May 10, 2016
@zhouhaibing089
Copy link
Contributor

zhouhaibing089 commented May 10, 2016

This reminds me that I found it is really a suffer to tell our end user to setup their kubectl configuration. say the user needs to type:

$ kubectl config set-cluster --server=xxx
$ kubectl config set-credentials xx --username=xxx password=xxxx
$ kubectl config set-context xxx --cluster=xxx --user=xxx --namespace=xxxx
$ kubectl config use-context xxxx

I think that's a lots of commands that user needs to remember and type, if we could provide a much simply command for the new, it would be much help. Like this one:

$ kubectl init <name> <server>
username: xxxx
password: xxxx

@smarterclayton
Copy link
Contributor

We have in the past said that "kubectl login ..." would do that for you,
but we need to sort out what login means when we have an arbitrary number
of possible ways to log in. Some of that discussion has been moving along.

On Tue, May 10, 2016 at 10:44 AM, zhouhaibing089 notifications@github.com
wrote:

This reminds me that I found it is really a suffer to teach end user to
setup their kubectl configuration. say the users need to type:

$ kubectl config set-cluster --server=xxx
$ kubectl config set-credentials xx --username=xxx password=xxxx
$ kubectl config set-context xxx --cluster=xxx --user=xxx --namespace=xxxx
$ kubectl config use-context xxxx

I think that's a lots of commands that user needs to remember and type, if
we could provide a much simply command for the new, it would be much help.
Like this one:

$ kubectl init username: xxxxpassword: xxxx


You are receiving this because you are on a team that was mentioned.
Reply to this email directly or view it on GitHub
#25383 (comment)

@yissachar
Copy link

When this is added it would be nice if the bash completion could use it to power completion for use-context.

e.g.

kubectl config use-context aws_

completes to

kubectl config use-context aws_kubernetes

@asalkeld
Copy link

I'd like to work on this, can someone assign it to me please? I'll have a PR up soon.

@adohe-zz
Copy link

@asalkeld that's awesome. @janetkuo ptal.

@asalkeld
Copy link

Note: I haven't added the tab completion for use-context, that completions bash script looks like serious magic :-O

@bgrant0607
Copy link
Member

See also #20605

k8s-github-robot pushed a commit that referenced this issue Jul 5, 2016
Automatic merge from submit-queue

Add command "kubectl config get-contexts"

```release-note
* A new command "kubectl config get-contexts" has been added.
```

fixes #25383
@timbunce
Copy link

timbunce commented Oct 3, 2016

For the record, here's a way to list contexts in v1.3: kubectl config view -o jsonpath='{.contexts[*].name}'

@arshbot
Copy link

arshbot commented Apr 4, 2019

There's a friendlier command available now which shows all the current contexts, which one you're in, names, clusters, authinfo, and namespaces

$ kubectl config get-contexts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants