Hi, Let us understand about deployments. Earlier we discussed about replica sets
which is going to have a collection of pods and it's going to maintain the
desired capacity. Sometimes there may be a need to change the replica set and
replace the replica set with a different version. Let's take an example I do have
version one of application running with desired capacity as 3 and I'm going to
get a different version of application or the next version of the application
and I want that to get deploy. There are two ways of deploying, one: I can start 3
such containers and replace all the requests coming to the old version
to the newer version or I can go in a staggered way or in a controlled rate I can switch the traffic. So whenever
I wanted to make change to the replica set in a controlled rate and in a controlled
way I can go ahead and use the deployments. So deployment is nothing
but it's a declarative way of controlling the pods or internally the replica sets
and making sure the availability of the replica set is changed in a controlled rate
and this can be used for different type of use cases like rolling the new version of
replica sets or replacing the applications with a different version and facing out
any version of the applications or pausing the entire application for some
reason as well as to scale up or scale down the load on any replica set
Basically I'm going to control the pod or replica set in a declarative way and that's
where the deployments will be used. As we discussed earlier directly we will not
be controlling the replica set in production we will be using the
deployments or the auto scaling. Let's go ahead and create a sample deployment
As a part of kubernetes website I do have the github user content over here.
I'm going to use the web link directly and use kubectl apply and see how it's going
to work. Here I do have the api version and kind as deployment within spec I do
have replica as 3 and selector I am using the app as nginx, so this is what the label
will be used to do the selection and the new pod will get created using this
specific template and it will be using this specific label and it will be using the
container with the name nginx and image as this specific image and port 80 will
get exposed. Let me go ahead and apply this particular file, so automatically the
file will get referred and the deployment will get created. Let me go ahead and
get the deployments so I do have a deployment where zero objects are ready
and the desired capacity needs to be 3. I can go ahead and do the description of
this specific deployment, I can get the deployment details using the describe
command and get the information. So here I do have the details about the name
in which namespace it got created what are all the annotations that is
the api version and what is the selector, this is the important label it's going to
use to select the pods and whether it is part of this specific deployment or not
and 3 desired capacity, yes I do have 3 number of pods available and as a part
of blue-green deployment as well as the deployment strategy we will be
discussing about the rolling update and what these specific values are, this is
just a quick introduction on various concepts and objects available as a part
of kubernetes. Now let me go ahead and get the replica set available as a part of
this specific deployment, so I can get the replica set so this is what the replica set
name I am going to get, let me give the command get rs, so this is the replica set
available as a part of the deployment. If I get into the description of the
deployment here I will be having the new deployment that is active and there is no
old deployments available. In case if I wanted to roll it to a new version I will be
getting the new replica set name over here and their status and within the
replica set I should have n number of pods I can go ahead and get the pods as
well, let me use the command kubectl get pods so these are all the pods
available as a part of the specific deployment and I can get the pods with a
label. So all the pods should have that specific label app is equal to nginx. So
this is what the app selector that's going to use to make it as a part of the
deployment or the replica set. So what's going to happen it's going to use the
replica set internally and make use of the desired capacity and the collection of
pods how to use the label selector and get the n number of pods up and running
The most of the use cases we will be using is the controlled way of deploying
or making changes to the replica set or to the auto scaling we will be using the
deployments. We can go ahead and scale up the deployments as well as
scale down the deployments and make changes to the deployments at runtime
all those we will be discussing it as a part of advanced discussion of
deployments. So in a quick summary we have seen what is a deployment and how
it is going to use replica sets and pods, label selector as a part
of the deployment internally and in what use cases and how
it will be used within the kubernetes.