In this demo, we're going to create a replica assets based on the pod definition file that we created
earlier.
So in the last demo, we created a pod using Yamal.
So here what I've done is I've created a directory called Pods Under the Covenant is for Beginners Directory,
which is my project directory.
And here are the two files that we created earlier for pods.
So now let us create a new directory for public assets called Replica Sets.
And inside this directory, let's create a new file called Replicas at Yamal.
So let's start with the EPA version.
And if you remember from the lecture, the vision for a concept should be APS slashed me one.
And next, we'll use Kindt and we'll use these positions available.
And here we are going to make use of public assets.
The next route element is the same as that of Pardes, or we are going to add metadata in the name of
the replica set, which would be my dash and my app dash of the cassette and will assign a label for
our app, like I said as well.
So the key would be app and the value will be my app.
Now I'm going to set the last the last property, which is the spec.
And as you can see for replicas at the Visual Studio code, the extension, the amole extension is automatically.
Understood that the object is public asset and that it needs a selector.
So it has already created The Selecter field for us.
And so we'll just have to fill it in.
So here we are.
And we have two possible options.
It can be a match expression's or match label.
So let's use the match label option.
And here we're going to use the same label that we used for the part that will tie the part to the replicas.
So let us use the same label that we used before.
Well, creating parts.
So for this, let me first open the the engine export definition file on the right side of the screen
so you can just direct click and open it on the right side.
The labels we use there where the EMV label, which is set to production.
So I'm just going to copy that over.
Now, the next property is replicas.
So for this example, let's make use of three replicas.
And then the next mandatory value that we need to add here is the template.
So for template, we can make use of the part definition file that we created earlier and copy the template.
So I'm just going to copy this whole section here from Metadata and pasted under the template section.
So now as soon as we paste the contents, we see that the the indentation is all out of order.
So in order to fix this, one easy way to do it is to select the the whole section that we just pasted
except for the first line and then press tab twice and then or until, you know, it fixes the the the
indentation.
Right.
Now, some editors are intelligent enough to automatically correct that for you.
Right.
However, this this one doesn't.
But I know that there is an extension available for this.
And so if you're interested in that.
Check it out.
I think it's called paste and then.
Or something like that.
OK.
So for now, we will just stick to the man who we are fixing it.
So now the format is corrected and there are no more errors in the file.
So one thing to note here is the labels used for the part and the labels used under these selecter at
the top.
So they have to be the same.
Right.
The label used at the top of the replicas.
That itself doesn't really matter.
The.
It is the the two labels that are set on the part.
And then one set on the selector that matters.
That's what ties them together.
So they have to be the same.
So say we changed the labels on the part template to something else like app and set it to my AB.
Then we must change it at the top as well to use the same.
Right.
So now we're done with the file.
OK.
So now that we have the European as a definition file ready, let's go back to the terminal.
And here in the Project Root directory, we see that we have the new directory called replica sets.
And underneath that there is the replicas at Yamal definition file that we just created.
So let's quickly check to make sure that the file has the contents we created.
So I'm just going to use Cat to view the contents of the file.
As everything as expected.
So now let me clear the screen and we're going to create this replica set using the cube to create command
with the dash F option.
So as soon as the replica set is created, let's check the status using Google gets replicas at command.
And we notice that there is one replica set which is created already.
That is a number of replicas is equal to three.
And the current and ready number of vehicles are three as well.
And it was created about eight seconds ago.
So we can further inspect the status of the parts by running the cube car to get parts command.
And we notice here that we have three replicas or three parts for the replica that we created.
And all of the parts have a unique name.
But you will notice that the name of the pod begins with the name of the replica set, which is my app,
Dash Replicas.
So that way you can look at the pod any part and you can identify that if it is a standalone part or
a part that is part of a replica, is it?
Now, all of them are in a running state.
So we said that a replica set ensures that a sufficient number of replicas or pods are available at
all times.
Now, let's see what happens if we were to delete one of these parts.
So let's go back and copy one of the port names.
So in this case, I'm copying this one here that has a name that ends with eight an X X L.
So I'm going to use the cue card to delete our part command and I'm going to paste the part name here.
Now, whenever you delete a pod, it takes a few seconds for the pod to fully terminate.
So just give it a few seconds for the fourth part to how fully terminate.
So once we get the prompt back, let's check the status of the parts again.
But you'll notice that the replica set still has three parts running.
And you'll notice that one of the pod.
Was just created fifteen seconds ago.
And you'll notice that the name of the older pod.
And that ended with the eight n x exhale has been deleted.
And a new pod with the name with a different name has been created.
So that's the, uh, the replica set, ensuring that sufficient number of parts are always available
on the cluster.
Now, if you're on the cubicle, describe a replica replicas, a command for the new replica set.
We will see that the desired number of replicas in history.
And here we see more information about the replica set.
Just like what we saw with the Cube Cuttle describe part command.
So here we see the name of the replica set, these electors, the label for the replicas itself.
If you scroll down, you'll see the labels that the selector about makes use of, which is the labels
on the pod.
And we also see the engine X container definition.
And if you scroll down below, we see the events.
So initially when we created the replica set, it actually came up with three replicas.
But then we deleted one of the replicas and then it spun up one additional replica for it to maintain
that design.
No.
Right.
And you see all of that in the history of events here.
So this is a handy tool and command if you'd like to inspect what happened to a replica set.
In case you're troubleshooting something or you're just looking for more information on what's happening
with the replica set, etc..
So so we said that a replica is it ensures that a minimum number of replicas are available all the time.
But what if there are more number of replicas than what's required?
So let's try to let's try something else.
Let's try to create a new pod by making use of the the same label that the replica set selector uses,
which is the app set to my app.
And to do this, let's go back to our pod definition file.
And so here I have the Internet start YAML file that we created.
And I will notice that we have a pod template which tries to create a pod by the name and the next dash
to.
We also.
But we have now changed its label to the same label as the pod definition template used in our replicas.
So now let's create the pod directly and not to the replicas it, but just, you know, directly the
pod like as we have done before.
And we'll see what happens when we create a new pod outside of the replica set, but one that has the
same labels that the replica set selector uses.
So before doing that, let me run the cubicle, get parts command, and I see that there is only the
three parts that were created by the replicas it.
And so now I'm going to use the cube, Carol, create command and with the dash F option and specify
the engine start M0 file and you will see that the engine X dash two parred has been created.
But if I run the cube to get parts command now, we'll see that the status of that part is in a terminating
state already.
And the replica set is terminating.
The new part that we just created is not allowing more pods with the same labels than the number of
replicas configured on the replicas.
So if we run the Cube Cuttle describe command now, we'll see that at the bottom.
Under the event section of the output of described command, the replicas of the controller delete the
new and the next dash to pod that we just created.
So now if I go back and run the cupola, get pods command and see that it is under terminating state
and soon it should go away from it from the list altogether.
OK, so now let's see how to update epilepticus it.
So what what if we want to change the number of replicas to, say, four instead of the current three?
Say, for instance, we are trying to scale up our application.
So for this, we must edit the replica set definition file and update its replicas count to four.
For this, we will make use of a new command call to cuddle, edit replica set and will provide the
name of the replica set, which is my app that a replica set.
And now when we run this command, we see that it opens up the running configuration of the replica
set in a text editor in a text format.
In this case, it opens up in Vim.
So note that this is not the actual file that we used that we created at the beginning of this demo.
This is a temporary file that that's created by cabernets in memory to allow us to edit the configuration
of an existing object on CORONETS.
And that's why you'll see a lot of additional fields in this file other than the details that you provided.
So changes made to this file are directly applied on the running configuration on the cluster.
As soon as the file is saved.
So you must be very careful with the changes that you're making here.
So now if I scroll down all the way to the specked section, which is over here, and we can see the
running configuration and the current number of replicas, which is set to three, I can change this
to scale it up by another part.
So four in this case, then I will save an exit from the editor.
Now, it should now spin up a new part in addition to the three that you already had to match, the
new number of replicas that we specified.
So if you're on the cubicle, get particle man.
Now we see that there is a new pod now which has spun up six seconds ago and we can use the same approach
to scale down as well.
And there's also a command available to scale the number of replicas without having to go in and edit
the definition file.
And that is using the cube Carol scale replica set command.
So we will provide the name of the replica set and we will set the number of replicas for it to scale
to two.
So you can specify a number which is greater or less than the current number of replicas.
And note taking note of the double dashes before the replicas option.
So if I run the you've got to get parts command.
Again, we will see that the replica set is now scaling down to two replicas by terminating two of the
parts.
Well, so let's wait for these two replicas to be terminated.
And there you go.
And now we just have two parts.
Well, that's it for this demo.
I will see you in the next.