We also need to specify a route that will serve as a health check endpoint for this ingress.
By default, Kubernetes engine will launch health check endpoints at the root path of each ingress resource
here to make sure that the load balancer is healthy.
So in order to make sure that it's reported as healthy and our application is actually routed to, we're
going to go ahead and create a new route in both the reservations and auth services to respond to this
health check.
Since we want this to be common to both of the services.
We'll go ahead and create it in our Libs common folder.
So go ahead and create a new directory called Health.
And inside of here we'll create a health dot controller and this will be a nestjs controller called
Health Controller.
We'll go ahead and specify the path for this controller to be at the root of the service, and then
we'll specify a single get route here called health that will simply return True to indicate that the
application can respond to Http traffic.
We'll go ahead and create a new health appmodule That will be a new Add module from Nestjs common called
Health Module, and we'll specify our controller that we set up in the controllers array.
Now we'll go ahead and specify an index.ts where we go ahead and export everything from the health dot
module and then at the root Index.ts we'll export everything from the health folder.
So now we can come in at the reservation service in the reservations module and all we have to do is
import the health module directly from app slash common and we get the health controller out of the
box.
So we'll go ahead and do the same thing in the auth module by importing the health module here from
app slash common.
So if our containers are running, we can then launch a request at localhost 3000 a get request to hit
that health controller and get a 200 response back.
Go ahead and commit these changes so that codebuild will rebuild our images and we have this change
available to take advantage of the health controller when we deploy the ingress.
So go ahead and wait until the latest build completes.
And our latest images have been pushed up from code build.