WEBVTT

00:01.230 --> 00:03.030
-: In the last section we had a long discussion talking

00:03.030 --> 00:05.790
about how we're going to uniquely tag each of our images.

00:05.790 --> 00:08.370
And the first thing we need to do is add some code

00:08.370 --> 00:10.560
to our Travis.yml file that's going

00:10.560 --> 00:13.672
to determine the current git SHA for our repository

00:13.672 --> 00:16.650
and export it as a environment variable so

00:16.650 --> 00:19.563
that we can later on use it inside of our deploy file.

00:20.490 --> 00:24.210
I'm gonna flip over to my Travis.yml file

00:24.210 --> 00:27.000
and up at the top, right after our services section,

00:27.000 --> 00:30.270
I'm gonna add on a new section called ENV.

00:30.270 --> 00:33.986
And then inside there, I'm gonna specify global.

00:33.986 --> 00:35.760
And inside of here we're gonna set up

00:35.760 --> 00:38.070
some number of environment variables.

00:38.070 --> 00:39.960
So the environment variable that you and I care about

00:39.960 --> 00:43.380
is getting the current commit SHA and I wanna store

00:43.380 --> 00:46.350
that as an environment variable called simply SHA

00:46.350 --> 00:48.810
so that we can easily refer back to it in the future

00:48.810 --> 00:52.020
inside of our deploy.sh file without having to run

00:52.020 --> 00:55.233
that git rev-parse command again and again and again.

00:56.220 --> 00:59.670
So inside of here I'll say git SHA,

00:59.670 --> 01:00.690
actually well let's keep it simple.

01:00.690 --> 01:02.430
We'll just do SHA.

01:02.430 --> 01:05.520
So that's going to be dollar sign, parentheses,

01:05.520 --> 01:08.313
git rev parse head.

01:09.270 --> 01:10.860
So, this right here is going to determine

01:10.860 --> 01:12.150
the current commit SHA

01:12.150 --> 01:14.280
and assign it to a environment variable

01:14.280 --> 01:17.700
inside of our Travis environment alone called SHA.

01:17.700 --> 01:20.130
So we can now freely access this environment variable

01:20.130 --> 01:22.530
inside the deploy.sh file.

01:22.530 --> 01:24.450
Now, while we're inside of this

01:24.450 --> 01:27.270
environment variable configuration block right here,

01:27.270 --> 01:29.370
there is actually one other environment variable

01:29.370 --> 01:30.690
that we need to specify.

01:30.690 --> 01:33.150
This is totally unrelated to all the SHA stuff.

01:33.150 --> 01:34.500
I just wanted to make sure we took care

01:34.500 --> 01:36.990
of both these environment variables at the same time.

01:36.990 --> 01:38.520
So the second environment variable that we're

01:38.520 --> 01:43.373
going to put together is cloud SDK underscore core

01:44.913 --> 01:49.913
disable prompts equals one like so.

01:50.550 --> 01:53.280
So, cloud SDK, this entire thing right here is just going

01:53.280 --> 01:55.440
to configure the Google Cloud CLI

01:55.440 --> 01:58.140
and make sure that it does not try to display any prompts

01:58.140 --> 02:00.000
that require user input.

02:00.000 --> 02:02.580
So in other words, when you and I run this command,

02:02.580 --> 02:06.150
G Cloud off activate service account, if this thing normally

02:06.150 --> 02:07.957
presents some warning or something that says like,

02:07.957 --> 02:10.740
"Are you sure you want to do this, press Y or N."

02:10.740 --> 02:12.180
We don't wanna see that because you and I

02:12.180 --> 02:13.800
don't have the ability to respond to that

02:13.800 --> 02:15.240
in a Travis environment.

02:15.240 --> 02:16.590
And so this right here is just gonna make sure

02:16.590 --> 02:19.054
that the Google Cloud CLI does not try to show us

02:19.054 --> 02:21.900
any prompts such as that.

