Working In A Namespace
Part of the Introduction to Kubernetes section of Coddy's Terminal journey. Lesson 31 of 45.
To create or look at objects in a namespace other than default, add -n to the command:
kubectl run api --image=redis -n dev
kubectl get pods -n devWithout -n, kubectl get pods still looks in default, where the api Pod does not exist.
To see everything at once, ask for all namespaces with -A:
kubectl get pods -AThe table gains a NAMESPACE column, and you will spot the cluster's own Pods in kube-system.
If you are going to work in one namespace for a while, make it the default for your context:
kubectl config set-context --current --namespace=devFrom then on every command without -n uses dev.
Challenge
EasyCreate a namespace named dev and start a Pod named api from the redis image inside it. List the Pods in dev, then list the Pods without -n to see that default is empty.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Introduction to Kubernetes
Practice on your own: Terminal playground