Three Pods were easy to keep apart. A real cluster runs hundreds, for several teams, in several environments. Namespaces keep them apart.
Rooms in a house
A namespace is a named part of the cluster. Every Pod lives in exactly one. Names only need to be unique inside their namespace, so web in shop and web in shop-test can both exist.
learner@shallows:~$ kubectl create namespace shop
namespace/shop created
learner@shallows:~$ kubectl get namespaces
NAME STATUS AGE
default Active 12d
kube-system Active 12d
shop Active 5sns is a short form you may use anywhere: kubectl create ns shop.
kubectl looks in one namespace
Every kubectl line works in one namespace. With no flag, that is default. The -n flag picks another one:
learner@shallows:~$ kubectl run web --image=nginx -n shop
pod/web created
learner@shallows:~$ kubectl get pods
No resources found in default namespace.
learner@shallows:~$ kubectl get pods -n shop
NAME READY STATUS RESTARTS AGE
web 1/1 Running 0 8s-A looks in every namespace at once and adds a NAMESPACE column:
learner@shallows:~$ kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-65bbc5489b-swtx8 1/1 Running 0 12d
shop web 1/1 Running 0 20skube-system holds the Pods that run the cluster itself. Leave them alone.
From here on, each lab keeps the Monster Market in its own namespace. The briefing names it.