WEBVTT

00:00.620 --> 00:06.740
Okay, let's go ahead and head back to the Deployment.yaml for the notification service, where we're

00:06.740 --> 00:11.390
going to go ahead and add some environment variables for this deployment.

00:11.390 --> 00:18.170
And let's go ahead and define a new field here called ports and define a container port.

00:18.170 --> 00:23.720
So this is going to be the port that we're going to allow connections on inside of this pod.

00:23.810 --> 00:26.390
In this case, we will use Port 3000.

00:26.390 --> 00:32.240
So now we've told Kubernetes which port we're connecting on, we need to tell the actual pod itself

00:32.240 --> 00:33.890
through the environment variable.

00:33.890 --> 00:39.470
Let's go ahead and do this with the environment variable section and we'll go ahead and define a new

00:39.470 --> 00:44.960
environment variable named port, and we'll provide the value at Port 3000.

00:44.990 --> 00:49.040
Next, we need to provide our Google OAuth environment variables.

00:49.040 --> 00:56.000
So let's go ahead and provide the ones that don't need to be secret First, we'll start off with the

00:56.030 --> 01:06.000
Google OAuth client ID and set the value equal to the dot env from our notifications dot env file.

01:06.000 --> 01:12.090
We can copy this value over and paste it in as plain text.

01:13.820 --> 01:18.620
We can do the same thing for the Smtp user.

01:19.550 --> 01:28.010
We'll go ahead and set the value from our M file as the sleeper Nest app at gmail.com.

01:28.850 --> 01:36.080
Now we need to create two secrets for our client secret as well as the refresh token as these are sensitive

01:36.080 --> 01:37.090
values.

01:37.130 --> 01:41.570
So we'll create these secrets the same way we have before by running kubectl.

01:41.570 --> 01:44.930
Create secret and I'll call this Google.

01:45.080 --> 01:56.540
Then we're going to specify from literal and set equals client secret and set that equal to the client

01:56.540 --> 01:57.350
secret.

01:58.410 --> 02:02.430
From our dot env file and we'll simply paste this in.

02:02.760 --> 02:11.010
Then we'll go ahead and add another from literal flag where we'll set the refresh token key equal to

02:11.010 --> 02:13.200
our refresh token.

02:13.200 --> 02:16.050
So we'll go ahead and copy this value as well.

02:17.250 --> 02:19.050
And paste that in.

02:19.470 --> 02:23.610
Additionally, don't forget we need to add the generic keyword.

02:23.610 --> 02:31.820
So after kubectl create secret, we will add generic to make this secret a generic type.

02:31.830 --> 02:35.730
And then we'll go ahead and enter this to create this secret.

02:35.760 --> 02:39.450
Now that we've created the secret, we need to reference it securely.

02:39.450 --> 02:47.040
So we'll go ahead and do this by firstly providing the name Google OAuth client secret.

02:47.190 --> 02:53.460
This will be set to value from secret key Ref.

02:53.760 --> 02:56.970
And we give this the name of our secret, which is Google.

02:56.970 --> 03:01.620
And then the key we specified this under which was client secret.

03:01.860 --> 03:09.510
We'll go ahead and copy this because it's going to be the same process to specify the Google OAuth refresh

03:09.510 --> 03:10.140
token.

03:10.140 --> 03:18.010
We just need to change out the client secret for the refresh token and also make sure we change the

03:18.010 --> 03:19.390
secret key ref.

03:19.390 --> 03:25.180
We keep the existing name of it, but then the key has to change to refresh token.

03:25.570 --> 03:31.680
Now we can go back and run helm Upgrade Sleeper to go ahead and upgrade our deployment.

03:31.690 --> 03:39.070
If we go ahead and run Kubectl get Pods, we should see the notification pods start up and if we run

03:39.070 --> 03:42.610
logs on it, we can see it has successfully started up.

03:42.610 --> 03:49.570
So next we want to create a service for our notifications deployment so that our other pods can easily

03:49.570 --> 03:53.470
talk to it in our Kubernetes cluster in a reliable way.

03:53.500 --> 03:58.600
So let's go ahead and CD into our templates folder and then CD into notifications.

03:58.600 --> 04:07.540
So let's go ahead and run Kubectl, create service cluster IP, and we'll call this notifications and

04:07.540 --> 04:15.040
we'll go ahead and specify the TCP argument here and we're going to set the port to 3000.

04:15.070 --> 04:21.880
We will set dry run equal to client so we don't actually create this and we'll set the output to Yaml

04:21.880 --> 04:24.430
and pipe this to a service dot yaml file.

04:24.430 --> 04:29.740
Now if we go ahead and look at the newly created file here in notifications, we can see we have everything

04:29.740 --> 04:32.680
we need to create a new cluster IP service.

04:32.680 --> 04:37.180
So I'll go ahead and remove the status section here as well as the creation timestamp.

04:37.180 --> 04:44.440
You can see here we have a port on TCP protocol at Port 3000 that's going to target port 3000 on the

04:44.440 --> 04:46.720
pod, which is exactly what we want.

