In this video we're going to start to write out a config file for a deployment.
So let's get to it.
Back inside.
My code Ed I'm going to delete the post dot gamble file if you want to.
You can back up this file or just change the extension.
Something like that you want to make sure you don't have this file anymore.
So if you want to keep a backup I would encourage you to add on a like dot old or something like that
extension to the very end.
Going to delete that file because we don't want to create an individual pod anymore and then inside
my aids directory I'm gonna make a new file called Post dash devil dot yellow devil on there indicates
that this file is going to create a deployment.
So devil is just deployment for short.
That's all inside if you're ever gonna write out.
Once again some config to create a deployment inside this config we're going to say that we want to
run some number of pods that are going to run our post image.
So let's get to it a lot.
The code or configuration we're going to write inside of here is going to be very similar to the stuff
that we just wrote out for a pod.
Well first start off with an API version and in this case they're going to put an apps slash V1.
So remember there are certain buckets of different types of objects we have access to.
In this case the deployment is inside this bucket of different objects called Apps slash be one a pod
as you will recall was inside of just the one will then specify the kind of object that we're trying
to create.
It's a deployment will then set up some metadata.
And in this case we're just going to assign a name to it.
So let's say posts dash devil that is going to be the name of my deployment again I'm putting on the
dash depot here so that if I ever print out some logs or something like that about all the objects inside
my cluster I'll see double.
And know that this is a deployment after that I'll put in a spec section but this is going to specify
exactly how this deployment should behave the first property will designate inside of here is replicas
and I'm gonna give it a one for right now replicas is the number of pods we want to create running some
particular image so in this diagram over here I'm showing three separate pods.
Right now we're not going to run three separate pods we're going to run just one by itself.
Now the next a little piece of configuration here is going to be just a little bit mysterious.
So we'll write it out and then take it right out a little bit additional config after that and we'll
talk about how these two parts of config kind of work together.
So going to say selector then match labels and then app post remember that inside of a gamble file indentation
is a big deal.
So you need to make sure that you've got one level of indentation on selector then two and then three.
So again we'll talk about what this is in just a second.
First we're gonna write out another little bit of config I'm gonna say template then metadata labels
and then app notes all right.
So these two sections right here the selector thing and this metadata thing right here are really working
together.
This might sound really in it's funny it might sound like crazy but to be honest with you a deployment
kind of has a hard time figuring out which pods it should manage inside of our cluster.
In other words if a set of pods get created we have to somehow give the deployment some information
and tell it hey these pods over here.
These are the ones you need to manage and that's what the goal of this selector and metadata labels
app thing is all about the selector right here is saying take a look at all the different pods that
have been created by an all the pods with a label of app os.
So this right here is what I refer to as a label as essentially well a label.
It's a key value pair that is just applying some arbitrary information to a pod app right here doesn't
really have any special meaning.
We can set up labels with any structure you can imagine so we can have a label of like that right there.
So in this case we are telling the deployment that we wanted to find all the different pods with the
label of app hosts and those are the pods that it should be in charge of then inside this template section.
The template is where we specify the exact configuration of a pod that we want this deployment to create
so this right here is some configuration that is going to be applied to the pod that the deployment
is going to make.
We are saying that we want the pod to have a label of app posts.
So again this part right here and this part right here are really working together to tell the deployment
about which pods it should try to manage after that will then set up a spec this back again.
Everything inside this template thing right here can be really thought of as a pod spec or a pod config
file very similar to the pod config file we had just a moment ago to the spec section right here is
describing the specification or the configuration options where the pod that we're trying to make so
we will designate containers we're going to have one container so containers is an array remember and
inside of a gamble we designate an array entry with a single Dash.
We'll say that the container should have a name of post and it should run the image of your dock or
I.D. so not mine whatever your Docker I.D. is flash posts and then version 0 0 1.
Like so and that's it.
That is our deployment config.
Now over time you're going to see that there are many other options or pieces of configuration we can
specify in here.
This is about as barebones a configuration as we can get when we are creating a deployment let's save
this.
And then finally we're going to go back over to our terminal and we're going to try to apply this to
our cluster.
Remember anytime we want to make a change or a cluster recreate those config files then we will run
that cube GTL apply command that we saw that we used just a moment ago to create a pod.
So to apply this config file we will run cube Seitel apply dash F and then post devil dot yellow and
that's it.
Now the deployment has been created but what does that really do for us.
Well let's take a quick pause right here.
We're gonna come back the next video and we'll see what creating the deployment really did to our cluster.