Can I set a default namespace in Kubernetes?

前端 未结 2 1768
耶瑟儿~
耶瑟儿~ 2020-12-29 22:34

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 o

相关标签:
2条回答
  • 2020-12-29 22:56

    You can also use a temporary linux alias:

    alias k='kubectl -n kube-system '
    

    Then use it like

    k get pods
    

    That's it ;)

    0 讨论(0)
  • 2020-12-29 22:59

    Yes, you can set the namespace as per the docs like so:

    $ kubectl config set-context --current --namespace=NAMESPACE
    

    Alternatively, you can use kubectx for this.

    0 讨论(0)
提交回复
热议问题