WEBVTT 00:00.500 --> 00:06.510 In this demo, we're going to create a replica assets based on the pod definition file that we created 00:06.540 --> 00:06.930 earlier. 00:07.650 --> 00:11.040 So in the last demo, we created a pod using Yamal. 00:11.130 --> 00:16.710 So here what I've done is I've created a directory called Pods Under the Covenant is for Beginners Directory, 00:17.640 --> 00:18.840 which is my project directory. 00:18.870 --> 00:22.590 And here are the two files that we created earlier for pods. 00:23.190 --> 00:27.240 So now let us create a new directory for public assets called Replica Sets. 00:27.360 --> 00:31.950 And inside this directory, let's create a new file called Replicas at Yamal. 00:33.250 --> 00:35.350 So let's start with the EPA version. 00:35.500 --> 00:41.440 And if you remember from the lecture, the vision for a concept should be APS slashed me one. 00:42.160 --> 00:46.330 And next, we'll use Kindt and we'll use these positions available. 00:46.450 --> 00:49.270 And here we are going to make use of public assets. 00:50.230 --> 00:56.050 The next route element is the same as that of Pardes, or we are going to add metadata in the name of 00:56.050 --> 01:03.520 the replica set, which would be my dash and my app dash of the cassette and will assign a label for 01:03.520 --> 01:04.630 our app, like I said as well. 01:05.200 --> 01:07.690 So the key would be app and the value will be my app. 01:08.650 --> 01:14.380 Now I'm going to set the last the last property, which is the spec. 01:15.040 --> 01:22.780 And as you can see for replicas at the Visual Studio code, the extension, the amole extension is automatically. 01:24.130 --> 01:28.900 Understood that the object is public asset and that it needs a selector. 01:28.930 --> 01:31.810 So it has already created The Selecter field for us. 01:32.470 --> 01:34.030 And so we'll just have to fill it in. 01:34.090 --> 01:35.470 So here we are. 01:35.470 --> 01:37.090 And we have two possible options. 01:37.150 --> 01:40.180 It can be a match expression's or match label. 01:40.240 --> 01:42.280 So let's use the match label option. 01:42.730 --> 01:49.350 And here we're going to use the same label that we used for the part that will tie the part to the replicas. 01:50.200 --> 01:52.860 So let us use the same label that we used before. 01:52.870 --> 01:53.770 Well, creating parts. 01:53.950 --> 01:59.830 So for this, let me first open the the engine export definition file on the right side of the screen 01:59.860 --> 02:02.530 so you can just direct click and open it on the right side. 02:03.310 --> 02:08.920 The labels we use there where the EMV label, which is set to production. 02:09.070 --> 02:10.810 So I'm just going to copy that over. 02:11.810 --> 02:13.970 Now, the next property is replicas. 02:14.060 --> 02:17.780 So for this example, let's make use of three replicas. 02:18.230 --> 02:22.860 And then the next mandatory value that we need to add here is the template. 02:23.030 --> 02:30.580 So for template, we can make use of the part definition file that we created earlier and copy the template. 02:30.590 --> 02:37.310 So I'm just going to copy this whole section here from Metadata and pasted under the template section. 02:38.210 --> 02:46.400 So now as soon as we paste the contents, we see that the the indentation is all out of order. 02:46.760 --> 02:52.580 So in order to fix this, one easy way to do it is to select the the whole section that we just pasted 02:52.670 --> 03:05.810 except for the first line and then press tab twice and then or until, you know, it fixes the the the 03:05.840 --> 03:06.440 indentation. 03:06.650 --> 03:06.890 Right. 03:07.520 --> 03:13.130 Now, some editors are intelligent enough to automatically correct that for you. 03:13.690 --> 03:13.870 Right. 03:13.910 --> 03:15.860 However, this this one doesn't. 03:16.730 --> 03:20.300 But I know that there is an extension available for this. 03:20.560 --> 03:22.010 And so if you're interested in that. 03:22.490 --> 03:23.060 Check it out. 03:23.510 --> 03:26.000 I think it's called paste and then. 03:26.180 --> 03:27.290 Or something like that. 03:28.260 --> 03:28.450 OK. 03:28.550 --> 03:31.130 So for now, we will just stick to the man who we are fixing it. 03:32.510 --> 03:37.190 So now the format is corrected and there are no more errors in the file. 03:37.700 --> 03:42.290 So one thing to note here is the labels used for the part and the labels used under these selecter at 03:42.310 --> 03:42.770 the top. 03:42.800 --> 03:44.030 So they have to be the same. 03:44.240 --> 03:44.480 Right. 03:44.990 --> 03:47.600 The label used at the top of the replicas. 03:47.660 --> 03:49.820 That itself doesn't really matter. 03:50.260 --> 03:50.540 The. 03:50.950 --> 03:55.130 It is the the two labels that are set on the part. 03:55.190 --> 03:57.410 And then one set on the selector that matters. 03:57.440 --> 03:59.480 That's what ties them together. 03:59.960 --> 04:01.560 So they have to be the same. 04:01.580 --> 04:07.040 So say we changed the labels on the part template to something else like app and set it to my AB. 04:07.400 --> 04:10.640 Then we must change it at the top as well to use the same. 04:11.150 --> 04:11.330 Right. 04:11.900 --> 04:14.600 So now we're done with the file. 04:15.300 --> 04:15.480 OK. 04:15.560 --> 04:21.080 So now that we have the European as a definition file ready, let's go back to the terminal. 04:21.230 --> 04:25.580 And here in the Project Root directory, we see that we have the new directory called replica sets. 04:26.090 --> 04:30.410 And underneath that there is the replicas at Yamal definition file that we just created. 04:30.890 --> 04:35.340 So let's quickly check to make sure that the file has the contents we created. 04:35.360 --> 04:39.860 So I'm just going to use Cat to view the contents of the file. 04:40.300 --> 04:41.690 As everything as expected. 04:42.920 --> 04:48.680 So now let me clear the screen and we're going to create this replica set using the cube to create command 04:48.800 --> 04:50.090 with the dash F option. 04:51.390 --> 04:58.290 So as soon as the replica set is created, let's check the status using Google gets replicas at command. 04:58.830 --> 05:03.010 And we notice that there is one replica set which is created already. 05:03.510 --> 05:06.510 That is a number of replicas is equal to three. 05:06.570 --> 05:09.750 And the current and ready number of vehicles are three as well. 05:10.200 --> 05:12.510 And it was created about eight seconds ago. 05:13.230 --> 05:18.310 So we can further inspect the status of the parts by running the cube car to get parts command. 05:18.540 --> 05:24.180 And we notice here that we have three replicas or three parts for the replica that we created. 05:24.990 --> 05:27.180 And all of the parts have a unique name. 05:27.600 --> 05:33.290 But you will notice that the name of the pod begins with the name of the replica set, which is my app, 05:33.300 --> 05:34.110 Dash Replicas. 05:35.100 --> 05:41.520 So that way you can look at the pod any part and you can identify that if it is a standalone part or 05:41.520 --> 05:43.140 a part that is part of a replica, is it? 05:44.140 --> 05:46.660 Now, all of them are in a running state. 05:47.620 --> 05:54.460 So we said that a replica set ensures that a sufficient number of replicas or pods are available at 05:54.880 --> 05:55.660 all times. 05:56.560 --> 06:00.340 Now, let's see what happens if we were to delete one of these parts. 06:00.790 --> 06:03.730 So let's go back and copy one of the port names. 06:04.230 --> 06:10.650 So in this case, I'm copying this one here that has a name that ends with eight an X X L. 06:11.080 --> 06:17.170 So I'm going to use the cue card to delete our part command and I'm going to paste the part name here. 06:17.920 --> 06:23.080 Now, whenever you delete a pod, it takes a few seconds for the pod to fully terminate. 06:23.260 --> 06:27.820 So just give it a few seconds for the fourth part to how fully terminate. 06:28.690 --> 06:32.680 So once we get the prompt back, let's check the status of the parts again. 06:33.480 --> 06:37.390 But you'll notice that the replica set still has three parts running. 06:37.690 --> 06:40.250 And you'll notice that one of the pod. 06:40.900 --> 06:43.630 Was just created fifteen seconds ago. 06:44.230 --> 06:46.450 And you'll notice that the name of the older pod. 06:46.970 --> 06:50.680 And that ended with the eight n x exhale has been deleted. 06:50.710 --> 06:55.660 And a new pod with the name with a different name has been created. 06:56.230 --> 07:02.020 So that's the, uh, the replica set, ensuring that sufficient number of parts are always available 07:02.020 --> 07:02.740 on the cluster. 07:03.520 --> 07:08.210 Now, if you're on the cubicle, describe a replica replicas, a command for the new replica set. 07:09.160 --> 07:13.300 We will see that the desired number of replicas in history. 07:13.330 --> 07:16.040 And here we see more information about the replica set. 07:16.120 --> 07:21.160 Just like what we saw with the Cube Cuttle describe part command. 07:22.240 --> 07:28.170 So here we see the name of the replica set, these electors, the label for the replicas itself. 07:28.720 --> 07:33.850 If you scroll down, you'll see the labels that the selector about makes use of, which is the labels 07:33.850 --> 07:34.510 on the pod. 07:34.960 --> 07:37.770 And we also see the engine X container definition. 07:38.490 --> 07:41.470 And if you scroll down below, we see the events. 07:41.500 --> 07:46.570 So initially when we created the replica set, it actually came up with three replicas. 07:47.080 --> 07:52.780 But then we deleted one of the replicas and then it spun up one additional replica for it to maintain 07:52.780 --> 07:53.410 that design. 07:53.470 --> 07:53.850 No. 07:54.340 --> 07:54.490 Right. 07:54.520 --> 07:57.580 And you see all of that in the history of events here. 07:58.030 --> 08:05.470 So this is a handy tool and command if you'd like to inspect what happened to a replica set. 08:05.600 --> 08:11.950 In case you're troubleshooting something or you're just looking for more information on what's happening 08:11.950 --> 08:14.230 with the replica set, etc.. 08:14.290 --> 08:23.140 So so we said that a replica is it ensures that a minimum number of replicas are available all the time. 08:23.710 --> 08:27.670 But what if there are more number of replicas than what's required? 08:28.180 --> 08:30.670 So let's try to let's try something else. 08:31.150 --> 08:37.450 Let's try to create a new pod by making use of the the same label that the replica set selector uses, 08:38.260 --> 08:41.090 which is the app set to my app. 08:41.710 --> 08:44.230 And to do this, let's go back to our pod definition file. 08:44.320 --> 08:48.970 And so here I have the Internet start YAML file that we created. 08:49.000 --> 08:54.910 And I will notice that we have a pod template which tries to create a pod by the name and the next dash 08:54.910 --> 08:55.300 to. 08:56.080 --> 08:56.840 We also. 08:57.400 --> 09:03.680 But we have now changed its label to the same label as the pod definition template used in our replicas. 09:04.690 --> 09:11.650 So now let's create the pod directly and not to the replicas it, but just, you know, directly the 09:11.650 --> 09:13.840 pod like as we have done before. 09:14.370 --> 09:21.790 And we'll see what happens when we create a new pod outside of the replica set, but one that has the 09:21.790 --> 09:25.490 same labels that the replica set selector uses. 09:26.930 --> 09:33.620 So before doing that, let me run the cubicle, get parts command, and I see that there is only the 09:33.650 --> 09:36.470 three parts that were created by the replicas it. 09:36.740 --> 09:43.340 And so now I'm going to use the cube, Carol, create command and with the dash F option and specify 09:43.340 --> 09:49.430 the engine start M0 file and you will see that the engine X dash two parred has been created. 09:50.420 --> 09:57.380 But if I run the cube to get parts command now, we'll see that the status of that part is in a terminating 09:57.380 --> 09:58.400 state already. 09:59.000 --> 10:01.130 And the replica set is terminating. 10:01.130 --> 10:07.220 The new part that we just created is not allowing more pods with the same labels than the number of 10:07.220 --> 10:08.870 replicas configured on the replicas. 10:09.950 --> 10:15.710 So if we run the Cube Cuttle describe command now, we'll see that at the bottom. 10:15.980 --> 10:22.730 Under the event section of the output of described command, the replicas of the controller delete the 10:22.730 --> 10:25.760 new and the next dash to pod that we just created. 10:26.330 --> 10:32.960 So now if I go back and run the cupola, get pods command and see that it is under terminating state 10:32.990 --> 10:36.440 and soon it should go away from it from the list altogether. 10:40.530 --> 10:44.780 OK, so now let's see how to update epilepticus it. 10:45.230 --> 10:51.140 So what what if we want to change the number of replicas to, say, four instead of the current three? 10:51.500 --> 10:54.920 Say, for instance, we are trying to scale up our application. 10:55.730 --> 11:02.150 So for this, we must edit the replica set definition file and update its replicas count to four. 11:03.140 --> 11:09.770 For this, we will make use of a new command call to cuddle, edit replica set and will provide the 11:09.770 --> 11:13.450 name of the replica set, which is my app that a replica set. 11:14.120 --> 11:20.540 And now when we run this command, we see that it opens up the running configuration of the replica 11:20.540 --> 11:23.270 set in a text editor in a text format. 11:24.170 --> 11:25.760 In this case, it opens up in Vim. 11:26.420 --> 11:33.320 So note that this is not the actual file that we used that we created at the beginning of this demo. 11:33.800 --> 11:41.120 This is a temporary file that that's created by cabernets in memory to allow us to edit the configuration 11:41.120 --> 11:43.210 of an existing object on CORONETS. 11:43.820 --> 11:50.600 And that's why you'll see a lot of additional fields in this file other than the details that you provided. 11:51.380 --> 11:57.140 So changes made to this file are directly applied on the running configuration on the cluster. 11:57.230 --> 11:58.760 As soon as the file is saved. 11:59.280 --> 12:03.650 So you must be very careful with the changes that you're making here. 12:04.520 --> 12:11.450 So now if I scroll down all the way to the specked section, which is over here, and we can see the 12:11.630 --> 12:17.150 running configuration and the current number of replicas, which is set to three, I can change this 12:17.210 --> 12:19.040 to scale it up by another part. 12:19.070 --> 12:25.040 So four in this case, then I will save an exit from the editor. 12:25.520 --> 12:31.130 Now, it should now spin up a new part in addition to the three that you already had to match, the 12:31.130 --> 12:33.550 new number of replicas that we specified. 12:34.590 --> 12:36.890 So if you're on the cubicle, get particle man. 12:37.050 --> 12:43.500 Now we see that there is a new pod now which has spun up six seconds ago and we can use the same approach 12:43.530 --> 12:44.770 to scale down as well. 12:46.070 --> 12:52.880 And there's also a command available to scale the number of replicas without having to go in and edit 12:53.630 --> 12:54.640 the definition file. 12:55.190 --> 12:58.910 And that is using the cube Carol scale replica set command. 12:59.600 --> 13:06.140 So we will provide the name of the replica set and we will set the number of replicas for it to scale 13:06.530 --> 13:07.100 to two. 13:07.580 --> 13:11.480 So you can specify a number which is greater or less than the current number of replicas. 13:12.230 --> 13:16.550 And note taking note of the double dashes before the replicas option. 13:17.240 --> 13:20.190 So if I run the you've got to get parts command. 13:20.240 --> 13:27.110 Again, we will see that the replica set is now scaling down to two replicas by terminating two of the 13:27.110 --> 13:27.590 parts. 13:29.140 --> 13:33.160 Well, so let's wait for these two replicas to be terminated. 13:35.040 --> 13:35.960 And there you go. 13:36.470 --> 13:38.150 And now we just have two parts. 13:38.780 --> 13:40.610 Well, that's it for this demo. 13:41.090 --> 13:42.800 I will see you in the next.