WEBVTT

00:00.813 --> 00:01.740
Presenter: In this section, we're going

00:01.740 --> 00:03.990
to get through our last set of boring config

00:03.990 --> 00:05.400
for the Postgres deployment

00:05.400 --> 00:08.010
and its associated cluster IP service.

00:08.010 --> 00:09.840
So I'm sure you don't need any clever

00:09.840 --> 00:11.850
or witty comments from me at this point.

00:11.850 --> 00:13.320
I'm sure you just wanna get this stuff done.

00:13.320 --> 00:14.850
So let's get to it.

00:14.850 --> 00:16.890
I'm gonna flip on over to my code editor

00:16.890 --> 00:18.930
inside of my K8s directory.

00:18.930 --> 00:23.930
We'll do our Postgres deployment .yaml file.

00:24.120 --> 00:25.500
Now again this is gonna be a file

00:25.500 --> 00:27.090
that's very much identical

00:27.090 --> 00:28.920
to the Redis stuff that we just put together

00:28.920 --> 00:31.230
and even the other different objects

00:31.230 --> 00:32.580
we had put together before that.

00:32.580 --> 00:35.790
I still do not recommend that you ever do a copy paste

00:35.790 --> 00:37.380
of these config files just because it's

00:37.380 --> 00:39.960
so incredibly easy to forget to update

00:39.960 --> 00:41.250
some specific property.

00:41.250 --> 00:43.020
Far safer to just rewrite it.

00:43.020 --> 00:45.120
But that's just my personal opinion.

00:45.120 --> 00:46.980
All right, so we'll do our API version

00:46.980 --> 00:49.413
of apps V1 for our deployment.

00:50.520 --> 00:54.210
This is going to be an object with a type of deployment.

00:54.210 --> 00:57.040
We'll set up our metadata if I can spell it correctly

00:58.200 --> 01:02.130
with a name of Postgres deployment, and then we'll set up

01:02.130 --> 01:05.670
our spec that's going to configure the deployment itself.

01:05.670 --> 01:08.610
So I again want to only have one replica running

01:08.610 --> 01:12.363
of my Postgres container inside of its given pod.

01:12.363 --> 01:15.660
Just very much like our Redis deployment

01:15.660 --> 01:16.493
that we just put together.

01:16.493 --> 01:18.240
We technically can create Postgres

01:18.240 --> 01:20.280
in a sort of cluster of different instances

01:20.280 --> 01:21.930
that are going to all work together

01:21.930 --> 01:25.147
to increase the availability and bandwidth of our database.

01:25.147 --> 01:26.850
However, again, that's something

01:26.850 --> 01:28.020
that's kind of outside the realm

01:28.020 --> 01:30.240
of Kubernetes that we're talking about right now.

01:30.240 --> 01:31.200
So we're just gonna focus

01:31.200 --> 01:33.573
on running a single replica as it stands.

01:34.410 --> 01:36.603
After that, we'll put down our selector.

01:37.950 --> 01:40.110
We're gonna say look for a label

01:40.110 --> 01:44.133
that is matching component Postgres.

01:46.380 --> 01:48.330
We'll then set up our pod template.

01:48.330 --> 01:50.389
So we'll give it a metadata property

01:50.389 --> 01:55.203
with labels of component Postgres.

01:56.610 --> 01:58.350
And then again, I'm going to make sure

01:58.350 --> 02:00.090
that I un-indent back to be on the same

02:00.090 --> 02:02.163
indentation level as metadata.

02:03.120 --> 02:05.220
We'll define our spec for all the different pods

02:05.220 --> 02:07.560
that get created by this deployment.

02:07.560 --> 02:10.230
I'll say here's our list of containers.

02:10.230 --> 02:13.170
I want it to have a name of Postgres.

02:13.170 --> 02:15.840
I want to use the image Postgres.

02:15.840 --> 02:17.010
And then finally, we're going to set up

02:17.010 --> 02:18.330
the ports here as well.

02:18.330 --> 02:21.030
So the default port with Postgres, which we are using

02:21.030 --> 02:23.520
we're not going to reconfigure or anything like that

02:23.520 --> 02:26.460
will set up a container port of 5 4 3 2.

02:26.460 --> 02:28.803
Again, default port for Postgres.

02:29.880 --> 02:31.020
All right, so that looks good.

02:31.020 --> 02:34.200
Now remember, very similarly to all the Redis

02:34.200 --> 02:36.840
and Express API stuff that we had done previously

02:36.840 --> 02:40.500
to get our express and our worker pods

02:40.500 --> 02:41.430
up and working correctly

02:41.430 --> 02:43.466
or more specifically the containers inside there,

02:43.466 --> 02:46.170
they need to have that set of environment variables

02:46.170 --> 02:47.003
that are going to make sure

02:47.003 --> 02:49.683
that they can successfully connect to this copy of Postgres.

02:49.683 --> 02:51.360
So we do have to set up a little bit

02:51.360 --> 02:52.710
of environment variables,

02:52.710 --> 02:54.450
not only inside of this file

02:54.450 --> 02:57.750
but inside of the worker and server deployments as well.

02:57.750 --> 02:59.490
We're gonna take care of that in just second.

