我可以在Kubernetes中设置默认名称空间吗?
问题描述:
我可以设置默认名称空间吗?那就是:
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.
答
Yes, you can set the namespace as per the docs like so:
$ kubectl config set-context --current --namespace=NAMESPACE
或者,您可以为此使用 kubectx .
Alternatively, you can use kubectx for this.