WEBVTT

00:00.020 --> 00:05.690
We also need to specify a route that will serve as a health check endpoint for this ingress.

00:05.720 --> 00:13.190
By default, Kubernetes engine will launch health check endpoints at the root path of each ingress resource

00:13.190 --> 00:16.190
here to make sure that the load balancer is healthy.

00:16.220 --> 00:21.740
So in order to make sure that it's reported as healthy and our application is actually routed to, we're

00:21.740 --> 00:27.950
going to go ahead and create a new route in both the reservations and auth services to respond to this

00:27.950 --> 00:28.640
health check.

00:28.640 --> 00:31.820
Since we want this to be common to both of the services.

00:31.850 --> 00:35.810
We'll go ahead and create it in our Libs common folder.

00:36.110 --> 00:39.470
So go ahead and create a new directory called Health.

00:39.470 --> 00:48.110
And inside of here we'll create a health dot controller and this will be a nestjs controller called

00:48.110 --> 00:49.760
Health Controller.

00:49.790 --> 00:54.500
We'll go ahead and specify the path for this controller to be at the root of the service, and then

00:54.500 --> 01:01.050
we'll specify a single get route here called health that will simply return True to indicate that the

01:01.050 --> 01:04.140
application can respond to Http traffic.

01:04.170 --> 01:11.670
We'll go ahead and create a new health appmodule That will be a new Add module from Nestjs common called

01:11.670 --> 01:19.680
Health Module, and we'll specify our controller that we set up in the controllers array.

01:20.190 --> 01:28.920
Now we'll go ahead and specify an index.ts where we go ahead and export everything from the health dot

01:28.950 --> 01:36.900
module and then at the root Index.ts we'll export everything from the health folder.

01:36.900 --> 01:43.620
So now we can come in at the reservation service in the reservations module and all we have to do is

01:43.620 --> 01:50.550
import the health module directly from app slash common and we get the health controller out of the

01:50.550 --> 01:51.260
box.

01:51.270 --> 01:58.710
So we'll go ahead and do the same thing in the auth module by importing the health module here from

01:58.710 --> 01:59.940
app slash common.

02:00.150 --> 02:08.700
So if our containers are running, we can then launch a request at localhost 3000 a get request to hit

02:08.700 --> 02:12.160
that health controller and get a 200 response back.

02:12.180 --> 02:18.660
Go ahead and commit these changes so that codebuild will rebuild our images and we have this change

02:18.660 --> 02:23.550
available to take advantage of the health controller when we deploy the ingress.

02:35.590 --> 02:38.590
So go ahead and wait until the latest build completes.

02:38.590 --> 02:41.710
And our latest images have been pushed up from code build.