04:46.720 --> 04:53.410
So now if we go back up to the root helm and run helm upgrade Sleeper again, we should be able to then

04:53.410 --> 04:58.870
run Kubectl, get service and see our new notification service.

04:58.900 --> 05:01.630
Okay, so let's move on to the payment service.

05:01.630 --> 05:04.840
Next, you can see the environment variables we need to supply.

05:04.840 --> 05:06.820
So let's go ahead and get started.

05:06.820 --> 05:14.320
We will go into the payments deployment and let's go ahead and firstly start off by adding the container

05:14.320 --> 05:16.120
port as we've done before.

05:16.330 --> 05:23.860
I'll go ahead and add a new section called Ports and add a container port, and we'll specify this at

05:23.860 --> 05:25.480
Port 3001.

05:26.200 --> 05:31.510
Next, let's go ahead and specify our environment variable block.

05:31.510 --> 05:37.870
We'll go ahead and specify our first environment variable and we will specify the port and give it a

05:37.870 --> 05:40.150
value of 3001.

05:40.510 --> 05:46.810
Next, you can see we need to tell it where the notifications host and port is and we know exactly where

05:46.810 --> 05:49.360
that is because of the service we just created.

05:49.360 --> 05:53.260
So let's go ahead and specify the notifications.

05:53.260 --> 06:01.660
Host This value is going to be just notifications because that's the name of the service we created

06:01.660 --> 06:04.390
and that's how Kubernetes services talk to each other.

06:04.390 --> 06:06.670
This will be the host name here.

06:06.670 --> 06:10.600
And of course we know the port is 3000 as we just defined.

06:10.600 --> 06:19.090
So we can go ahead and specify the notifications port now and give this a value of 3000.

06:19.090 --> 06:22.060
Finally, we need to specify the stripe secret key.

06:22.060 --> 06:27.010
And again, we of course don't want to commit any values that contain this.

06:27.040 --> 06:30.760
We would never be committing these dot m files to a repository.

06:30.760 --> 06:33.670
I have done this merely to make it easier for you.

06:33.700 --> 06:37.210
However, in reality we wouldn't be committing these files.

06:37.210 --> 06:41.890
And so we need a way to secretly hide these in our Kubernetes cluster.

06:41.890 --> 06:43.300
And that's what we'll go ahead and do.

06:43.300 --> 06:44.710
As we did with the MongoDB.

06:45.010 --> 06:47.980
We'll create a new secret here for the Stripe key.

06:48.010 --> 06:55.360
So go ahead and copy your existing stripe secret key and then we can go ahead and run kubectl, create

06:55.390 --> 07:01.810
secret generic again, we'll call it Stripe and it will be from literal.

07:01.810 --> 07:07.960
Again, we can specify an API key here and paste in our API key.

07:08.080 --> 07:14.110
We can go ahead and copy our existing code to extract the MongoDB secret.

07:14.110 --> 07:16.690
And let's go ahead and paste that in.

07:16.690 --> 07:18.490
To our existing EMF block.

07:18.490 --> 07:22.450
We simply need to change the secret key name to Stripe.

07:22.480 --> 07:25.690
And then we'll change the key to API key.

07:25.720 --> 07:30.880
Finally, we need to change the environment variable to stripe secret key.

07:30.910 --> 07:37.690
Let's go ahead and redeploy our deployments now by running Helm Upgrade Sleeper again.

07:37.990 --> 07:42.730
Now if we run Kubectl get pods, we can see the payments.

07:42.730 --> 07:46.780
Pod is now up and running and it is no longer crashing.

07:46.780 --> 07:51.040
If we look at the logs, we can see it has also started up successfully.

07:51.070 --> 07:53.470
Okay, so now we're on to the auth service.

07:53.500 --> 07:55.780
We've already defined the MongoDB Uri.

07:56.080 --> 08:02.050
Let's go ahead and firstly take care of the JWT secret that we need to define here.

08:02.200 --> 08:04.840
Again, just like the stripe secret key.

08:04.840 --> 08:06.910
I'll take this from our existing env.

08:06.940 --> 08:13.150
We'll go ahead and copy this existing secret, then we'll go ahead and run kubectl, create secret generic

08:13.150 --> 08:15.370
and I'll call this JWT.

08:15.730 --> 08:17.560
We'll pass from literal.

08:17.590 --> 08:22.690
I'll set it equal to JWT secret and paste in our JWT secret.

08:22.720 --> 08:25.060
Now let's go back in our folder.

08:25.060 --> 08:31.390
Under the auth deployment, we can go ahead and copy this existing block for the MongoDB Uri as we've

08:31.390 --> 08:32.320
done before.

08:32.350 --> 08:36.730
Paste that in and we'll go ahead and swap this out for the JWT secret value.

08:36.760 --> 08:41.340
Change the name here to JWT and the key to JWT secret.

08:41.350 --> 08:44.800
So now we're defining the JWT secret from our new secret.

08:44.830 --> 08:48.620
Next, we'll define a JWT expiration.

