Skip to content

Instantly share code, notes, and snippets.

@dantejauregui
Last active December 3, 2023 22:13
Show Gist options
  • Save dantejauregui/7a05546945a531fc444fbc0a1bddbc08 to your computer and use it in GitHub Desktop.
Save dantejauregui/7a05546945a531fc444fbc0a1bddbc08 to your computer and use it in GitHub Desktop.
Changing different Contexts (Kubernetes distributions)
1.To find the current Context, you can simply run the following command:
kubectl config current-context
2.To list all of the available Kubernetes Contexts in our .KubeConfig file:
kubectl config get-contexts
3.To switch to a different Kubernetes Context that exists in our .KubeConfig file:
kubectl config use-context <context-name>
==========================
EXTRA COMMANDS:
-To view information about a specific Context from our .KubeConfig file:
kubectl get context <context-name>
kubectl get context staging
-to create a new context in a kubeconfig file:
kubectl config set-context <context-name> --namespace=<namespace-name> --user=<user-name> --cluster=<cluster-name>
kubectl config set-context staging --cluster=staging --namespace=staging --user=staging-admin
-to delete an existing context from a kubeconfig file:
kubectl config delete-context <context-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment