WEBVTT

00:00.720 --> 00:03.600
-: In the last section, we created a deploy dot SH file.

00:03.600 --> 00:06.900
So inside this file we have to do our image building

00:06.900 --> 00:10.170
apply some configs and imperatively, set the latest images.

00:10.170 --> 00:12.480
Now, I've repeated this series of three steps right here

00:12.480 --> 00:13.980
like five or six times

00:13.980 --> 00:15.480
and I'm sure you're tired of me saying it.

00:15.480 --> 00:16.920
The reason that I keep talking

00:16.920 --> 00:18.450
about these three steps right here is

00:18.450 --> 00:20.850
that it's actually gonna be a little bit more challenging

00:20.850 --> 00:23.100
than it might seem at first glance.

00:23.100 --> 00:25.380
So we're gonna do kind of a initial take

00:25.380 --> 00:26.580
on these steps right here.

00:26.580 --> 00:28.770
And then as we start to go through a couple of these steps

00:28.770 --> 00:30.150
we're gonna very quickly realize

00:30.150 --> 00:32.310
that there's a little bit of an issue

00:32.310 --> 00:34.980
with some of the config that we'll put together

00:34.980 --> 00:37.148
for these steps that you would think would be reasonable.

00:37.148 --> 00:38.640
So in other words, we're gonna write out

00:38.640 --> 00:40.800
what's gonna seem like the right code

00:40.800 --> 00:42.933
or the right commands, but at the end of the day,

00:42.933 --> 00:45.960
something's gonna be just a little bit off.

00:45.960 --> 00:48.150
All right, so let's get to it.

00:48.150 --> 00:50.190
Inside my deploy dot sh file

00:50.190 --> 00:51.660
we're gonna first write out a series

00:51.660 --> 00:53.892
of commands to build each of our different images

00:53.892 --> 00:57.420
and then push them each off to Docker hub.

00:57.420 --> 01:01.380
So I'm going to do a Docker build, I'm going to tag it.

01:01.380 --> 01:03.360
I'll put in my Docker ID.

01:03.360 --> 01:05.591
We'll do our multi client first.

01:05.591 --> 01:08.640
I'll specify the Docker file location,

01:08.640 --> 01:12.420
which is dot slash client Docker file.

01:12.420 --> 01:15.060
And then I will also specify my build context

01:15.060 --> 01:17.043
of dot slash client.

01:18.510 --> 01:19.980
Now I'm gonna zoom out for just a second so you

01:19.980 --> 01:21.243
can see that entire line.

01:22.230 --> 01:24.300
Okay, so there it is in entirety.

01:24.300 --> 01:27.480
Now I'm going to do the same thing twice again.

01:27.480 --> 01:30.330
Once for our server image and once for the worker.

01:30.330 --> 01:32.970
I encourage you to not do a copy paste here

01:32.970 --> 01:34.440
because if you do a copy paste

01:34.440 --> 01:37.410
incredibly likely that you might forget to change

01:37.410 --> 01:40.320
one of the mentions of client inside of here.

01:40.320 --> 01:42.360
All right, so we'll do a Docker build

01:42.360 --> 01:43.443
Docker ID,

01:44.460 --> 01:45.453
multi-server,

01:46.320 --> 01:49.563
server, Docker file, and server.

01:51.000 --> 01:52.920
So now at this point I want you to double check

01:52.920 --> 01:54.090
three locations.

01:54.090 --> 01:56.310
One, two, three.

01:56.310 --> 01:58.410
Those should all say server.

01:58.410 --> 02:01.350
Should not see any mention of client on the second line.

02:01.350 --> 02:03.600
And they'll do the same thing a third time around.

02:03.600 --> 02:06.003
So I'll say Docker bill dash T,

02:08.160 --> 02:08.993
worker,

02:11.910 --> 02:14.400
get the worker Docker file, and then finally

02:14.400 --> 02:17.040
specify the build context of worker as well.

02:17.040 --> 02:18.688
And so now again I want you to triple check

02:18.688 --> 02:22.560
multi worker, worker and worker.

02:22.560 --> 02:24.300
Cool. So that looks good.

02:24.300 --> 02:26.940
Okay, so that is us building our images.

02:26.940 --> 02:28.350
So now the next thing we have to do

02:28.350 --> 02:32.430
is take to those images and push them off to Docker hub.

02:32.430 --> 02:34.980
Now we've already logged into Docker through

02:34.980 --> 02:36.930
our Travis dot YAML file.

02:36.930 --> 02:39.340
The Docker command that we're using right here

02:40.429 --> 02:41.580
is the same Docker that we're kind of configuring

02:41.580 --> 02:43.840
back inside the Travis dot YAML file with the

02:43.840 --> 02:46.461
Docker login command, wherever we put that.

02:46.461 --> 02:48.150
Here it is right here.

02:48.150 --> 02:50.160
So we don't have to log in again or anything like that.

02:50.160 --> 02:52.170
We can just freely take each of these images

02:52.170 --> 02:53.770
and push them off to Docker hub.

02:55.500 --> 03:00.349
So I'll do a Docker push via Docker ID multi client

03:00.349 --> 03:05.010
and then I'm going to repeat the process two more times

03:05.010 --> 03:06.060
and let me zoom in now

03:06.060 --> 03:09.540
since we're looking at a very shorter line here.

03:09.540 --> 03:11.073
So I'll do Docker ID,

03:13.170 --> 03:14.943
multi-server and finally,

03:18.967 --> 03:19.830
multi worker like so.

03:19.830 --> 03:21.270
Okay. So yeah, it still seems

03:21.270 --> 03:23.310
like everything is looking pretty good.

03:23.310 --> 03:25.620
Let's go back over to our diagram over here.

03:25.620 --> 03:27.090
So the next step after building

03:27.090 --> 03:29.460
and pushing those images is to take all the configs

03:29.460 --> 03:31.353
in the K eight directory and apply them.

03:31.353 --> 03:33.591
Now remember inside the Travis dot YAML file

03:33.591 --> 03:36.870
we already configured Google Cloud.

03:36.870 --> 03:39.810
And Google Cloud is in charge of our kubectl command

03:39.810 --> 03:41.760
inside of this Travis environment.

03:41.760 --> 03:44.670
So we don't have to do any more configuration of kubectl.

03:44.670 --> 03:48.930
We can just write kubectl commands in the exact same fashion

03:48.930 --> 03:52.200
as though we were running them on our own local machine.

03:52.200 --> 03:54.720
And so to take all of the different config files inside

03:54.720 --> 03:56.010
of our K eights directory

03:56.010 --> 04:01.010
we'll simply do kubectl, apply, dash F, K eights.

04:01.080 --> 04:03.150
So take everything inside that K eights directory

04:03.150 --> 04:05.013
apply all those config files.

04:06.360 --> 04:08.280
Okay, so now the last step we have to go through

04:08.280 --> 04:10.622
imperatively set the latest image on each deployment.

04:10.622 --> 04:12.540
So this is where things are gonna start to

04:12.540 --> 04:14.220
get really interesting, and we're going to very

04:14.220 --> 04:15.510
quickly see that there's

04:15.510 --> 04:18.513
a little bit of an issue with what we are doing here.

04:19.770 --> 04:22.080
So remember how we set a image forcibly

04:22.080 --> 04:24.510
or imperatively on a deployment?

04:24.510 --> 04:28.260
We do it by writing out kubectl set image.

04:28.260 --> 04:31.210
Then we'd reference the object type that we want to update.

04:32.460 --> 04:34.080
Then the name of our deployment,

04:34.080 --> 04:36.330
which in our case for the server is server deployment.

04:36.330 --> 04:39.510
And we can get the name of that from our K eights directory.

04:39.510 --> 04:41.670
Here's the server deployment file right here.

04:41.670 --> 04:44.070
And we had given it a name of server deployment.

04:45.300 --> 04:46.380
So that looks good.

04:46.380 --> 04:49.200
So we're saying deployments server deployment

04:49.200 --> 04:51.870
and then we select the server container

04:51.870 --> 04:54.570
and we tell it to use the image

04:54.570 --> 04:59.570
my Docker ID slash multi server, like so.

05:00.780 --> 05:01.740
All right.

05:01.740 --> 05:03.810
So I wanna look at this configuration

05:03.810 --> 05:04.643
that we just put together

05:04.643 --> 05:06.750
and notice how we're not gonna do the last two

05:06.750 --> 05:08.790
or the other two deployments in here just yet.

05:08.790 --> 05:11.760
Cause I wanna point out something that is not quite correct

05:11.760 --> 05:13.590
with how we've written out this command right here

05:13.590 --> 05:16.020
and the entire series of commands inside this file.

05:16.020 --> 05:16.853
Don't worry

05:16.853 --> 05:18.180
I'm not saying we have to rewrite the entire file

05:18.180 --> 05:19.560
I'm just saying that there's one

05:19.560 --> 05:22.920
or two little things inside of here that we need to tweak.

05:22.920 --> 05:25.050
So I want you to think about what's going on inside

05:25.050 --> 05:27.540
of that deploy file right now.

05:27.540 --> 05:29.250
At the very top, we're essentially saying,

05:29.250 --> 05:30.870
Okay let's do our Docker build

05:30.870 --> 05:32.490
and then we tag our image,

05:32.490 --> 05:33.323
like in this case,

05:33.323 --> 05:36.270
it's the multi client with just the name

05:36.270 --> 05:39.300
whatever my Docker ID is slash multi client.

05:39.300 --> 05:41.190
And so the results of this entire command right here

05:41.190 --> 05:43.230
is an image with the command

05:43.230 --> 05:45.570
or something with the tag Docker ID multi client.

05:45.570 --> 05:48.150
And remember, anytime that we build an image

05:48.150 --> 05:51.720
if we do not specify a tag, the implicit understanding

05:51.720 --> 05:55.440
is that it gets automatically a tag of latest applied to it.

05:55.440 --> 05:57.930
In fact, you can actually double check that right now

05:57.930 --> 06:00.240
if you check out your Docker hub account.

06:00.240 --> 06:02.250
So if you go to hub.docker.com

06:02.250 --> 06:05.850
and look at your multi client image, look at tags,

06:05.850 --> 06:08.853
and you'll see inside of here, here's latest.

06:09.690 --> 06:10.920
So I've got some other versions.

06:10.920 --> 06:12.990
So we had put together previously, but essentially

06:12.990 --> 06:15.900
right now the latest copy is tagged as latest.

06:15.900 --> 06:18.060
That is the implicit tag that is assigned

06:18.060 --> 06:21.660
to any image that I build and push off to Docker hub.

06:21.660 --> 06:22.800
So what's that mean?

06:22.800 --> 06:25.680
Well, it means that later on when we run Docker

06:25.680 --> 06:28.950
blah blah or kubectl, set image, blah, blah, blah

06:28.950 --> 06:32.640
and then specified the multi-client image that deployment,

06:32.640 --> 06:34.515
and this is something that we ran into previously remember,

06:34.515 --> 06:37.830
that deployment looks at the image that is specified

06:37.830 --> 06:40.230
it sees Docker ID slash multi-client

06:40.230 --> 06:42.450
and then maybe we add on old and latest here,

06:42.450 --> 06:43.283
maybe we don't.

06:43.283 --> 06:44.670
Doesn't really matter either way.

06:44.670 --> 06:47.280
Essentially the deployment is gonna look at that image name

06:47.280 --> 06:48.180
and it's gonna say,

06:48.180 --> 06:50.190
Oh I was already running the latest image

06:50.190 --> 06:53.189
so I don't have to make any change whatsoever.

06:53.189 --> 06:56.460
Remember we spoke about this at great length

06:56.460 --> 06:58.290
earlier on inside the course.

06:58.290 --> 07:00.415
We had spoken about the set image command.

07:00.415 --> 07:03.360
We had spoken about how there's a couple of different ways

07:03.360 --> 07:06.390
of somehow telling a deployment to update the version

07:06.390 --> 07:07.620
of an image that it uses.

07:07.620 --> 07:09.300
And we had eventually landed on saying

07:09.300 --> 07:11.280
that we were gonna use a imperative command to

07:11.280 --> 07:13.170
update our deployment.

07:13.170 --> 07:14.003
So we had said

07:14.003 --> 07:16.200
that the I entire flow was gonna be something like this.

07:16.200 --> 07:18.090
We were going to change our, well,

07:18.090 --> 07:20.520
this was a very particular workflow right here

07:20.520 --> 07:21.420
but we had essentially said

07:21.420 --> 07:23.580
that we were going to update the multi-client image

07:23.580 --> 07:26.040
and we were then going to very importantly,

07:26.040 --> 07:29.029
tag the image with a unique version number

07:29.029 --> 07:32.280
and push it up to Docker hub,

07:32.280 --> 07:34.991
so that sometime in the future when we used Cube CTL to

07:34.991 --> 07:37.620
set the image that the deployment used

07:37.620 --> 07:41.760
we could specify a very particular version of that image.

07:41.760 --> 07:43.770
So that the deployment would say,

07:43.770 --> 07:47.040
Oh, okay I see you've applied some new version here

07:47.040 --> 07:48.660
or it's a image name that is different

07:48.660 --> 07:49.950
than the one that I'm currently running.

07:49.950 --> 07:52.470
So an update is required.

07:52.470 --> 07:53.970
So essentially the issue

07:53.970 --> 07:56.970
with all the deployment commands we've put in here so far

07:56.970 --> 07:59.340
is that we're kind of operating under the assumption

07:59.340 --> 08:01.830
that all these images are using that latest tag.

08:01.830 --> 08:03.540
And as soon as we set an image

08:03.540 --> 08:05.670
with the latest tag on our deployment,

08:05.670 --> 08:07.080
the deployment's gonna say,

08:07.080 --> 08:10.860
I'm already running latest, no change required.

08:10.860 --> 08:13.380
All right, so now that we remember this entire situation

08:13.380 --> 08:16.020
because we did cover it quite a bit ago inside this course

08:16.020 --> 08:17.610
let's take a quick pause when we come back

08:17.610 --> 08:18.971
to the next section, we're gonna talk about how

08:18.971 --> 08:22.189
we can get some version numbers to be automatically applied

08:22.189 --> 08:24.420
to all of our different image tags,

08:24.420 --> 08:26.700
and how we can essentially solve this entire issue

08:26.700 --> 08:28.230
with making sure that our deployments

08:28.230 --> 08:31.140
really get the latest version of these images.

08:31.140 --> 08:33.563
So quick pause and I'll see you in just a minute.
