How to switch namespace in kubernetes

前端 未结 7 1527
半阙折子戏
半阙折子戏 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 didn't like kubectx and kubens because they are adding one more letter for bash-complection to kubectl command.

    So I just wrote tiny kubectl-use plugin:

    # kubectl use prod
    Switched to context "prod".
    
    # kubectl use default
    Switched to namespace "default".
    
    # kubectl use stage kube-system
    Switched to context "stage".
    Switched to namespace "kube-system".
    

    If you interesting to it, check https://github.com/kvaps/kubectl-use

提交回复
热议问题