08:48.640 --> 08:50.620
So this will not be a secret.

08:50.650 --> 08:58.390
We can just go ahead and define this directly, and I will use the same value as before as 3600 seconds.

08:58.420 --> 09:03.550
Next, we need to define both of our Http port and TCP port.

09:03.560 --> 09:09.590
So as we've done before when defining ports, let's open up a new section here called ports.

09:09.610 --> 09:17.530
We can go ahead and define a new container port and we'll go ahead and use 3002 for our TCP port.

09:17.530 --> 09:22.420
And we also need a port for our Http server.

09:22.420 --> 09:24.710
So we'll use 3003 for this.

09:24.730 --> 09:28.490
Let's go ahead and define these ports in our environment variable.

09:28.510 --> 09:40.150
Firstly, we will do the TCP port and give it a value of 3002 and then we'll have our Http port here

09:40.150 --> 09:43.570
and give it a value of 3003.

09:43.690 --> 09:47.080
Let's go ahead and run helm upgrade again.

09:47.110 --> 09:55.480
Now if we run Kubectl get pods, we can see our auth pod is now up and running and both our nest application

09:55.480 --> 09:59.650
over Http has started as well as our microservice over TCP.

09:59.830 --> 10:04.300
Let's go ahead and generate our service for our payments deployment.

10:04.330 --> 10:08.910
We'll go ahead and make sure we're in the payments folder in our templates directory.

10:08.920 --> 10:15.450
We'll go ahead and run Kubectl, create service cluster IP and call this payments.

10:15.460 --> 10:19.690
We'll go ahead and specify TCP port at 3001.

10:19.840 --> 10:29.310
Set the dry run equal to client, specify the outputs Yaml and pipe this to a service dot yaml file.

10:29.320 --> 10:36.160
Now you can see we have our newly created payment service that is going to direct traffic on port 3001

10:36.160 --> 10:38.830
to the pod port at 3001.

10:38.860 --> 10:42.110
I'll go ahead and remove the status and the creation timestamp.

10:42.130 --> 10:42.430
Okay.

10:42.430 --> 10:46.420
So we need to generate the service for the auth deployment.

10:46.450 --> 10:52.990
Now let's go ahead and run kubectl, create service cluster IP auth.

10:52.990 --> 11:02.350
We're going to go ahead and specify the TCP equal to 3002 and comma 3003 so that we can open up two

11:02.380 --> 11:08.200
ports on this service because of course, if you remember, auth will have two ports, one for Http

11:08.440 --> 11:10.840
and one for our microservice over TCP.

11:11.080 --> 11:17.600
We'll set the dry run equal to client output Yaml and spit this out to a service dot yaml file.

11:17.620 --> 11:24.100
Now if we look at the services yaml for auth you can see we have two ports open up exactly as we designed.

11:24.130 --> 11:27.940
We'll go ahead and remove the status and the creation timestamp.

11:27.940 --> 11:35.200
Finally, we're ready to set up our reservations deployment and you can see all the environment variables

11:35.200 --> 11:36.490
we need to define now.

11:36.490 --> 11:38.770
So open up the reservations deployment.

11:38.800 --> 11:42.430
Of course, we know we have the MongoDB Uri already specified.

11:42.430 --> 11:46.870
Let's go ahead and set up a port for the reservation service itself.

11:46.870 --> 11:54.250
We'll go ahead and specify a ports section and I'll give it a container port at 3004.

11:54.280 --> 12:01.640
Let's go ahead and specify this environment variable name of port and give it a value of 3004.

12:01.660 --> 12:05.890
Now we need to specify the auth host and port.

12:05.890 --> 12:07.150
So let's go ahead and do that.

12:07.150 --> 12:10.300
Next, we know the name of the auth service.

12:10.330 --> 12:16.180
We know the name will be auth host and of course we know the value will be the name of the author.

12:16.250 --> 12:17.060
Service.

12:17.060 --> 12:23.690
And so we know if you run kubectl get service, the auth service hostname will be auth.

12:23.690 --> 12:30.410
So we'll go ahead and provide the name auth and the auth port with a value.

12:30.410 --> 12:36.530
So for the auth port we want to make sure that we're using the TCP port and not the Http one because

12:36.530 --> 12:39.380
we're communicating through the microservice layer.

12:39.380 --> 12:44.870
So to confirm this, we can go ahead and look at what we defined in the auth deployment.

12:44.900 --> 12:52.220
Well, the TCP port is at 3002, so let's go ahead and define this as 3002.

12:52.220 --> 13:02.900
Next, we have the payments host, which we know will be payments and the payments port which we can

13:02.900 --> 13:05.870
check to see will be at 3001.

13:05.870 --> 13:08.210
So let's go ahead and define that now.

13:08.390 --> 13:12.410
So finally we can go ahead and run helm Upgrade Sleeper one more time.

13:12.410 --> 13:18.930
And if we run Kubectl get Pods, we can see our reservation pod has finally started up.

13:18.930 --> 13:23.730
Let's go ahead and check out the logs to see that it has started up successfully.