02:21.900 --> 02:24.780
Now this is kind of a tricky command to write out here

02:24.780 --> 02:26.850
so please make sure that you spell everything

02:26.850 --> 02:28.440
in this correctly and that everything

02:28.440 --> 02:30.510
is capitalized inside there.

02:30.510 --> 02:31.710
All right, so again, I apologize

02:31.710 --> 02:33.360
for that kind of little sidetrack

02:33.360 --> 02:34.650
but again, I just wanted to do

02:34.650 --> 02:37.100
all these environment variables at the same time.

02:38.070 --> 02:39.330
All right, so we're gonna flip back over

02:39.330 --> 02:41.820
to our deploy.sh file and we're gonna start

02:41.820 --> 02:44.190
to make some changes to this thing now to make sure

02:44.190 --> 02:47.790
that we apply not only a latest tag

02:47.790 --> 02:51.153
to all of our built images, but the git SHA as well.

02:52.170 --> 02:54.480
All right, so I'm gonna first start with the client.

02:54.480 --> 02:57.960
Now here's the dash T my docker ID multi client.

02:57.960 --> 03:00.990
I'm going to append that latest, like so.

03:00.990 --> 03:03.630
So this is just going to be a hundred percent clear

03:03.630 --> 03:08.370
that we want to tag this image as the latest version.

03:08.370 --> 03:10.980
After that, I'm then going to add on a second tag.

03:10.980 --> 03:12.060
So this is where this file's

03:12.060 --> 03:13.350
gonna get a little bit squirrely

03:13.350 --> 03:16.020
and there's gonna be a lot of text moving around here.

03:16.020 --> 03:19.410
So we're gonna say dash T, so a second tag,

03:19.410 --> 03:23.935
your docker ID slash multi client,

03:23.935 --> 03:28.323
colon and then dollar sign SHA like so.

03:31.980 --> 03:36.633
So now in total docker build, tag one with the latest,

03:38.550 --> 03:42.178
tag two with our SHA that we had defined

03:42.178 --> 03:44.490
as an environment variable inside the Travis.yml file.

03:44.490 --> 03:46.050
And then after the second tag,

03:46.050 --> 03:49.500
we should still see the dash F for the docker file

03:49.500 --> 03:51.273
and the build context on the end.

03:53.430 --> 03:56.080
Okay, so we're gonna repeat that process twice again.

03:57.360 --> 04:01.290
So, on multi-server, I'll add on colon latest

04:01.290 --> 04:06.247
and then we'll do another dash T multi-server SHA.

04:08.010 --> 04:09.480
So again, double check this line.

04:09.480 --> 04:14.480
We've got tag one with latest and then tag two with a SHA.

04:17.250 --> 04:21.303
So then finally we'll do latest on the multi worker,

04:23.040 --> 04:25.833
multi worker SHA.

04:26.850 --> 04:30.303
All right, so tag one and tag two.

04:31.440 --> 04:34.560
Again, do make sure that we have client server worker,

04:34.560 --> 04:36.870
so make sure you did not accidentally put like server

04:36.870 --> 04:38.160
in there or anything like that.

04:38.160 --> 04:40.833
We have client server worker, client server worker,

04:42.660 --> 04:44.280
client server worker, client, server worker

04:44.280 --> 04:45.130
all the way down.

04:46.260 --> 04:47.580
Okay, so that's looking good.

04:47.580 --> 04:49.020
Now the next thing we need to do is make sure

04:49.020 --> 04:52.620
that we push these new tags off to docker hub as well.

04:52.620 --> 04:55.140
So, unfortunately when you do this docker push right here,

04:55.140 --> 04:59.070
we are pushing very specific tags as opposed to an image

04:59.070 --> 05:01.050
and all the tags that it has.

05:01.050 --> 05:02.550
So, we have to run docker push

05:02.550 --> 05:04.620
not only for multi client latest

05:04.620 --> 05:08.370
but also for multi client SHA as well.

05:08.370 --> 05:10.770
So for each these different tags we have,

