The command kubectl set-context allows you to create or modify these profiles without ever touching a YAML file. The basic syntax is:
Check your current namespace:
kubectl set-context --current --namespace=backend Output:
export KUBECONFIG=~/.kube/config:~/secrets/gke-config kubectl set-context gke-prod --cluster=gke-prod --user=gke-user The command will update the first writable file in the list (usually the first one). kubectl set-context is deceptively simple. It does one small thing—modifying a field in a text file—but that small thing is the foundation of safe, efficient multi-cluster Kubernetes administration.
# Good: Relies on context namespace kubectl get pods kubectl get pods -n default 3. Verify Before You Execute Create a shell alias to show your current context in your prompt:
The command kubectl set-context allows you to create or modify these profiles without ever touching a YAML file. The basic syntax is:
Check your current namespace:
kubectl set-context --current --namespace=backend Output:
export KUBECONFIG=~/.kube/config:~/secrets/gke-config kubectl set-context gke-prod --cluster=gke-prod --user=gke-user The command will update the first writable file in the list (usually the first one). kubectl set-context is deceptively simple. It does one small thing—modifying a field in a text file—but that small thing is the foundation of safe, efficient multi-cluster Kubernetes administration.
# Good: Relies on context namespace kubectl get pods kubectl get pods -n default 3. Verify Before You Execute Create a shell alias to show your current context in your prompt: