WEBVTT

00:01.200 --> 00:03.330
-: We've now installed our Google Cloud CLI,

00:03.330 --> 00:04.163
configured it,

00:04.163 --> 00:05.340
logged in with Docker,

00:05.340 --> 00:06.450
built our test image,

00:06.450 --> 00:07.800
and then ran our tests.

00:07.800 --> 00:09.360
So now, we wanna start focusing

00:09.360 --> 00:11.340
on doing our actual deployment,

00:11.340 --> 00:14.100
assuming that all the tests were successfully ran.

00:14.100 --> 00:15.660
Now to actually do our deployment,

00:15.660 --> 00:17.190
we're going to write a script

00:17.190 --> 00:19.290
separate from the travis.yml file.

00:19.290 --> 00:20.400
And inside that script,

00:20.400 --> 00:22.140
we're gonna put in a series of commands

00:22.140 --> 00:24.930
that are going to build our images one by one,

00:24.930 --> 00:25.980
tag each one,

00:25.980 --> 00:27.450
push them to Docker Hub,

00:27.450 --> 00:30.300
apply all of our config files inside the K8's folder,

00:30.300 --> 00:32.760
and then do that imperative set image command

00:32.760 --> 00:34.410
for each of our deployments.

00:34.410 --> 00:36.300
So all this stuff right here,

00:36.300 --> 00:38.040
all going to be executed inside

00:38.040 --> 00:39.870
of a separate test file, excuse me,

00:39.870 --> 00:41.490
a separate script file,

00:41.490 --> 00:43.860
apart from our travis.yml file.

00:43.860 --> 00:45.870
Now, why is this gonna be in a separate file?

00:45.870 --> 00:47.400
Well, I want you to recall

00:47.400 --> 00:49.860
how we put together our travis.yml file

00:49.860 --> 00:52.080
for the Elastic Beanstalk project,

00:52.080 --> 00:52.913
and I'm gonna pull it

00:52.913 --> 00:54.360
on the screen here very quickly.

00:54.360 --> 00:55.319
All right.

00:55.319 --> 00:56.520
So here's the old travis.yml file,

00:56.520 --> 00:57.840
and just to be really clear,

00:57.840 --> 00:58.770
I labeled it right here,

00:58.770 --> 01:00.990
this is old stuff from the last project

01:00.990 --> 01:03.450
not relevant to what we're doing right now.

01:03.450 --> 01:04.980
So on our previous project,

01:04.980 --> 01:06.930
we put together the deploy section,

01:06.930 --> 01:09.030
and we specified a provider.

01:09.030 --> 01:10.320
When we specified the provider,

01:10.320 --> 01:12.120
that essentially told Travis

01:12.120 --> 01:13.650
to take all of our code

01:13.650 --> 01:16.920
and use this pre-established deployment script

01:16.920 --> 01:18.270
that Travis maintains,

01:18.270 --> 01:19.440
to take all of our code

01:19.440 --> 01:22.080
and send it off to Elastic Beanstalk.

01:22.080 --> 01:24.990
Now, Travis does not have a similar built-in provider

01:24.990 --> 01:26.280
for deploying code off

01:26.280 --> 01:27.870
to a Kubernetes cluster.

01:27.870 --> 01:29.580
If we want to deploy to Kubernetes,

01:29.580 --> 01:32.790
we have to put together our own custom series of commands,

01:32.790 --> 01:33.623
and tell Travis,

01:33.623 --> 01:35.790
"Hey, just run these commands for us.

01:35.790 --> 01:38.190
We'll take care of the deployment, just run these."

01:38.190 --> 01:39.840
So that's essentially what we're going to do.

01:39.840 --> 01:42.150
There is no built-in provider for Kubernetes,

01:42.150 --> 01:45.063
we have to put our own solution together from scratch.

01:46.276 --> 01:47.340
All right.

01:47.340 --> 01:48.570
So to do so,

