WEBVTT

00:00.633 --> 00:04.733
Let's go through this lab
on Ingress Controller.

00:05.273 --> 00:07.623
We have deployed
Ingress Controller resources

00:07.703 --> 00:09.243
and applications to explore the setup.

00:09.323 --> 00:12.203
Let's first look at the environment.

00:12.533 --> 00:14.193
Let's look at the nodes.

00:14.273 --> 00:15.923
There's a single node.

00:16.583 --> 00:19.503
Let's look at the deployments.

00:19.583 --> 00:21.263
There are no deployments.

00:21.413 --> 00:23.101
Let's check all namespaces.

00:24.563 --> 00:26.793
There are deployments in other namespaces.

00:26.873 --> 00:29.103
There are deployments in the app-space,

00:29.183 --> 00:30.483
the ingress-nginx space,

00:30.563 --> 00:32.213
the kube-system space.

00:32.543 --> 00:36.093
Let's look at the Ingress Controller,

00:36.173 --> 00:40.913
which is usually in kube-system namespace.

00:41.603 --> 00:46.893
We'll see it's in the ingress namespace,
which is--

00:46.973 --> 00:47.253
Sorry.

00:47.333 --> 00:50.573
It's given here, it's ingress-nginx.

00:53.033 --> 00:56.633
We see the Ingress Controller
and the other parts right here.

01:00.083 --> 01:03.623
Okay, which namespace
is the Ingress Controller deployed in?

01:04.133 --> 01:06.833
If you run a get pods -A command,

01:07.463 --> 01:10.173
we see all the pods and we see
the Ingress Controller here,

01:10.253 --> 01:13.613
and we see that it's part
of the ingress-nginx namespace.

01:13.823 --> 01:15.886
It's the ingress-nginx namespace.

01:18.593 --> 01:22.073
Now, what is the name
of the Ingress Controller Deployment?

01:22.823 --> 01:25.011
The Ingress Controller Deployment--

01:25.163 --> 01:26.523
This is the name of the deployment.

01:26.603 --> 01:30.713
We can also verify that by doing a get

01:30.803 --> 01:35.393
deploy in the ingress-nginx namespace,

01:35.813 --> 01:38.613
and we see
that it's ingress-nginx-controller.

01:38.693 --> 01:40.883
It's ingress-nginx-controller.

01:44.213 --> 01:47.393
Now, which namespace
are the applications deployed in?

01:48.593 --> 01:53.883
Here, we have the pods for the application,

01:53.963 --> 01:55.923
and we have the video there

01:56.003 --> 02:00.083
and the default backend application
there in the app-space namespace.

02:03.323 --> 02:05.913
How many applications are deployed
in the app-space namespace?

02:05.993 --> 02:09.713
We see that there are three pods,
so that's three applications.

02:12.953 --> 02:16.313
Now, which namespace
is the Ingress Resource deployed in?

02:16.763 --> 02:22.463
Let's look at the Ingress Resource,
so the kubectl get ingress,

02:23.303 --> 02:27.603
and we'll look at all namespaces, and we see

02:27.683 --> 02:30.433
that we have the ingress-wear-watch
resource,

02:30.593 --> 02:32.843
and it's in the app-space namespace.

02:36.293 --> 02:38.163
Now, what is the name
of the Ingress Resource?

02:38.243 --> 02:41.933
The name of the Ingress
Resource is ingress-wear-watch.

02:47.543 --> 02:50.903
Now, what is the Host configured
on the Ingress Resource?

02:51.773 --> 02:55.403
You can see that right here,
it's set to star.

02:55.793 --> 02:59.753
That means all hosts are applicable,
or all or any hosts.

03:03.083 --> 03:06.623
What backend is the /wear
path on the Ingress configured in?

03:07.193 --> 03:11.183
Let's look at the ingress

03:15.367 --> 03:21.623
ingress-wear-watch Ingress
Resource in a bit more detail.

03:22.853 --> 03:25.403
That's in the app-space namespace.

03:26.483 --> 03:29.673
Here, we see the additional details,
and we can see the rules.

03:29.753 --> 03:31.713
We see the host, and then we see the path,

03:31.793 --> 03:34.418
and we have the /wear and the /watch path.

03:35.723 --> 03:37.533
What backend is the /wear
path configured to?

03:37.613 --> 03:40.733
The /wear path is configured
to the wear-service,

03:40.973 --> 03:43.553
that's the wear-service.

03:46.973 --> 03:49.233
At what path is the video streaming

03:49.313 --> 03:51.663
application made available on the Ingress?

03:51.743 --> 03:53.133
The video streaming application,

03:53.213 --> 03:56.767
the video-service is at the watch path.

03:57.443 --> 03:58.943
Watch is the answer.

04:00.743 --> 04:04.403
If the requirement does not match
any of the configured paths,

04:04.553 --> 04:07.241
what service are the requests forwarded to?

04:07.823 --> 04:10.623
We know that if it does
not match any of these,

04:10.703 --> 04:12.993
it's going to go to the default backend.

04:13.073 --> 04:15.653
Here, it is default-http-backend.

04:16.463 --> 04:19.463
That's the service,
so that's default-http-backend.

04:21.503 --> 04:25.406
Now, view the Ingress Service using
the tab at the top of the terminal.

04:25.486 --> 04:30.153
Here, we have Ingress Service,
and if you look at it,

04:30.233 --> 04:33.473
it gives us a 404 not found error.

04:37.433 --> 04:38.223
Which page do you see?

04:38.303 --> 04:40.043
We see a 404 error page.

04:42.743 --> 04:45.033
Now, view the applications
by appending the /wear

04:45.113 --> 04:47.873
and /watch to the URL that you opened.

04:48.593 --> 04:51.443
Let me open this,

04:55.300 --> 04:59.063
and I have a /wear, which is this.

04:59.567 --> 05:04.733
This is the wear application,
and then we have the watch.

05:06.833 --> 05:09.893
Apparently,
this is the video streaming application.

05:12.143 --> 05:13.920
You are requested to change the URLs

05:14.000 --> 05:17.243
at which the applications
are made available.

05:17.603 --> 05:20.703
Make the video streaming
application available at /stream.

05:20.783 --> 05:22.523
For that, let's go and edit

05:24.713 --> 05:26.433
the Ingress Resource.

05:26.700 --> 05:29.543
Let's just replace describe with edit,

05:30.413 --> 05:32.313
and this one should be fairly easy.

05:32.393 --> 05:33.963
Here, we have the paths.

05:34.043 --> 05:35.973
We have the wear path for the wear service

05:36.053 --> 05:38.373
and then we have the watch
path for the watch service.

05:38.453 --> 05:42.623
All we have to do is replace
this with /stream.

05:44.153 --> 05:45.603
Now, let's save that.

05:45.683 --> 05:47.913
It's immediately replaced.

05:47.993 --> 05:51.623
If we refresh the watch path,
now we get a 404 error,

05:52.193 --> 05:55.043
and we replace it with stream,

05:55.733 --> 05:58.608
and we now get the video
streaming application.

05:59.483 --> 06:02.633
Let's check that out,
yes, that's successful.

06:03.323 --> 06:05.493
Now, view the video
application using the stream,

06:05.573 --> 06:08.903
which we already did it, so let's skip that.

06:09.443 --> 06:13.023
Now, a user is trying to view
the /eat URL on the Ingress Service.

06:13.103 --> 06:14.763
Which page would he see?

06:14.843 --> 06:17.120
We know that there's nothing called /eat.

06:17.200 --> 06:18.743
Let's just verify.

06:19.673 --> 06:21.543
There is nothing called /eat here,

06:21.623 --> 06:24.523
but we don't know
if it's there in another space.

06:25.703 --> 06:28.553
Let's try that out.

06:28.793 --> 06:30.473
Eat, it doesn't--

06:30.653 --> 06:32.778
There's nothing, it's a 404 error.

06:32.867 --> 06:34.367
There's a 404 error.

06:37.463 --> 06:38.703
Now, due to increased demand,

06:38.783 --> 06:41.613
your business decides
to take on a new venture.

06:41.693 --> 06:43.683
You acquired a food delivery company.

06:43.763 --> 06:46.623
Their applications
have been migrated over to your cluster.

06:46.703 --> 06:49.413
Inspect the new deployments
in the app-space namespace.

06:49.493 --> 06:51.793
Okay, let's check out

06:52.833 --> 06:57.923
deploy in the app-space namespace,

06:58.313 --> 06:59.643
and we see that we have the default backend,

06:59.723 --> 07:02.963
we have food along with
the video and wear application.

07:03.053 --> 07:04.803
This is the new application.

07:06.473 --> 07:09.603
Now, you're requested to add
a new path to your ingress to make

07:09.683 --> 07:12.363
the food delivery application
available to your customers,

07:12.443 --> 07:14.523
so make the new application
available at /eat.

07:14.603 --> 07:15.963
We want to make it available at /eat.

07:16.043 --> 07:20.543
We know that we need to find out
the service that this is exposed on.

07:20.783 --> 07:22.463
Let's try and find that.

07:22.883 --> 07:26.903
Instead of deployment, let's look
at services in the same namespace.

07:26.993 --> 07:28.773
Now, we see that we have the food-service,

07:28.853 --> 07:32.603
and let's also verify and make
sure that the Port is 8080.

07:33.383 --> 07:35.543
It's food-service at Port 8080.

07:36.143 --> 07:39.233
I'm going to copy that,
and let's go and edit

07:41.363 --> 07:43.023
the Ingress Resource again.

07:43.103 --> 07:46.463
We have a command for that already,
kubectl edit ingress,

07:46.613 --> 07:49.553
the name of the Ingress
Resource in the app-space.

07:50.993 --> 07:53.933
What we need to do is add
an additional path here.

07:54.323 --> 07:58.373
We're going to copy this,

08:00.443 --> 08:01.443
paste that.

08:02.303 --> 08:04.383
What we'll do is you know

08:04.463 --> 08:10.673
that it's food service, so food-service, and

08:12.923 --> 08:18.633
the port number is 8080,
that's fine, and the path is /eat.

08:19.367 --> 08:20.567
Let's save that.

08:21.367 --> 08:23.720
Let's wait for it to finish.

08:23.800 --> 08:25.173
Okay, and let's try to refresh,

08:25.253 --> 08:28.343
and we see the food-service application.

08:29.243 --> 08:31.223
Okay, let's check the work.

08:33.863 --> 08:35.223
Now, view the food delivery application

08:35.303 --> 08:37.366
using /eat, which we already did.

08:38.543 --> 08:40.713
Now, a new payment
service has been introduced.

08:40.793 --> 08:41.823
Since it is critical,

08:41.903 --> 08:44.463
the new application is deployed
in its own namespace.

08:44.543 --> 08:46.143
Identify the namespace.

08:46.223 --> 08:51.573
Let's do a get pods -A,
and see what the new namespace is.

08:51.653 --> 08:54.593
We have a new namespace
called critical space.

08:55.133 --> 08:58.433
Let's do a get deploy in the critical space,

08:59.093 --> 09:01.473
and we see that we have our webapp-pay.

09:01.553 --> 09:03.241
This is the new deployment.

09:04.533 --> 09:06.093
Identify the namespace.

09:06.173 --> 09:07.823
That's critical space.

09:10.223 --> 09:12.483
What is the name of the deployment
of the new applications?

09:12.563 --> 09:15.533
We just found that out,
it's called webapp-pay.

09:18.983 --> 09:19.863
You are requested to make

09:19.943 --> 09:22.293
the new application available at /pay.

09:22.373 --> 09:24.153
Identify and implement
the best approach to making

09:24.233 --> 09:26.163
this application available
on the Ingress Controller

09:26.243 --> 09:28.083
and test to make sure it's working.

09:28.163 --> 09:30.083
Look into annotations as well.

09:30.383 --> 09:34.653
Okay, we know
that for the app-space applications,

09:34.733 --> 09:37.546
we have the Ingress
Resource in the app-space.

09:37.853 --> 09:41.133
Now, we cannot use that resource
to add something in another space.

09:41.213 --> 09:42.620
What we're going to do
is we're going to create

09:42.700 --> 09:46.973
an Ingress Resource
for this critical space itself.

09:48.053 --> 09:50.616
Well, at least, that's the best practice.

09:50.783 --> 09:52.353
The best practice is to create--

09:52.433 --> 09:55.323
For different teams who maybe are having

09:55.403 --> 09:56.853
access to different namespaces

09:56.933 --> 09:59.333
to create their own Ingress Resource.

10:00.323 --> 10:03.063
That's should be the approach
that we should be using.

10:03.143 --> 10:05.053
You can assume that maybe
those who are working

10:05.133 --> 10:07.353
on this application only
has access to this namespace,

10:07.433 --> 10:09.753
but those who are working
on the web-pay application

10:09.833 --> 10:11.958
only has access to this namespace.

10:12.713 --> 10:15.803
Any ingress-related
resources that are created

10:16.163 --> 10:18.851
would have to be created in this namespace.

10:19.643 --> 10:21.331
We'll create a new ingress,

10:21.593 --> 10:24.243
and then we'll set
the path as we did before.

10:24.323 --> 10:26.198
We'll set the backend service.

10:26.393 --> 10:30.487
Let's first find out
what the backend service is

10:30.567 --> 10:36.563
to this web-pay, it's called pay-service,

10:36.743 --> 10:40.343
just like food service [?]
this one's called pay-service,

10:40.673 --> 10:42.720
and the deployment is webapp-pay.

10:42.800 --> 10:48.623
We want to direct traffic that goes
to the path /pay, which as of now,

10:49.643 --> 10:51.323
there won't be anything.

10:52.913 --> 10:56.853
We want to direct
that to this pay service on port.

10:56.933 --> 10:59.753
Remember that the port now is 8282.

11:01.133 --> 11:02.813
That should be the port.

11:03.293 --> 11:06.203
Let's do a kubectl create ingress.

11:11.453 --> 11:14.078
We do have an imperative command for that.

11:14.603 --> 11:17.333
Let's do a -h to see the format.

11:17.933 --> 11:21.623
We're going to other multiple examples.

11:22.313 --> 11:25.853
Let's just pick the simplest one,
so kubectl create ingress,

11:25.933 --> 11:27.683
the name, and then the role.

11:27.833 --> 11:30.133
That's basically it.

11:31.500 --> 11:32.833
Let's do that.

11:34.733 --> 11:37.023
The name, let's see if there's a name given.

11:37.103 --> 11:41.603
There's no name given here,
so we could give it any name.

11:41.993 --> 11:46.787
This is going to be ingress-pay maybe,

11:46.867 --> 11:48.663
and then it's in the namespace.

11:48.743 --> 11:53.423
Remember
that this has to be in the critical space.

11:54.113 --> 11:57.593
Then,
the rule is that anything that goes to--

11:57.743 --> 12:02.093
Sorry, /pay, the path /pay,
so that's /pay here,

12:03.263 --> 12:07.973
would go to the pay-service,
that's what we just saw,

12:08.933 --> 12:11.183
and the port is 8282.

12:11.783 --> 12:16.943
We don't have any certs for now,
so let's just get rid of this.

12:19.133 --> 12:22.223
That's the ingress-pay.

12:23.767 --> 12:25.387
Let's check it out

12:25.467 --> 12:32.063
what ingress in the critical space.

12:32.633 --> 12:34.758
Obviously, that is indeed created.

12:35.573 --> 12:41.543
Let's take a look at it,
ingress in critical space.

12:41.903 --> 12:44.091
We see that we have the ingress-pay

12:44.543 --> 12:46.383
is going to catch
everything that goes to pay

12:46.463 --> 12:48.838
and then redirect that to pay service.

12:49.853 --> 12:51.666
Let's go and try it out here.

12:54.173 --> 12:57.203
You see that it's still not working
as expected.

12:57.863 --> 12:59.551
It still gives a 404 error.

12:59.753 --> 13:02.613
Let's take a look
at the logs and find out why.

13:02.693 --> 13:04.803
If you look at the logs

13:04.883 --> 13:08.573
of this application in the critical space,

13:11.063 --> 13:14.513
we have the webapp-pay service,
the webapp-pay pod.

13:15.083 --> 13:18.383
Then,
what we're going to do is we're going to do a logs

13:18.767 --> 13:23.963
for that pod in the critical space.

13:26.063 --> 13:29.243
We see that these are the requests
that are coming in.

13:29.633 --> 13:31.463
It's coming in as pay.

13:34.073 --> 13:40.943
The thing is, these applications
may not have a /pay at the end.

13:43.373 --> 13:45.213
It should be without this pay.

13:45.293 --> 13:48.593
What's happening is,
when you're calling /pay,

13:50.843 --> 13:54.863
the Ingress Resource
is just forwarding as is,

13:55.013 --> 13:57.303
the URL as is to this application,

13:57.383 --> 14:00.563
and this application does
not really have a /pay path.

14:02.243 --> 14:05.183
It should just be just /.

14:06.700 --> 14:08.123
Let's do that.

14:10.403 --> 14:15.143
For that, we have to put in the ingress,
the annotations, and the rewrite rules.

14:15.773 --> 14:20.453
If you look at this, the watch,
wear, or even the pay service,

14:20.723 --> 14:21.963
they're just available at this.

14:22.043 --> 14:24.793
They don't have a /watch
or /wear at the end,

14:24.953 --> 14:29.903
but with the default rule
that the Ingress Controller creates,

14:30.173 --> 14:33.723
anything that goes to watch
is going to have watch at the end.

14:33.803 --> 14:35.883
Anything that goes to wear
is going to have wear at the end,

14:35.963 --> 14:37.293
so that's why the error.

14:37.373 --> 14:44.243
We want to put in this rewrite
annotation to get that removed.

14:44.467 --> 14:45.667
Let's copy that.

14:50.513 --> 14:57.020
Let's edit the ingress-pay

14:57.100 --> 15:00.033
in the critical space.

15:03.767 --> 15:07.103
We should have ingress and then

15:09.400 --> 15:11.403
we've got to add an annotation here.

15:11.483 --> 15:16.133
Annotations go in metadata section here.

15:17.243 --> 15:19.681
We're going to save the rewrite target.

15:20.349 --> 15:22.587
This is basically going to take that out

15:22.667 --> 15:26.823
and take out the pay
at the end and just put / there.

15:28.223 --> 15:29.798
That seems to be set.

15:31.733 --> 15:32.883
When you refresh it,

15:32.963 --> 15:36.143
you can actually see
that this is working as expected.

15:36.413 --> 15:40.193
Let's check our work, looks good.

15:41.183 --> 15:43.983
Yes, we've already gone here
and verified that it's working.

15:44.063 --> 15:46.126
Okay, that's the end of this lab.

