
This command allows you to create custom contexts in your kubeconfig file. Next, we looked at the kubectl config create-context command. This command allows you to switch between Kubernetes contexts. Next, we looked at the kubectl config set-context command. This command is used to list and view Kubernetes contexts. We started by showing you the kubectl config get-contexts command. In this article, we covered the kubectl command line tool. The below screenshot shows the output.įigure: The output of kubectl config delete-context command #Conclusion The above command will delete the context named demo from the current Kubernetes configuration. To find the current context, you can simply run the following command: If you want to work with multiple Kubernetes clusters, you can create additional contexts. This context points to a local Kubernetes cluster running on your development machine.
#KUBECTL GET CONTEXTS INSTALL#
When you first install Kubernetes, a default context is created for you. This command is part of the kubectl utility, which interacts with Kubernetes clusters. The kubectl config get-contexts is a command that retrieves information about the current Kubernetes context. For example, if you have multiple Kubernetes clusters, each with its own set of users and permissions, you can use kubectl config use-context to switch between them.

It’s helpful if you need to access different clusters for different purposes or if you want to limit your access to certain parts of a cluster.
#KUBECTL GET CONTEXTS HOW TO#
If you’re new to Kubernetes, the following resources can help you learn about the platform and how to get started. To install kubectl, you simply need the run the commands as per the installation guide. You can use it to manage Kubernetes resources such as pods, services, and deployments. The kubectl utility is a command line interface (CLI) for interacting with Kubernetes. In this post, you’ll learn how the kubectl command can be used to manage your Kubernetes contexts, making it easier for you. While Kubernetes is a powerful tool, it can be daunting for beginners to get started. It’s now one of the most popular ways to deploy and manage large-scale applications. Set cluster (run in directory where ca.Kubernetes, the open source container orchestration system, has gained a lot of traction in the past few years.

On a fresh machine, follow these steps (given the ca.cert and $endpoint information retrieved above: Name=`kubectl config get-contexts $c | awk '"`

Get information from your kubectl config (current-context, server.) # get current context Get service account token from secret user_token=$(kubectl get secret $secret -o json | jq -r '.data' | base64 -D) Get ca.crt from secret (using OSX base64 with -D flag for decode) kubectl get secret $secret -o json | jq -r '.data' | base64 -D > ca.crt Get related secret secret=$(kubectl get sa alice -o json | jq -r. Create service account for user Alice kubectl create sa alice
