How to switch kubectl clusters between gcloud and minikube
You can switch from local (minikube) to gcloud and back with:
kubectl config use-context CONTEXT_NAME
to list all contexts:
kubectl config get-contexts
You can create different enviroments for local and gcloud and put it in separate yaml files.
A faster shortcut to the standard kubectl commands is to use kubectx:
- List contexts:
kubectx
- Equivalent to
kubectl config get-contexts
- Equivalent to
- Switch context (to foo):
kubectx foo
- Equivalent to
kubectl config use-context foo
- Equivalent to
To install on macOS: brew install kubectx
The kubectx package also includes a similar tool for switching namespaces called kubens
.
These two are super convenient if you work in multiple contexts and namespaces regularly.
More info: https://ahmet.im/blog/kubectx/