Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl how to list all contexts

Tags:

How do I view all the contexts I have set up with kubectl?

It doesn't appear there's a resource known to kubectl as 'contexts'

$ kubectl get contexts error: the server doesn't have a resource type "contexts" 
like image 437
arshbot Avatar asked Jan 06 '20 03:01

arshbot


People also ask

How do you check context in kubectl?

Kubectl current-context command shows the current context of kubectl. When you enter the 'kubectl config current-context' in the virtual machine environment, the following output will be displayed. The 'kubectl config use-context cluster-name' command is used to set the default context to the given cluster name.

What is kubectl set-context?

Specifically, kubectl config set-context only modifies the section of kubeconfig corresponding to the context. The following commands are the commands that allow you to add or modify cluster access and user credentials in your kubeconfig. You might notice some similarity to kubectl config set-context in its structure.

How do I change to different context in kubectl?

After your clusters, users, and contexts are defined in one or more configuration files, you can quickly switch between clusters by using the kubectl config use-context command. Note: A file that is used to configure access to a cluster is sometimes called a kubeconfig file.


1 Answers

You can view all contexts via the config command

$ kubectl config get-contexts 
like image 113
arshbot Avatar answered Sep 20 '22 13:09

arshbot