WEBVTT

00:00.000 --> 00:02.790
-: All right my friends, we've now got our application

00:02.790 --> 00:04.260
up and running with Kubernetes

00:04.260 --> 00:06.660
but there's one last thing I want to show you.

00:06.660 --> 00:08.580
Right now, we don't really have a good setup

00:08.580 --> 00:10.080
for running our code locally

00:10.080 --> 00:12.570
and doing local development with Kubernetes.

00:12.570 --> 00:15.030
Sure, we can deploy to our mini cube cluster

00:15.030 --> 00:16.560
but going through the process of actually

00:16.560 --> 00:19.530
developing our application is a little bit awkward.

00:19.530 --> 00:21.300
Let me show you what I mean.

00:21.300 --> 00:23.820
If you recall back on the Docker Compose stuff we did,

00:23.820 --> 00:27.960
we had set up a client container for our React project.

00:27.960 --> 00:30.780
When we made use of Docker Compose, we set up a volume

00:30.780 --> 00:33.210
that mapped our local React Project directory

00:33.210 --> 00:34.380
into that volume.

00:34.380 --> 00:37.200
So essentially, we were sharing our source code

00:37.200 --> 00:40.830
between our local file system and that client container.

00:40.830 --> 00:42.600
That meant that anytime we changed our code

00:42.600 --> 00:45.330
on our local machine, it updated the code inside

00:45.330 --> 00:47.700
the container as well, and the React application

00:47.700 --> 00:50.970
automatically updated right before our eyes.

00:50.970 --> 00:54.210
Now this system only works with Docker Composed right now

00:54.210 --> 00:57.300
we don't really have anything equivalent for Kubernetes.

00:57.300 --> 00:59.520
So right now if you and I wanted to make some change

00:59.520 --> 01:02.400
to our local React Project during development,

01:02.400 --> 01:05.010
we don't have any easy way to somehow inject

01:05.010 --> 01:07.980
that source code into our client pod.

01:07.980 --> 01:10.200
Instead, we would have to completely rebuild

01:10.200 --> 01:15.180
the client image and then rerun that Cube CTL apply command.

01:15.180 --> 01:16.443
That's definitely a pain.

01:17.340 --> 01:18.690
So let me show you a better way to handle

01:18.690 --> 01:20.460
this development process.

01:20.460 --> 01:23.370
We're going to be making use of a tool called Scaffold.

01:23.370 --> 01:26.670
This is a command line tool separate from Kubernetes

01:26.670 --> 01:28.830
but designed to be used with Kubernetes

01:28.830 --> 01:31.560
just to facilitate local development.

01:31.560 --> 01:33.270
Here's how Scaffold works.

01:33.270 --> 01:36.000
Scaffold is going to watch our local React Project

01:36.000 --> 01:37.380
directory for changes.

01:37.380 --> 01:39.600
So you and I might then open up our code editor

01:39.600 --> 01:43.020
and change some React component or whatever else.

01:43.020 --> 01:45.720
Once we save that file, Scaffold is gonna see that

01:45.720 --> 01:47.760
a change occurred and then Scaffold

01:47.760 --> 01:50.100
is gonna jump into action.

01:50.100 --> 01:53.250
Scaffold is all about somehow taking that change in our code

01:53.250 --> 01:56.400
and getting it reflected inside of our Kubernetes cluster.

01:56.400 --> 01:59.040
It can do that with one of two different modes

01:59.040 --> 02:02.100
and we're going to explore both these different modes.

02:02.100 --> 02:04.170
The first way that Scaffold is going to somehow

02:04.170 --> 02:06.390
update our client pod inside of our cluster

02:06.390 --> 02:08.100
is just automatically rebuild

02:08.100 --> 02:10.440
the entire client image from scratch.

02:10.440 --> 02:13.650
When I say from scratch, I don't mean like rerun

02:13.650 --> 02:16.320
every single step including installing dependencies,

02:16.320 --> 02:19.290
it will be just a normal Docker build process.

02:19.290 --> 02:22.650
Scaffold is going to tell Docker to rebuild the client.

02:22.650 --> 02:24.690
Docker is going to see that the only change we made

02:24.690 --> 02:26.730
was to our source code, and so it's essentially

02:26.730 --> 02:28.380
just going to stick that source code

02:28.380 --> 02:30.750
into a new updated image.

02:30.750 --> 02:33.240
Scaffold will then take that image and update

02:33.240 --> 02:35.760
our local Kubernetes cluster, and then we should see

02:35.760 --> 02:37.983
our updated application appear.

02:39.000 --> 02:41.100
Now that process is still a little bit slow

02:41.100 --> 02:42.990
because we have to go through that entire sequence

02:42.990 --> 02:45.360
of rebuilding the image, even though it's kind of just

02:45.360 --> 02:48.270
the last step we are changing and then we still have to go

02:48.270 --> 02:50.520
through that redeployment process.

02:50.520 --> 02:54.240
So the other way that Scaffold can work is mode two

02:54.240 --> 02:56.790
which is to essentially take the updated files

02:56.790 --> 02:59.940
or the changes we made in our local React Project directory

02:59.940 --> 03:04.260
and just kind of magically inject them into our client pod.

03:04.260 --> 03:06.150
It will then be up to our client pod

03:06.150 --> 03:09.360
to somehow automatically update itself.

03:09.360 --> 03:10.500
So with mode two right here

03:10.500 --> 03:12.030
if we want to go through mode two

03:12.030 --> 03:14.610
we need to make sure that our client pod is running

03:14.610 --> 03:17.700
in such a mode where it's going to see these updated files

03:17.700 --> 03:20.220
and automatically update itself.

03:20.220 --> 03:22.290
We've already set up Create React App.

03:22.290 --> 03:24.360
Remember, Create React App is going to automatically

03:24.360 --> 03:25.740
refresh the change, or excuse me

03:25.740 --> 03:28.620
refresh the page anytime we change a file.

03:28.620 --> 03:31.080
We also set up our Node project as well

03:31.080 --> 03:33.510
the backend API server with Nodemon.

03:33.510 --> 03:35.160
So Nodemon watches for changes

03:35.160 --> 03:36.990
inside of our project directory.

03:36.990 --> 03:39.690
So right now our API server and the client pod

03:39.690 --> 03:43.620
will automatically refresh given this updated source code.

03:43.620 --> 03:45.930
So we currently have a project that's kind of well-suited

03:45.930 --> 03:47.013
for mode number two.

03:48.000 --> 03:50.730
Okay, so now we've got an overview of what Scaffold does.

03:50.730 --> 03:52.620
Let's start to go through the installation process

03:52.620 --> 03:53.613
in the next video.
