Kubectl Switch Contexts |work| Access
Type :context inside the K9s dashboard to view all available environments.
export KUBECONFIG=~/.kube/config:~/projects/dev-config:~/projects/prod-config Use code with caution. kubectl switch contexts
kubectl port-forward service/payment-api 8080:80 -n payment-system Type :context inside the K9s dashboard to view
If you only need to verify the name of your current active workspace without printing the entire list, use: kubectl config current-context Use code with caution. Switch Contexts Using Native Kubectl Switch Contexts Using Native Kubectl Instead of globally
Instead of globally switching your main configuration to production, isolate dangerous tasks to a single terminal window using inline environment variables:
Kubernetes administrators often manage multiple clusters across development, staging, and production environments. Efficiently switching between these environments is critical for speed and preventing catastrophic deployment errors. The native tool for this workflow is kubectl config use-context .
: You can automate the switching of contexts within scripts to streamline automated deployments across multiple clusters.