How to switch namespace in kubernetes

前端 未结 7 1526
半阙折子戏
半阙折子戏 2021-01-30 02:42

Say, I have two namespaces k8s-app1 and k8s-app2

I can list all pods from specific namespace using the below command

kubectl get pods -n 

        
7条回答
  •  无人共我
    2021-01-30 03:19

    I like my answers short, to the point and with references to official documentation:

    Answer:

    kubectl config set-context --current --namespace=my-namespace
    

    From:

    https://kubernetes.io/docs/reference/kubectl/cheatsheet/

    # permanently save the namespace for all subsequent kubectl commands in that context.
    kubectl config set-context --current --namespace=ggckad-s2
    

提交回复
热议问题