WEBVTT

00:02.000 --> 00:06.553
-In this video,
we will go over the solution for the lab

00:06.720 --> 00:07.920
on namespaces.

00:09.038 --> 00:12.900
The first question is how many namespaces
exist on the system?

00:13.530 --> 00:19.110
For this we run
the kubectl get namespaces command.

00:22.234 --> 00:25.422
You could also run
the kubectl get ns command.

00:25.589 --> 00:28.072
That's the short form for namespaces.

00:30.240 --> 00:33.923
The question is to identify
the number of namespaces.

00:34.090 --> 00:40.834
You have 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, so there are 10 namespaces.

00:45.665 --> 00:50.726
The next question is how many pods exist
in the research namespace?

00:51.330 --> 00:53.676
To look at the pods,
we know that we run

00:53.843 --> 00:58.579
the kubectl get pods command,
but to look into a particular namespace,

00:58.916 --> 01:01.623
we specify the namespace option.

01:02.580 --> 01:06.328
The namespace we got
to look to is research.

01:09.163 --> 01:11.942
That's the research namespace.
There are two pods.

01:13.800 --> 01:17.504
Another way to do this,
if you don't want to type the full option,

01:17.671 --> 01:25.501
is just to use the -n, and that's two.

01:30.080 --> 01:34.393
The next question is create a pod
in the finance namespace using

01:34.560 --> 01:36.211
the spec given below.

01:37.020 --> 01:40.020
We know that to create a pod,
we run the kubectl run command.

01:41.081 --> 01:44.639
Then we pour the name which happens
to be redis and the image

01:45.269 --> 01:49.164
is redis as well, but we don't want
to create it in the default namespace.

01:49.331 --> 01:50.833
If I run this command,
it's going to create the pod

01:51.000 --> 01:53.233
in that default namespace,
but we want to create it

01:53.400 --> 01:54.633
in the finance namespace.

01:54.800 --> 02:01.926
You've got to use the namespace option
and then specify finance.

02:03.544 --> 02:10.860
Then we run the get pods command, again,
in the finance namespace to make sure

02:11.160 --> 02:13.266
that the pod is created.

02:18.432 --> 02:23.346
The next question is which namespace
has the blue pod in it.

02:24.312 --> 02:28.769
We know that running
the get ns command lists

02:28.936 --> 02:30.097
all the namespaces.

02:30.685 --> 02:34.440
One thing we could do is just go
through each namespace as we did here

02:34.830 --> 02:39.733
and identify and look for that pod
or another option is we do have

02:39.900 --> 02:48.389
a command called kubectl get pods
--all-namespaces.

02:50.340 --> 02:53.257
This lists the pods in all namespace.

02:53.424 --> 02:56.174
You have the namespace here,
and you have the pods here.

02:56.490 --> 03:01.440
From here, we can identify the blue pod
and it's in the marketing namespace.

03:01.770 --> 03:04.997
Another option
is we stop typing --all-namespaces,

03:05.164 --> 03:11.217
you just do a -A, and that, also,
gives you the same output.

03:13.296 --> 03:16.089
Blue is in the marketing namespace.

03:19.491 --> 03:25.543
The Blue application is available for us
to access and it can be accessed using

03:25.710 --> 03:27.891
the link above your terminal.

03:28.058 --> 03:30.411
Let's click on that.

03:31.020 --> 03:33.207
This is the Blue application.

03:33.374 --> 03:38.335
It's a simple web application
that can be used for connectivity tests.

03:39.510 --> 03:41.841
Nothing so let's click on okay.

03:43.920 --> 03:47.653
The question is what DNS name should
the Blue application use to access

03:47.820 --> 03:51.186
the database db-service
in its own namespace?

03:51.839 --> 03:59.370
If we run the kubectl get pods command
in the marketing namespace,

03:59.850 --> 04:05.070
we see that it has the Blue application.

04:05.700 --> 04:09.421
There's a redis-db
but I believe there's also

04:15.027 --> 04:20.571
a service called db-service
within the same namespace.

04:21.150 --> 04:23.863
How does the Blue application access
the db-service?

04:24.030 --> 04:26.730
We've learned that
if it's within the same namespace,

04:27.840 --> 04:32.310
an application can access
another service just by using its name.

04:34.740 --> 04:36.974
We can test it in this interface.

04:37.141 --> 04:42.899
It's a db-service
and the pod number is 6379.

04:43.066 --> 04:44.574
That's where it is.

04:45.771 --> 04:48.844
Let's click on test and that's a success.

04:49.011 --> 04:53.778
We could just refer to it as db-service
if it's within your own namespace.

04:56.100 --> 04:59.443
Now the next question is what DNS name
should the Blue application use to access

04:59.610 --> 05:02.614
the database db-service in the "dev"
namespace.

05:03.019 --> 05:04.979
There's another namespace called "dev",

05:08.086 --> 05:09.319
and there's a service there too.

05:09.486 --> 05:11.655
There are two services
by the name db-service.

05:11.822 --> 05:15.309
One is in the marketing
and the other is in the dev namespace.

05:16.043 --> 05:21.300
An application blue
in the marketing namespace can access

05:21.999 --> 05:27.943
the application or a service
in the dev namespace but for that,

05:28.110 --> 05:32.010
you've got to use the full address
of that service that includes

05:32.380 --> 05:34.562
the namespace service.

05:34.729 --> 05:41.010
That's db-service.dev,
that's the namespace,

05:41.220 --> 05:43.995
and then you have svc.cluster.local.

05:44.640 --> 05:52.248
We can try that here,
dev is the namespace, svc.cluster.local.

05:53.015 --> 05:54.015
Click on test.

05:54.990 --> 05:56.140
That's correct.

05:56.307 --> 05:58.475
Let's select that.

06:00.387 --> 06:02.453
Yes, that's the correct answer.

06:02.790 --> 06:04.091
That's the end of the lab.

