What is a Kubernetes deployment | Kubernetes deployment definition file

After checking pods, replica set, now discuss about Kubernetes deployment. What is Kubernetes deployment and what are there advantages and how we can create the definition file. We check all these things in this article.

What is a Kubernetes deployment?

As we discuss previously about the replica set it runs the multiple pods but here in deployment it run the multiple replica set same time. So that in case of any replica set got fail it then the other replica set will come and result in high HA. It will also help in automatic deploying, scaling and update of application.

You can better understand the Kubernetes deployment from the below images:

Kubernetes Deployment

From the image we can see that deployment contain the replica set and replica set contain pod and pod contain container.

Advantages of  Kubernetes deployment

  • Provide the HA to the application.
  • Provide the seamless upgrade
  • Enables automatic deploying, scaling and update of application

Types of upgrade

In this we have two type of upgrade and we use them as per our need and these types are mention below:

  • Recreate
  • Rolling update


So in this type of upgrade the all pod will shutdown and upgrade simultaneously. The main drawback of using such type of upgrade is that its need a complete downtime of the apps as all the pod will go down.

Rolling update

Its is a more modern type of upgrade that we use now a day in IT. In this type of upgrade what happen in a replica set one pod will go for a upgrade and when its come up then its peer will go for the upgrade and this how it will update the replica set. The major benefit of this type of upgrade is that it does not need a downtime and its the by default option for the upgrade. All the enterprise will opt this type of upgrade as there is no downtime.

Kubernetes deployment definition file

Now will see how we can create a deployment definition file in yaml.

apiVersion: apps/v1
kind: Deployment
  name : myapp-deployment
    app: nginx
    type: frontend
      name: nginx-2
        app: myapp
        - name: nginx
          image: nginx 
  replicas: 3
      app: myapp

So this is how we can create the definition file. Now lets understand this definition file in this file we are create a pod of nginx for that what we did we created a Deployment with the name myapp-deployment. In this we created 3 replicas.

So this is how we can create the definition file. You can try and test and create the different type of definition file and test them out.

Some important links

Leave a Reply

Your email address will not be published. Required fields are marked *