05:10.770 --> 05:13.833
we're going to have two separate push commands.

05:14.730 --> 05:16.110
So I'm gonna look at all the current pushes

05:16.110 --> 05:17.010
we have right here

05:18.120 --> 05:19.890
and I'm gonna put on latest to each of them

05:19.890 --> 05:21.790
just to be a hundred percent explicit.

05:24.540 --> 05:26.820
And then I'll do another set of push commands.

05:26.820 --> 05:29.130
Now for this one, I am just gonna do a copy paste,

05:29.130 --> 05:31.290
no harm in this case.

05:31.290 --> 05:34.470
So, there's my copy paste for client server worker

05:34.470 --> 05:36.720
and then I'll update each of these to be SHA,

05:37.950 --> 05:40.713
SHA, and SHA, like so.

05:45.837 --> 05:47.730
So, now the last thing we have to do is make sure

05:47.730 --> 05:51.030
that we get a separate set image command for each

05:51.030 --> 05:53.580
of our different deployments and we need to make sure

05:53.580 --> 05:56.610
that we specify multi-server with our git SHA

05:56.610 --> 05:58.080
on the end as well.

05:58.080 --> 06:01.020
And so for the first set image right here,

06:01.020 --> 06:03.120
I'm gonna go to the very end of the line.

06:03.120 --> 06:08.120
Here's multi-server and I'll append on colon SHA, like so.

06:11.820 --> 06:13.980
And then we're going to repeat this command twice again

06:13.980 --> 06:17.910
for the multi client and the multi worker as well.

06:17.910 --> 06:21.783
So I'll do cube CTL, set image deployments,

06:23.670 --> 06:24.813
client deployment,

06:26.400 --> 06:29.880
client is going to be my docker id, multi client,

06:34.230 --> 06:35.230
I'll put the SHA in.

06:38.613 --> 06:39.810
And then finally, we'll do the same thing as well

06:39.810 --> 06:44.810
for cube CTL set image deployments, worker deployment,

06:47.550 --> 06:49.860
and the worker image, or excuse me, the worker container

06:49.860 --> 06:54.810
inside that deployment needs to use the image my docker id,

06:54.810 --> 06:56.883
multi worker, colon, SHA.

06:58.710 --> 07:00.000
Okay, so that's it.

07:00.000 --> 07:01.770
That's all we have to do.

07:01.770 --> 07:03.660
Now that's the entire deployment script here.

07:03.660 --> 07:05.100
Now again, I gotta ask you,

07:05.100 --> 07:08.970
please do one last quick triple check inside of here.

07:08.970 --> 07:10.680
Make sure you've got client server worker,

07:10.680 --> 07:13.232
client server worker, server client worker,

07:13.232 --> 07:15.360
server client worker, server client worker,

07:15.360 --> 07:16.470
all the way across.

07:16.470 --> 07:19.590
No one of these lines should have like duplicated client

07:19.590 --> 07:20.640
client in a row like so.

07:20.640 --> 07:22.350
They're all completely separate images

07:22.350 --> 07:23.800
that we're working with here.

07:24.780 --> 07:28.260
Okay, so that's pretty much it for our deploy.sh file.

07:28.260 --> 07:29.250
And I think that's pretty much it

07:29.250 --> 07:31.680
for our Travis.email file, as well.

07:31.680 --> 07:33.900
So we're just about ready to push this thing

07:33.900 --> 07:36.360
off to GitHub and test out our deployment.

07:36.360 --> 07:38.850
But before we do, there's one or two last quick things

07:38.850 --> 07:42.510
we have to take care of inside of our Kubernetes cluster

07:42.510 --> 07:44.070
on Google Cloud.

07:44.070 --> 07:45.300
So let's take a quick pause right here,

07:45.300 --> 07:46.530
come back to the next section,

07:46.530 --> 07:48.960
and one last little piece of setup we have to get to.

07:48.960 --> 07:50.610
So I'll see you in just a minute.
