kubectl config get-contexts -o name Cause : You may have an environment variable $KUBECONFIG pointing to a different file, or you're using a shell alias that hardcodes --context .
# Switch to the first context whose cluster name contains "fra1" CONTEXT=$(kubectl config get-contexts -o name | grep fra1 | head -1) kubectl config use-context "$CONTEXT" Many power users install kubectx for faster switching: kubectl change current context
:
unset KUBECONFIG alias | grep kubectl After switching context, always check your namespace: kubectl config get-contexts -o name Cause : You
kubectl config get-contexts -o name Cause : You may have an environment variable $KUBECONFIG pointing to a different file, or you're using a shell alias that hardcodes --context .
# Switch to the first context whose cluster name contains "fra1" CONTEXT=$(kubectl config get-contexts -o name | grep fra1 | head -1) kubectl config use-context "$CONTEXT" Many power users install kubectx for faster switching:
:
unset KUBECONFIG alias | grep kubectl After switching context, always check your namespace: