WEBVTT

00:00.253 --> 00:06.402
In this video, we're going to look at 
Ingress networking in a bit more detail.

00:06.537 --> 00:09.105
We'll try and deploy
an Ingress Controller.

00:10.455 --> 00:13.327
We've deployed two applications.
Explore the setup.

00:14.184 --> 00:15.864
Let's check that out.

00:16.783 --> 00:20.959
Set alias first.

00:21.616 --> 00:25.501
Let's do a pod -A.

00:27.984 --> 00:32.040
In the app-space, we have the video
and wear applications.

00:33.889 --> 00:36.833
Let us now deploy 
an Ingress Controller first.

00:37.088 --> 00:40.858
Create a namespace 
called ingress-space.

00:44.668 --> 00:46.370
This is what we are going to do.

00:46.553 --> 00:49.502
The first step is to create this 
namespace called ingress-space.

00:49.583 --> 00:52.252
We'll do this one step at a time.

00:53.674 --> 00:54.931
Let's do that first.

00:55.012 --> 00:58.835
I'm going to create namespace
ingress-space.

01:00.248 --> 01:01.748
Okay.
That's successful.

01:01.930 --> 01:05.478
Now, the NGINX Ingress Controller 
requires a ConfigMap object.

01:05.559 --> 01:08.418
Create a ConfigMap object
in the ingress-space.

01:11.751 --> 01:14.252
We're just going to create
a ConfigMap object.

01:14.333 --> 01:18.593
We'll do a kubectl create configmap.

01:21.173 --> 01:25.926
The name should be,
it's given here, nginx-configuration,

01:26.561 --> 01:31.481
and the namespace is ingress-space.

01:32.655 --> 01:33.655
Okay.

01:35.077 --> 01:36.219
That's done.

01:36.688 --> 01:38.605
If you can see here.

01:39.438 --> 01:41.475
We've just created these two.

01:42.827 --> 01:46.335
Now, the NGINX Ingress Controller 
requires a ServiceAccount.

01:46.416 --> 01:48.684
Create a ServiceAccount
in the ingress-space name.

01:48.890 --> 01:52.538
The name of the ServiceAccount
is ingress-serviceaccount.

01:57.075 --> 02:01.085
Create serviceaccount

02:04.402 --> 02:06.917
in the ingress-space.

02:19.241 --> 02:21.990
We have created the Roles and RoleBindings
for the ServiceAccount.

02:22.071 --> 02:23.286
Let's check that out.

02:24.803 --> 02:26.129
Get roles.

02:31.438 --> 02:36.605
We have the ingress-role 
and rolebindings.

02:37.509 --> 02:41.440
We have ingress rolebinding.
Let's check out

02:45.447 --> 02:51.528
ingress-role in the ingress-space.

02:52.767 --> 02:58.743
We see that there are a number 
of resources that are given access to

02:58.862 --> 03:01.262
like the pods, secrets, namespaces.

03:01.433 --> 03:04.966
These are the verbs,
the actions that it can perform.

03:06.054 --> 03:07.585
Let's keep going.

03:09.387 --> 03:13.046
Let us now deploy the Ingress Controller.
Create a deployment using the file given.

03:13.127 --> 03:16.834
There's already a file given
called ingress-controller.

03:19.842 --> 03:21.905
The hard stuff is already in there.

03:22.850 --> 03:25.194
It's going to be called 
ingress-controller.

03:25.645 --> 03:28.035
The ServiceAccount name
that we created is here.

03:28.226 --> 03:30.559
The container that it uses is here.

03:30.682 --> 03:33.238
The arguments that are passed to it
is configured,

03:33.319 --> 03:35.357
and there are some 
environment variables as well,

03:35.438 --> 03:38.504
and the ports that it exposes.
These are all done.

03:38.647 --> 03:43.583
There are some issues, 
so let's try and create a file

03:44.186 --> 03:47.187
from this first-- 
Create a deployment from this file first.

03:47.520 --> 03:52.384
It looks like there are some issues.
There's an issue on line 36.

03:53.162 --> 03:54.991
Looks like a YAML issue,

03:56.073 --> 03:58.973
let's edit the file 
and try and fix those.

04:00.552 --> 04:04.301
Let's go to line 36.
Right here.

04:04.539 --> 04:08.802
We see that, yes, indeed
there's an issue with spacing.

04:08.883 --> 04:10.083
We'll fix that.

04:11.893 --> 04:13.357
Let's try to create it again.

04:13.959 --> 04:19.260
We see that 
namespace "ingress-" not found.

04:19.341 --> 04:21.261
If you look here,

04:22.426 --> 04:26.492
the namespace is not properly specified,
so let's try and edit that.

04:32.429 --> 04:35.635
And space.

04:39.673 --> 04:42.658
Let's try and create
ingress-controller now.

04:43.516 --> 04:45.543
Let's check out the status

04:49.440 --> 04:52.302
in the ingress-space.

04:53.334 --> 04:55.433
It's in a continuing creating state.

04:57.814 --> 05:00.785
Let's give it sometime.

05:01.332 --> 05:03.891
Meanwhile, we can check
the status of our work.

05:03.972 --> 05:06.524
Yes, it's completed successfully.

05:06.689 --> 05:09.353
We have now deployed 
the ingress-controller.

05:09.496 --> 05:12.718
Now, the next step
is to create a service to

05:13.289 --> 05:15.511
make ingress 
available to external users.

05:16.010 --> 05:18.144
The ingress-controller is ready.

05:18.225 --> 05:22.052
The next step
is to create a service called ingress.

05:22.133 --> 05:27.301
What we're going to do is
our goal is to expose ingress-controller.

05:27.382 --> 05:34.135
The easiest way to do that 
is get deploy -n ingress-space.

05:34.810 --> 05:37.217
It's called ingress-controller,
so we're going to create a service

05:37.298 --> 05:40.552
using the expose command.
We're going to do expose.

05:44.221 --> 05:46.238
What do we want to expose?
We want to expose

05:46.319 --> 05:49.830
the ingress-controller deployment.

05:50.338 --> 05:55.885
We'll say deploy an ingress-controller
in the ingress-space.

06:03.658 --> 06:06.666
Also, there are some specifications
given here.

06:06.747 --> 06:11.381
The name has to be ingress.
Let's pass in a name called ingress.

06:12.016 --> 06:16.134
Let's check out the help
just to get a bit more idea.

06:16.809 --> 06:21.993
We have the expose command, 
and then we have the deployment,

06:22.074 --> 06:23.218
the deployment name.

06:23.551 --> 06:26.722
If you want a name for the service, 
you can use --name.

06:26.803 --> 06:27.920
That's what we just did.

06:28.055 --> 06:32.302
You can also specify the port,
so the port and the target port.

06:33.469 --> 06:37.489
We want to use 80
and the target port is also 80,

06:37.917 --> 06:42.032
but the expose command does not 
allow us to use the node port option.

06:42.113 --> 06:43.885
What we're going to do is 
we're going to create the service first,

06:43.966 --> 06:45.983
and then we're just going to go in
and edit the node port.

06:46.064 --> 06:48.459
That's the easiest way to do that.

06:48.540 --> 06:51.967
We'll just take these 
because that's what we are left with.

06:53.641 --> 06:54.921
Clear my screen.

06:57.888 --> 07:02.530
We're going to specify the port.
The port and the target port are both 80.

07:06.292 --> 07:11.768
We're going to do an export deploy 
ingress-controller in the ingress-space.

07:11.849 --> 07:14.879
We'll name it ingress,
and then we'll specify these.

07:14.960 --> 07:16.740
We can also specify the type.

07:17.153 --> 07:22.019
We'll say --type 
going to be node port.

07:22.224 --> 07:23.408
That's what's given here.

07:23.489 --> 07:25.745
Then we specify the port
and the target port.

07:25.826 --> 07:29.014
The node port cannot be specified,
but we specify this.

07:29.221 --> 07:30.708
The right selector,

07:30.797 --> 07:33.564
expose should take care
of using the right selector for this,

07:33.645 --> 07:34.772
for the deployment.

07:35.097 --> 07:36.537
Let's create that.

07:37.290 --> 07:38.330
It's created.

07:40.338 --> 07:44.966
Get svc in the ingress-space.

07:46.244 --> 07:48.244
It's created.
It's a node port.

07:49.900 --> 07:54.571
If you look here, the node port 
that is used is 32741.

07:54.652 --> 07:56.385
That's not what we wanted.

07:56.613 --> 08:02.375
We'll go and edit the service
in the ingress-space.

08:03.851 --> 08:06.232
Edit service called ingress.

08:08.566 --> 08:10.208
Here we can see the details.

08:10.289 --> 08:14.851
The only thing we need to do 
is change this to 30080.

08:15.319 --> 08:18.343
This is actually a simpler way
to create a service

08:18.424 --> 08:21.435
without having to work 
with the YAML files at all.

08:21.927 --> 08:24.054
That's going to be useful
in the exam.

08:24.713 --> 08:25.855
Let's check.

08:26.696 --> 08:28.224
That's successful.

08:28.867 --> 08:30.756
Now, the next step 
is to create the ingress resource

08:30.837 --> 08:35.582
to make the applications available at wear
and watch on the ingress service.

08:35.796 --> 08:37.828
We're going to create 
an ingress service.

08:37.909 --> 08:42.498
We'll do a kubectl create ingress

08:42.753 --> 08:45.684
in the app-space.

08:47.120 --> 08:48.685
That's where the applications are.

08:51.272 --> 08:53.018
Let's quickly check help.

08:53.950 --> 08:56.047
This is what we used earlier.

08:56.128 --> 09:00.192
We're going to do a create 
then give the name of the ingress rule,

09:00.398 --> 09:04.585
and then we'll just use this rule
to specify the roles.

09:09.782 --> 09:16.215
The name of the ingress resource 
could just be ingress and wear and watch.

09:17.159 --> 09:19.310
Then we'll specify the rules.

09:19.928 --> 09:24.037
We don't need the certificate stuff,
so we'll remove that.

09:26.124 --> 09:29.926
The rules says wear

09:31.188 --> 09:35.521
needs to go to the wear-service.

09:37.830 --> 09:40.203
Then we have another rule.

09:42.124 --> 09:46.835
Again, we're going to remove this,
and this is for the second one.

09:46.916 --> 09:49.335
We can have multiple rules like this,

09:50.152 --> 09:56.585
watch, and that's going to go 
to the watch-service.

09:57.029 --> 09:59.450
I'm not sure if it's called
the wear and watch service.

09:59.531 --> 10:02.002
I'm just to part this for now.

10:02.112 --> 10:07.419
Let's check the service names
in app-space.

10:08.800 --> 10:09.827
We see that--

10:09.908 --> 10:11.981
Okay, it's the wear-service 
and it's the video-service, n

10:12.062 --> 10:14.962
ot the watch-service,
and the ports are 8080.

10:15.810 --> 10:17.327
Let's edit that.

10:18.954 --> 10:23.418
The watch is called the video-service
in port 8080,

10:23.499 --> 10:28.148
and the wear is called
the wear-service.

10:29.188 --> 10:31.252
Let's get rid of this one.

10:31.545 --> 10:38.502
Okay, so that's created,
ingress in app-space.

10:39.938 --> 10:41.283
We see that is created.

10:41.680 --> 10:44.505
Let's do a describe ingress--

10:49.053 --> 10:50.752
Let's do app-space.

10:53.466 --> 10:57.502
We see that the wear goes 
to the wear-service,

10:57.583 --> 10:59.835
and it's identified
the endpoint for that.

10:59.916 --> 11:03.807
Watch is to the video-service 
and it's identified the endpoints to that.

11:04.822 --> 11:07.756
Let's test it out 
and see if it's working.

11:10.240 --> 11:11.702
Let's do a wear.

11:14.107 --> 11:15.972
Okay, so it isn't working.

11:17.805 --> 11:19.165
Let's do a watch.

11:23.789 --> 11:28.764
Let's go and check out the logs 
on these applications.

11:33.392 --> 11:37.948
Let's do a logs.
Take this out.

11:42.574 --> 11:45.368
As you can see, 
the requests aren't even reaching here.

11:46.749 --> 11:48.749
Let's check the other service.

11:58.440 --> 12:00.995
If the requests were coming in, 
you'd actually see the requests coming in.

12:01.076 --> 12:04.885
The requests aren't hitting this.

12:04.966 --> 12:06.876
That's one thing.

12:08.090 --> 12:09.876
Let's try and figure out why.

12:14.947 --> 12:18.793
Let's look at the logs 
of the ingress controller itself.

12:19.356 --> 12:22.983
The ingress controller, 
as we know, is in the ingress-space.

12:23.404 --> 12:27.119
Let's do a logs 
of this ingress controller.

12:31.833 --> 12:35.539
If you look here, 
there seems to be a lot of logs.

12:36.134 --> 12:37.748
App-space.

12:39.788 --> 12:42.868
it's definitely hitting
the ingress controller,

12:44.415 --> 12:47.874
but then you see 
there are three node-eights.

12:47.955 --> 12:51.612
The three node-eights 
indicate a redirect.

12:52.484 --> 12:55.524
What's happening is, 
every time we're going here,

12:55.605 --> 12:58.468
as you can see, the browser here
it just keeps redirecting.

12:58.549 --> 13:01.075
It looks like it's going into a--

13:01.567 --> 13:05.718
You can see the errors here,
so it's going into too many redirects.

13:07.400 --> 13:13.448
That is mainly because it's just trying
to do a redirect on the SSL.

13:13.529 --> 13:17.980
For HTTPS, 
it's trying to do a redirect on HTTPS.

13:18.061 --> 13:22.457
What we need to do is 
we need to edit the ingress service.

13:28.155 --> 13:30.917
Here's the ingress service.
We need to edit it

13:36.901 --> 13:39.635
in the app-space

13:44.460 --> 13:46.321
to provide ingress.

13:47.543 --> 13:50.817
Then you need add the annotations.

13:52.095 --> 13:58.227
The annotations
for the ReadWrite target,

13:58.308 --> 13:59.514
because as we discussed earlier,

13:59.595 --> 14:02.135
we don't want it to go
to a wear and watch URL.

14:02.658 --> 14:09.479
To prevent the SSL redirect, 
we have to add the SSL redirect to false.

14:10.287 --> 14:11.567
Let's edit that.

14:12.768 --> 14:14.448
Let's try this again.

14:17.467 --> 14:19.267
That seems to do the trick.

14:19.852 --> 14:21.684
It's actually working now.

14:24.382 --> 14:26.062
Let's check our work.

14:28.276 --> 14:30.206
We already accessed the application.

14:30.889 --> 14:33.190
That's the end of this lab.

