Working With Kubernetes Namespaces
Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.
- Get pod details of other namespace using:
kubectl get pods --namespace=dev
- By below command you will get pod details of default namespace
kubectl get pods
- You can change default namespace by using:
kubectl config set-context ${kubectl config current-context} --namespace=dev
- Now for getting pod details of default you need to use
kubectl get pods --namespace=default
- Get all pods details across namespaces using:
kubectl get pods --all-namespaces
- Creating a namespace using yml definition, please refer this link:
kubectl create -f namespace-dev.yml
- Mentioning namespace in pod:
kubectl create -f pod-definition.yml --namespace=dev
- Get list of system pods using:
kubectl get pods --namespace=kube-system
- You can set resource limits on namespaces, here an example yml for same, please refer this link:
kubectl create -f compute-quota.yml