Working With Kubernetes Namespaces

0 44

Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.

  1. Get pod details of other namespace using:
    kubectl get pods --namespace=dev
  2. By below command you will get pod details of default namespace
    kubectl get pods
  3. You can change default namespace by using:
    kubectl config set-context ${kubectl config current-context} --namespace=dev
  4. Now for getting pod details of default you need to use
    kubectl get pods --namespace=default
  5. Get all pods details across namespaces using:
    kubectl get pods --all-namespaces
  6. Creating a namespace using yml definition, please refer this link:
    kubectl create -f namespace-dev.yml
  7. Mentioning namespace in pod:
    kubectl create -f pod-definition.yml --namespace=dev
  8. Get list of system pods using:
    kubectl get pods --namespace=kube-system
  9. You can set resource limits on namespaces, here an example yml for same, please refer this link:
    kubectl create -f compute-quota.yml

Leave A Reply

Your email address will not be published.