-In this video, we will go over the solution for the lab
on namespaces.
The first question is how many namespaces exist on the system?
For this we run the kubectl get namespaces command.
You could also run the kubectl get ns command.
That's the short form for namespaces.
The question is to identify the number of namespaces.
You have 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, so there are 10 namespaces.
The next question is how many pods exist in the research namespace?
To look at the pods, we know that we run
the kubectl get pods command, but to look into a particular namespace,
we specify the namespace option.
The namespace we got to look to is research.
That's the research namespace. There are two pods.
Another way to do this, if you don't want to type the full option,
is just to use the -n, and that's two.
The next question is create a pod in the finance namespace using
the spec given below.
We know that to create a pod, we run the kubectl run command.
Then we pour the name which happens to be redis and the image
is redis as well, but we don't want to create it in the default namespace.
If I run this command, it's going to create the pod
in that default namespace, but we want to create it
in the finance namespace.
You've got to use the namespace option and then specify finance.
Then we run the get pods command, again, in the finance namespace to make sure
that the pod is created.
The next question is which namespace has the blue pod in it.
We know that running the get ns command lists
all the namespaces.
One thing we could do is just go through each namespace as we did here
and identify and look for that pod or another option is we do have
a command called kubectl get pods --all-namespaces.
This lists the pods in all namespace.
You have the namespace here, and you have the pods here.
From here, we can identify the blue pod and it's in the marketing namespace.
Another option is we stop typing --all-namespaces,
you just do a -A, and that, also, gives you the same output.
Blue is in the marketing namespace.
The Blue application is available for us to access and it can be accessed using
the link above your terminal.
Let's click on that.
This is the Blue application.
It's a simple web application that can be used for connectivity tests.
Nothing so let's click on okay.
The question is what DNS name should the Blue application use to access
the database db-service in its own namespace?
If we run the kubectl get pods command in the marketing namespace,
we see that it has the Blue application.
There's a redis-db but I believe there's also
a service called db-service within the same namespace.
How does the Blue application access the db-service?
We've learned that if it's within the same namespace,
an application can access another service just by using its name.
We can test it in this interface.
It's a db-service and the pod number is 6379.
That's where it is.
Let's click on test and that's a success.
We could just refer to it as db-service if it's within your own namespace.
Now the next question is what DNS name should the Blue application use to access
the database db-service in the "dev" namespace.
There's another namespace called "dev",
and there's a service there too.
There are two services by the name db-service.
One is in the marketing and the other is in the dev namespace.
An application blue in the marketing namespace can access
the application or a service in the dev namespace but for that,
you've got to use the full address of that service that includes
the namespace service.
That's db-service.dev, that's the namespace,
and then you have svc.cluster.local.
We can try that here, dev is the namespace, svc.cluster.local.
Click on test.
That's correct.
Let's select that.
Yes, that's the correct answer.
That's the end of the lab.