WEBVTT

00:00.320 --> 00:00.620
Okay.

00:00.620 --> 00:07.460
So back in the Google console, we are going to make use of the Google Cloud to deploy our application

00:07.460 --> 00:12.200
in a Kubernetes cluster as well as to store our Docker images.

00:12.230 --> 00:17.150
The reason why we're using Google Cloud is because, as you can see up top here, we can start a free

00:17.150 --> 00:23.630
trial and get $300 in credit, which means we can deploy our application in a production setting completely

00:23.630 --> 00:25.880
free using this free credit.

00:25.910 --> 00:33.530
So let's go ahead and get started by looking up the container registry in the search bar here.

00:33.800 --> 00:36.740
And this is where we're going to push our Docker images to.

00:36.770 --> 00:39.230
It will be a private Docker registry.

00:39.230 --> 00:45.800
And this is so that only our Kubernetes cluster or our local cluster will be able to access these images,

00:45.800 --> 00:47.530
which is exactly what we want.

00:47.540 --> 00:54.170
So let's go ahead and start by clicking Enable this API and you can see we have billing required, so

00:54.170 --> 00:58.070
let's hit, cancel and then up top where you see start your free trial.

00:58.070 --> 01:02.180
Let's go ahead and click Activate to activate this free trial.

01:02.190 --> 01:09.900
I'll go ahead and select other for our organization, accept the terms and conditions and click next.

01:09.900 --> 01:14.790
So next, we have to supply a credit card or billing method in Google Cloud.

01:14.790 --> 01:20.640
So go ahead and provide this note that we will get $300 in free credit and don't worry about getting

01:20.640 --> 01:21.510
charged at all.

01:21.510 --> 01:27.750
This is a $300 free credit and if this credit runs out, we will not be charged, as you can see here.

01:27.930 --> 01:28.470
Okay.

01:28.470 --> 01:34.350
So after signing up for our Google Cloud free trial, I'm going to go back into the search bar here

01:34.350 --> 01:37.080
and look for the registry here.

01:37.080 --> 01:40.230
And we're going to choose the artifact registry.

01:40.680 --> 01:44.910
And then we're going to go ahead and click enable to enable the API.

01:45.480 --> 01:50.820
Next we're going to go ahead and click Create Repository and we're going to go ahead and create four

01:50.820 --> 01:53.730
repositories for each of our microservices.

01:53.730 --> 01:58.500
So let's go ahead and start off by creating the reservations repository.

01:58.500 --> 02:02.460
And each one of these will be where we are going to push our Docker images to.

02:02.460 --> 02:07.140
So of course we'll keep the format here as Docker for the region here.

02:07.140 --> 02:13.290
I'll go ahead and select us East four Feel free to select whichever region you'd like and then go ahead

02:13.290 --> 02:14.700
and click Create.

02:14.730 --> 02:17.910
You can see that our new repository has been created.

02:17.910 --> 02:24.720
Go ahead and repeat the same process for the three other services, the auth service notifications and

02:24.720 --> 02:25.590
payments.

02:25.620 --> 02:25.950
Okay.

02:25.950 --> 02:31.470
So after creating the remaining repositories for all of our services, you can see we have our four

02:31.470 --> 02:32.880
repositories here now.

02:32.880 --> 02:37.860
So if we click on any one of these, for example, the reservations and then we'll click on the setup

02:37.860 --> 02:40.680
instructions button where we'll have the instructions.

02:40.680 --> 02:45.900
You can first see that we need to make sure we have the Google Cloud SDK installed, which is what we're

02:45.900 --> 02:52.290
going to be utilizing a lot in this production deployment to communicate with the Google cloud on our

02:52.290 --> 02:58.920
CLI as well as to configure Docker here, we'll need to do in order to authenticate with Gcloud and

02:58.920 --> 03:01.830
make sure we have access to push and pull these images.

03:01.830 --> 03:07.860
So let's go ahead and click this link to go to the Google Cloud SDK documentation where you can see

