Context "staging" modified. Now, any kubectl get pods will automatically show pods in the backend namespace. This is non-destructive; you can always override it with -n frontend when needed. You don't have to be using a context to modify it. To change the default namespace for the development context (even if you are currently in production ):
cat ~/.kube/config A context entry in the file looks like this:
kubectl get ns # Output shows resources in default namespace (or whatever is set) To change the default namespace for your current context to backend :
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:
The command kubectl set-context allows you to create or modify these profiles without ever touching a YAML file. The basic syntax is:
kubectl set-context --current --namespace=backend Output:
Check your current namespace:
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.
USD
EUR
GBP
CAD
AUD
HKD
JPY
KRW
SGD
NZD
THB
繁體中文
日本語
한국어
ไทย
Français
Español
Deutsch
Português
italiano
Nederlands
English







