How I create new namespace in Kubernetes

后端 未结 3 602
星月不相逢
星月不相逢 2021-02-03 20:44

I work in a multi-tenant node app, I know to create a new namespace in Kubernetes is possible to run a kubectl command as follow: kubectl create namespace

3条回答
  •  天涯浪人
    2021-02-03 21:10

    you can create namespace using below command:

    kubectl create namespace << namespace_name>>.

    Please find below some examples

    kubectl create namespace dev 
    kubectl create namespace test
    kubectl create namespace prod
    

    To see namespace created:

    kubectl get namespace   
         or  
    kubectl get ns
         or 
    kubectl get namespaces 
    

    To avoid mentioning namespace in every kubectl command execution like while creating pod,deployment or any other kubernetes object, set namespace like as mentioned below:

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

    I hope this helped!!

提交回复
热议问题