01:48.570 --> 01:52.140
I'm gonna open up my travis.yml file for our project,

01:52.140 --> 01:53.040
inside of here,

01:53.040 --> 01:55.800
we're gonna put together our deploy section,

01:55.800 --> 01:58.080
but our deploy section is gonna look a little bit different

01:58.080 --> 01:59.640
than the previous ones.

01:59.640 --> 02:02.910
I'll specify a provider of script, like so.

02:02.910 --> 02:05.100
So before we had said Elastic Beanstalk,

02:05.100 --> 02:06.480
this time we're saying script,

02:06.480 --> 02:07.987
which is telling Travis that,

02:07.987 --> 02:10.440
"Hey, don't try to do anything with our project,

02:10.440 --> 02:11.760
we'll take care of the deployment.

02:11.760 --> 02:13.707
Just run the script file for us."

02:14.700 --> 02:17.190
We then have to specify a command to run,

02:17.190 --> 02:19.050
that's going to essentially be the script

02:19.050 --> 02:20.940
that we want Travis to execute.

02:20.940 --> 02:25.933
So I'm gonna say ash./deploy.sh.

02:27.180 --> 02:28.440
So this is essentially saying

02:28.440 --> 02:30.060
that you and I are gonna put together

02:30.060 --> 02:34.140
a custom script file called deploy.sh.

02:34.140 --> 02:36.180
And inside of that custom script file,

02:36.180 --> 02:38.250
we're gonna write out a series of commands

02:38.250 --> 02:39.930
that's going to go through all those steps

02:39.930 --> 02:41.310
that we have just mentioned.

02:41.310 --> 02:43.620
Building our images, applying configs,

02:43.620 --> 02:45.300
and imperatively setting images

02:45.300 --> 02:46.653
on each deployment.

02:48.180 --> 02:49.320
So this right here again,

02:49.320 --> 02:50.347
is what's telling Travis,

02:50.347 --> 02:51.630
"Don't worry about the deployment,

02:51.630 --> 02:53.970
just run this command for us right here,

02:53.970 --> 02:56.520
and we'll do the deployment ourselves."

02:56.520 --> 02:58.020
Now there is one other option on here

02:58.020 --> 02:59.370
that we are gonna specify,

02:59.370 --> 03:02.220
we'll say on branch master.

03:02.220 --> 03:04.740
So remember, if we are pushing up some like feature

03:04.740 --> 03:05.940
or development branch,

03:05.940 --> 03:08.220
we probably don't want to execute this deploy script.

03:08.220 --> 03:09.900
We only want to do our deployment

03:09.900 --> 03:12.120
if we are pushing up branch master.

03:12.120 --> 03:14.070
So only for working on the master branch,

03:14.070 --> 03:16.170
do we want to run this command right here,

03:16.170 --> 03:18.022
which is gonna run that deploy script file

03:18.022 --> 03:21.840
and attempt to deploy all of our new images out.

03:21.840 --> 03:22.673
All right.

03:22.673 --> 03:23.820
So then now the last thing I wanna do in this section

03:23.820 --> 03:26.730
is very quickly create this deploy.sh file

03:26.730 --> 03:29.070
inside of our root project directory.

03:29.070 --> 03:31.140
So inside the root project,

03:31.140 --> 03:33.663
I'll create deploy.sh.

03:34.710 --> 03:35.940
So again, inside of here,

03:35.940 --> 03:38.430
we're gonna put together our series of commands

03:38.430 --> 03:40.230
that's going to build the images,

03:40.230 --> 03:42.390
tag them, push them, apply configs,

03:42.390 --> 03:43.380
and so on.

03:43.380 --> 03:44.850
So let's take a quick pause right here.

03:44.850 --> 03:46.020
When we come back to the next section,

03:46.020 --> 03:47.880
we're gonna start filling out our implementation

03:47.880 --> 03:49.143
for our deploy script.
