Unless sexually made a very small change to our pod configuration file a container port.
But when we did so we very quickly saw an error message that said that we were not allowed to update
certain fields that are tied to a pod.
So essentially that message is telling us that there are some fields so we are allowed to update such
as the image that a pod uses.
But there are other fields so we are not allowed to touch at all.
Once the pod has been created and so this kind of flies in the face of everything I just told you about
making changes to the configuration file.
In other words how are we going to change a configuration file to change an object inside of our cluster.
If there are fields that we are not at all allowed to update or touch well to solve this issue we're
going to start making use of a new type of object that is going to replace our usage of pod inside of
our very simple application as it stands right now.
So the new type of object that we're going to make use of in addition to pods and services is something
called a deployment deployment is a Nettie's object that is meant to maintain a set of identical pods
so that can be one part two part three pod whatever number and the deployment is going to constantly
work to make sure that every single pod in its set that it's supposed to manage is always running that
can correct configuration and is always in a runnable state.
In other words it is not crashing or it's not dead or anything like that.
Now a deployment is very similar in nature to a pod.
Yes I just said a deployment contains a set or maintains a set of pods.
But at the end of the day we can use either deployments or pods with Kuber Nettie's to run containers
for our application.
So let's compare and contrast the differences between pods and deployments.
So with the pod we're running a single set of very closely related containers remember in a pod.
We're only going to stick in multiple multiple containers if they have very tight integration with each
other.
In reality pods are only used in a development environment and usually only if you have like a very
one off single container or a very small group of containers you want to run.
We do not actually make use of pods directly in a production environment because of all these limitations
around being able to update its configuration and stuff like that.
Now a deployment on the other hand again is meant to set or is meant to run and manage a set of identical
ports.
So that is one or more likely one pod to pod three pod however many you want in that set of pods.
Every part is going to be running the exact same set of containers with identical configuration now
the deployment itself is going to monitor the state of each pod.
It's going to watch the configuration of each one it's going to make sure that every pod is running
the containers successfully inside of it.
If any pod happens to crash for any reason the deployment is going to automatically attempt to restart
that pod or completely recreate it in a fresh new state.
We make use of deployments in a development environment and we use them as the primary means of running
containers in a production environment as well.
So in this course I first started off showing you pods just so you understand.
Here is a very basic way of creating a container with Kubert Nettie's.
But in reality when we start making use of communities for any serious purpose we make use of deployments
as opposed to individual pots.
So from here on forward we're going to kind of tend to forget that pods exist and we're going to instead
make use of deployments for running all of our different containers again behind the scenes a deployment
is just making use of pods so it's still very important to understand what a pod is and how you work
with one.
But again we're going to make use of deployments in our development and production environments.
Now I want to show you is just a very quick diagram here of what's going on behind the scenes.
So when we create a deployment object it's going to have attached to it something called a pod template
a pod template is essentially a little block of configuration file or see a little block configuration
that says hey here's what any pod that is created by this deployment is supposed to look like.
So the template might say OK every pod that this deployment manages is supposed to have one container
that has the name of client that exposes port three thousand and uses the image multi worker.
And so that deployment would use this template to create a pod that looks like this a pod that has a
name of client pod just simply client it's running the multi worker image and it exposes 43000 to the
outside world.
If we made a change to the template over here like let's say were instead supposed to expose port 3000
we changed that to 9 9 9 like so then the deployment would attempt to either change the existing pod
that it's managing or alternatively it would attempt to kill this part entirely and replace it with
a brand new pod that has the correct port assigned to it like so.
So again this deployment object over here is going to be constantly watching all of the different pods
that it maintains it's going to be watching their state and making sure that they have the correct state.
So at the end of the day to solve this issue that we're having right now with updating the configuration
for our pod rather than trying to make use of a POD and update the container port we're going to instead
refactor this thing to instead be a deployment that creates a pod running the multi worker image and
with a very specific container port.
Once you make use of the deployment all those restrictions around updating certain variables like say
the container port right here or the name of the container will be lifted with a deployment.
We can change any piece of configuration tied to a pod that we want to.
We don't have to worry about seeing that error message like we did previously.
OK so let's take a quick pause right here.
We're going to come back in the next section.
We're going to start to Reflektor our client pod file or just completely recreate it for that matter.
And we're going to turn it into a deployment object type instead.
So I'll see you in just a minute.