

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Namespaces
incomplete
2: Moving Namespaces
incomplete
3: Intra-Cluster DNS
incomplete
4: Namespace and Routing Review
incomplete
This lesson's interactive features are locked, please to keep using them
Up until this point, we've been working in the default namespace. When using kubectl commands, you can specify the namespace with the --namespace or -n flag. If you don't, it will use the default namespace.
wagslane@MacBook-Pro courses % kubectl get pod
NAME READY STATUS RESTARTS AGE
synergychat-api-646c6fd585-dk5db 1/1 Running 0 28m
synergychat-crawler-cd4947995-tcrkn 3/3 Running 0 39m
synergychat-web-846d86c444-d9c8q 1/1 Running 0 28m
synergychat-web-846d86c444-sk6n4 1/1 Running 0 28m
synergychat-web-846d86c444-w2pqg 1/1 Running 0 28m
vs.
wagslane@MacBook-Pro courses % kubectl -n kube-system get pod
NAME READY STATUS RESTARTS AGE
coredns-5d78c9869d-jwcbr 1/1 Running 0 4d
etcd-minikube 1/1 Running 0 4d
kube-apiserver-minikube 1/1 Running 0 4d
kube-controller-manager-minikube 1/1 Running 0 4d
kube-proxy-j2ssm 1/1 Running 0 4d
kube-scheduler-minikube 1/1 Running 0 4d
storage-provisioner 1/1 Running 1 (4d ago) 4d
The kube-system namespace is where all the core Kubernetes components live, it's created automatically when you install Kubernetes. You don't want to mess with it.
If you have a small cluster with only a few applications, you can probably get away with just using the default namespace. However, if you have a large cluster with many applications, and in particular many teams working on those applications, namespaces are a great way to keep things organized.
For the sake of learning, let's assume that we have a separate development team responsible for the crawler service at SynergyChat, and they want to have their own namespace.
Create a new namespace called crawler:
kubectl create ns crawler
Make sure it was created successfully:
kubectl get ns
Next, add namespace: crawler to the metadata section of each of the crawler resources and apply them. Interestingly, you should see that the resources are "created" not "updated". That's because they're now in a new namespace, and the unique identifier of a resource in Kubernetes is the combination of its name and its namespace.
Make sure your resources are now redeployed in the crawler namespace:
kubectl -n crawler get pods
kubectl -n crawler get svc
kubectl -n crawler get configmaps
Then go delete the old resources in the default namespace:
kubectl delete deployment <deployment-name>
kubectl delete service <service-name>
kubectl delete configmap <configmap-name>
Next, run:
kubectl proxy
Run and submit the CLI tests.