What is Deployment in Kubernetes?

Reading Time: 4 minutes

Deployment in kubernetes is an upgraded and higher version of Replication controller. They manage the deployment of a replica set which is also an upgraded version of the replication controller.

  • Deployment in kubernetes allows you to describe an application life cycle, such as which images to use for the app, the number of pods, and the way in which they should be updated.
  • In kubernetes, Deployment have the capability to update the replica set and are also capable of rolling back to the previous version. They provide many updated features of match labels and selectors.
  • What we do is we describe a desired state in a deployment and we have a controller called deployment controller which makes it happen. Deployment controller changes the actual state to the desired state.
  • Deployments are declarative, which means that they have what to achieve not how to achieve. To achieve this desired state, deployment uses Replica Sets, which further maintains the required set of pods.

UseCases of Deployment:

1.Create a Deployment

In kubernetes, when a deployment is created, a replica set automatically creates pods in the background.

Firstly lets create a yaml file for deployment:

In this example:

  • A Deployment named nginx-deployment is created, indicated by the .metadata.name field.
  • The Deployment creates three replicated Pods, indicated by the .spec.replicas field.
  • The .spec.selector field defines how the Deployment finds which Pods to manage.In this case, you select a label that is defined in the Pod template (app: nginx).

Before you begin, make sure your Kubernetes cluster is up and running. Follow the steps given below to create the above Deployment:

  1. Create the Deployment by running the following command:

 2. If you want to apply configuration then run the following  command:

3. Use following command to check if the deployment has been created or not:

 4. Use following command to check if the replica set has been created or not:

2. Update a Deployment

When we update a deployment, a new replica set is created and the deployment manages moving the pods from the old replica set to the new one at a controlled rate.

Therefore, to update a deployment change some parameters for instance change the number of replicas and image version in your yaml. Change the configuration and apply the changes by the command:

3. Rollback a Deployment

In Deployment, we can rollback to any deployment version we want. 

Use the following command to rollback :

And for checking the history of rollout use this command and it will give you the number of revisions.

To get out to a particular revision use this command:

If we don’t mention revision number here, then it will rollback to the most recent deployment.

4. Scale a Deployment 

Each and every deployment can be scaled up or scaled down based on the requirements. We can also use autoscale in which we can give the limit of resources.

Therefore. To scale a deployment the command is:

Now, we have autoscaling through which we can choose the min and max no. of pods we want to run based on the cpu utilization. The command to autoscale is:

Therefore, here 5 is the minimum number of replicas always running and 9 is the maximum number of replicas running. Suppose if I scale my deployment to 10 replicas, it will automatically descale to 9 replicas and if I scale down to 2 replicas then it will automatically upscale to 5 replicas.

5. Pause a Deployment

We can also pause the deployment in kubernetes and make the changes or fix the bug, and then the deployment can be resumed. Therefore, to pause a deployment we have the command:

Now, if you want to update the image then use this command:

Therefore, you can make as many updates as you want and you can resume back to your deployment. Changes will only get applied if we resume back to the deployment.

Finally, for resuming a deployment the command is:


In this blog we came to know about Deployment . We got to know about when to use deployment, its various use cases and how it plays a very important role in describing an application life cycle.

Written by 

Naincy is currently a Software Intern at Knoldus. She is always ready to learn new technologies and tools. She loves painting and dancing.