Manage Kubernetes contexts and clusters in kubeconfig.
medium risk
kubectl uses kubeconfig (~/.kube/config) to store cluster credentials and contexts. A context pairs a cluster with credentials and a namespace. Managing multiple clusters requires switching contexts — and verifying you're in the right one before destructive operations.
kubectl config get-contextsList all available contexts · explain & risk-check →kubectl config current-contextShow the active context · explain & risk-check →kubectl config use-context prod-clusterSwitch to production cluster context · explain & risk-check →kubectl config set-context --current --namespace=productionSet default namespace for current context · explain & risk-check →KUBECONFIG=~/.kube/cluster1:~/.kube/cluster2 kubectl config view --merge --flatten > ~/.kube/configMerge multiple kubeconfig files · explain & risk-check →Install kubectx and kubens (`brew install kubectx`) for fast context/namespace switching. Set a PS1 prompt that shows current context — catching wrong-cluster mistakes before they happen.
Reference text is hand-written and may be incomplete — check man kubeconfig for your version. Test destructive commands on a non-production system first.