03:07.860 --> 03:09.870
we have a guide and a quickstart.

03:09.870 --> 03:13.350
So I'll click on the quickstart to install the Google Cloud CLI.

03:13.380 --> 03:19.410
Then I'll scroll down to the instructions to install the latest Gcloud CLI version and you can see we

03:19.410 --> 03:22.200
have instructions for all different operating systems here.

03:22.200 --> 03:26.940
So select your operating system and follow the instructions to install gcloud.

03:26.940 --> 03:32.460
I'm using a mac OS so of course I'll firstly check to see that I have Python three running.

03:32.460 --> 03:39.240
So I'll go ahead and confirm this in my terminal by running Python 3-V and you can see we have python

03:39.240 --> 03:39.900
installed.

03:39.900 --> 03:45.840
If you don't have Python installed in your system, simply go to python.org and then go to the download

03:45.840 --> 03:49.770
sections where you can find the correct download for your system.

03:49.770 --> 03:53.220
Next, I'm going to go ahead and select the correct platform for my system.

03:53.220 --> 03:59.820
You can see here we can run Uname dash M from the command line to find out the correct version on your

03:59.820 --> 04:01.260
Mac if you're using Mac.

04:01.290 --> 04:06.510
In my case, I'm using the 686 by 64 and here I'll go ahead and download this.

04:06.510 --> 04:12.900
Lastly, you can see here we have an optional step to add the Gcloud CLI tools to our path.

04:12.900 --> 04:16.260
That way we can easily access the commands anywhere in our system.

04:16.260 --> 04:22.110
So let's go ahead and copy this command here to run the install script, which will do this for us.

04:22.110 --> 04:27.660
So back in the terminal here, I'm going to CD to my home directory where I moved the download to and

04:27.660 --> 04:29.100
have extracted it to.

04:29.100 --> 04:33.570
And you can see now I'm able to CD into a Google Cloud SDK folder.

04:33.570 --> 04:41.100
So I'll go ahead and now run the Install.sh script, which was from the documentation you can see here,

04:41.100 --> 04:46.710
it'll ask if you want us to modify our path and enable Shell command completion, I'll go ahead and

04:46.710 --> 04:52.680
select yes, and I'll go ahead and tell it to use my existing zshrc file.

04:52.680 --> 04:56.830
Or you can choose whichever path you'd want to update your path variable.

04:56.850 --> 04:58.770
Finally, it asks us if we want to install.

04:58.950 --> 05:00.050
Commended modules.

05:00.060 --> 05:01.080
I'll go ahead and select.

05:01.080 --> 05:01.460
Yes.

05:01.470 --> 05:04.380
Next we're going to go ahead and initialize gcloud.

05:04.410 --> 05:13.290
By running Gcloud config configurations create and I'll create a new configuration here for Sleeper.

05:13.320 --> 05:13.590
Okay.

05:13.590 --> 05:21.180
So next we're going to go ahead and initialize gcloud by running gcloud config configurations.

05:21.210 --> 05:25.950
Create and I'll go ahead and create a new configuration called Sleeper here.

05:25.950 --> 05:28.610
And also this will activate it.

05:28.620 --> 05:29.100
Okay.

05:29.100 --> 05:35.760
So lastly, go back into the Gcloud console and under the projects section, take note of the project

05:35.760 --> 05:38.280
ID here and back in the terminal.

05:38.280 --> 05:45.750
We're going to go ahead and use Gcloud config set project and then paste in this project ID to update

05:45.750 --> 05:51.390
our default project ID and make sure that all commands execute against this project.

05:51.390 --> 05:51.750
Okay.

05:51.750 --> 06:00.120
So back in the artifact registry, if we continue on to the setup instructions, we have initialized

06:00.120 --> 06:05.640
Gcloud and now we're going to continue to the next step configure application default credentials,

06:05.640 --> 06:11.430
which is how we're going to authenticate our Gcloud CLI to be able to communicate with our artifact

06:11.430 --> 06:12.450
registry.

06:12.450 --> 06:16.320
So let's go ahead and click on this link and learn how we can do this.

06:16.320 --> 06:22.170
You can see we have a command we can run here called application Default login, which will allow us

06:22.170 --> 06:29.820
to obtain user credentials via a web flow and allow us to easily authenticate when developing locally.

06:29.820 --> 06:31.290
So let's go ahead and do this.

06:31.290 --> 06:35.730
We're going to go ahead and copy this command here to log in to Gcloud.

06:35.730 --> 06:40.890
Then I'll go ahead and paste this command in the terminal here, which should open up a browser for

06:40.890 --> 06:41.940
authentication.

06:41.940 --> 06:42.270
Okay.

06:42.270 --> 06:46.050
So you can see we're now brought to this authentication screen.

06:46.050 --> 06:52.080
I'll go ahead and continue with this account and allow trust to the Google Auth library.

06:52.080 --> 06:57.780
And you can now see we have successfully authenticated with the Gcloud CLI and further in the terminal

06:57.780 --> 07:03.780
we can see that our credentials got saved to this file here on the application default credentials dot

07:03.810 --> 07:04.440
json.

07:04.440 --> 07:04.740
Okay.

07:04.740 --> 07:11.490
After everything set up, we then should be able to run gcloud artifacts repositories list.

07:12.120 --> 07:17.400
To see all the repositories that we have created and we should now see all of our repositories.

07:17.400 --> 07:22.920
So lastly, let's go back to our artifact registry setup instructions, and you can see we have this

07:22.920 --> 07:29.850
command here to configure Docker locally, to use Gcloud to authenticate when pushing or pulling our

07:29.850 --> 07:30.630
images.

07:30.630 --> 07:36.060
So go ahead and copy this command and go ahead and paste this command in here which will update our

07:36.060 --> 07:37.620
Docker configuration.

07:37.620 --> 07:42.960
So now we've correctly set the credentials for our Gcloud registry.

07:42.960 --> 07:47.900
Let's go ahead and start building images and pushing to our external repository.

07:47.910 --> 07:51.360
Okay, so let's go ahead and try pushing up our first image.

07:51.360 --> 07:58.830
I'll go ahead and CD to the apps directory and then directly into the reservations folder, run Docker,

07:58.830 --> 08:06.600
build tag reservations, and I'll go ahead and specify the Docker file path is at the current directory.

08:06.600 --> 08:11.790
And then I'm going to specify the context where we want to actually run this from two directories up

08:11.890 --> 08:12.790
at the root.

08:12.820 --> 08:18.670
Let's go ahead and build our Docker file next in Gcloud console, let's go back to the artifact registry,

08:18.700 --> 08:27.100
click on our reservations repository and let's go ahead and click the copy button here to copy the URI

08:27.130 --> 08:29.520
for the reservations repository.

08:29.530 --> 08:37.900
Okay, So next, let's go ahead and run Docker tag reservations and paste in our Gcloud repository URL

08:37.900 --> 08:39.430
and add one more slash.

08:39.430 --> 08:41.710
And this is going to be the name of the image.

08:41.710 --> 08:45.820
I'm going to go ahead and call this production as if we're building a production image.

08:45.820 --> 08:53.050
And finally we can go ahead and copy the full Docker image name here and run Docker image, push and

08:53.050 --> 08:54.190
paste it in here.

08:54.190 --> 08:57.760
And now we can see our image is being pushed to Gcloud.

08:57.760 --> 08:59.470
So go ahead and let this complete.

08:59.470 --> 09:05.440
After our image has finished pushing, we should then be able to go back to our repository here for

09:05.440 --> 09:09.550
reservations, refresh the page and now we can go ahead and see.

09:09.550 --> 09:11.260
We have our first image here.

09:11.260 --> 09:13.360
Tagged production pushed up.

09:13.360 --> 09:18.880
Now let's go ahead and repeat this same exact process for the rest of our microservices.

09:18.910 --> 09:21.250
Auth Notifications Payments.
