Can I set a default namespace in Kubernetes?

自作多情 提交于 2020-03-13 07:23:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!