02:59.490 --> 03:02.040
But for right now, I wanna first put together

03:02.040 --> 03:04.082
the cluster IP service, and then we'll come back

03:04.082 --> 03:06.810
and talk about all these environment variables

03:06.810 --> 03:09.390
and this PVC thing and all that stuff.

03:09.390 --> 03:11.578
Essentially, I just wanted to get the boring parts

03:11.578 --> 03:13.500
out of the way here at the very start

03:13.500 --> 03:15.660
of these repetitive config files.

03:15.660 --> 03:17.640
And then go over to the more interesting stuff

03:17.640 --> 03:19.020
like the environment variables

03:19.020 --> 03:21.213
and the Postgres persistent volume claim.

03:22.800 --> 03:24.630
All right, so that's our deployment.

03:24.630 --> 03:27.270
We're going to also make inside of our K8s directory

03:27.270 --> 03:32.270
the Postgres cluster IP service .yaml file.

03:36.090 --> 03:37.920
And inside of here, completely identical

03:37.920 --> 03:39.360
to the Postgres one we just,

03:39.360 --> 03:41.850
or excuse me, the Redis one we just put together

03:41.850 --> 03:44.310
I'll do an API version of v1.

03:44.310 --> 03:45.993
We are making a service.

03:47.010 --> 03:51.753
It'll have a metadata name of Postgres cluster IP service

03:55.320 --> 03:59.760
and we'll give it a spec with the type of cluster IP.

03:59.760 --> 04:00.950
And then finally, to make sure that we're,

04:00.950 --> 04:02.700
or not finally, we have two other properties

04:02.700 --> 04:04.290
to do here, but one of the two is going to be

04:04.290 --> 04:06.690
this selector where we'll tell this thing

04:06.690 --> 04:08.670
what set of pods it's going to look for

04:08.670 --> 04:12.360
and as usual, we'll give it component along with the name

04:12.360 --> 04:15.180
or the label that we had applied to it, which was Postgres

04:15.180 --> 04:17.417
as we can verify back inside of our template section

04:17.417 --> 04:19.533
over here inside the deployment.

04:20.790 --> 04:22.890
All right, so now the real last step,

04:22.890 --> 04:24.030
for real this time around,

04:24.030 --> 04:25.920
we're gonna set up our ports.

04:25.920 --> 04:27.260
We're gonna say the default port

04:27.260 --> 04:29.760
of 5 4 3 2 to connect to Redis.

04:29.760 --> 04:31.320
And we're not gonna do any type

04:31.320 --> 04:34.170
of remapping this time around as well.

04:34.170 --> 04:35.823
Up target port. There we go.

04:37.890 --> 04:39.690
All right, so that looks like it's just about it.

04:39.690 --> 04:42.510
Now let's take these two new configuration files

04:42.510 --> 04:45.300
and we're going to apply them to Cube CTL as well.

04:45.300 --> 04:47.640
And then we'll check out our different sets of pods

04:47.640 --> 04:49.519
and make sure that everything is running successfully

04:49.519 --> 04:50.970
before we start to come back

04:50.970 --> 04:54.570
and take care of the Postgres persistent volume claim thing

04:54.570 --> 04:57.150
and some environment variables as well.

04:57.150 --> 05:00.810
So at my terminal, still inside of my complex directory

05:00.810 --> 05:05.130
we'll do our Cube CTL apply, K8s.

05:05.130 --> 05:07.403
Now we should see that we have the Postgres IP service

05:07.403 --> 05:10.320
and the Postgres deployment as well.

05:10.320 --> 05:14.040
So just as before, we'll do our get pods.

05:14.040 --> 05:15.780
And now one of these names is really long

05:15.780 --> 05:18.783
so it wants to kind of wrap the levels with me.

05:20.400 --> 05:22.500
So I can see my Postgres deployment right here.

05:22.500 --> 05:24.870
The container is being created.

05:24.870 --> 05:28.470
I'll do get pods again, and I can now see that it is

05:28.470 --> 05:31.740
in fact up and running for the Postgres deployment.

05:31.740 --> 05:34.780
And I'll make sure that I do my get services as well

05:35.880 --> 05:39.180
and somewhere inside of here, Postgres cluster IP service.

05:39.180 --> 05:40.013
Very good.

05:40.013 --> 05:43.140
And I got pop port 5 4 3 2.

05:43.140 --> 05:45.870
All right, so I think that we are pretty much all set.

05:45.870 --> 05:48.420
So that's just about it on our very basic,

05:48.420 --> 05:50.010
very simplistic config files

05:50.010 --> 05:53.730
for all the different deployments and associated services.

05:53.730 --> 05:54.840
So let's take a pause right here.

05:54.840 --> 05:56.730
When we come back to the next section, we're gonna talk

05:56.730 --> 05:58.590
about some additional work that we need to do

05:58.590 --> 06:00.600
to make sure that the server can connect

06:00.600 --> 06:03.360
to Redis and Postgres, and to make sure

06:03.360 --> 06:06.570
that the worker can connect to Redis as well.

06:06.570 --> 06:08.040
And also let's not forget this

06:08.040 --> 06:10.230
little PVC thing down here.

06:10.230 --> 06:12.980
Okay so, quick pause and I'll see you in just a minute.
