kubectl set-context development --cluster=staging-cluster This updates the development context to use staging-cluster instead of its original cluster. kubectl set-context modifies your kubeconfig file (usually ~/.kube/config ). You can see the changes directly:
Check your current namespace:
kubectl set-context --current --namespace=backend Output: kubectl set-context
cat ~/.kube/config A context entry in the file looks like this: kubectl set-context
kubectl set-context production --cluster=aws-prod --user=admin-user This creates the context but does not switch to it. To switch, you would run kubectl use-context production . This is the most common real-world use case. You have a context called staging , but you are tired of typing -n backend for every command. kubectl set-context