问题
Can I set the default namespace? That is:
$ kubectl get pods -n NAMESPACE
It saves me having to type it in each time especially when I'm on the one namespace for most of the day.
回答1:
Yes, you can set the namespace as per the docs like so:
$ kubectl config set-context $(kubectl config current-context) --namespace=NAMESPACE
Alternatively, you can use kubectx for this.
回答2:
You can also use a temporary linux alias:
alias k='kubectl -n kube-system '
Then use it like
k get pods
That's it ;)
来源:https://stackoverflow.com/questions/54902676/can-i-set-a-default-namespace-in-kubernetes