Working With Deployment In Kubernetes

What is Deployment in Kubernetes? How to maintain a rolling update of our application?

Nov 26, 2020 · 5 min read

Kubernetes Deployment(controller) is your buddy if you want to deploy, update , maintain your hosted application on the production server without any downtime with utmost efficiency and with the required scalability and availability

Many times while working on your production server, you may encounter an instance where you would like to push a new update of your web application, while doing so it is desired not to break the running web app and to avoid any downtime. You may be required to deploy many instances of your web application to manage user workloads and to ensure the application is always available for the user to access.

Kubernetes Deployment here is your true mate which helps you to seamlessly perform your application rolling update. It also helps you to scale the web app horizontally by helping you create multiple replicas of the web application.

So in the Kubernetes ecosystem,

A Deployment provides declarative updates for Pods and ReplicaSets without breaking the user side experience

You can effortlessly roll-out application updates and also rollback the update if anything breaks using the deployment object in Kubernetes.

Deployment act as a controller in Kubernetes which helps Kubernetes developers and administrator achieve the desired state for pods, replica sets in the manner decided by the controller.

One can create Deployments to create new ReplicaSets or to remove existing Deployments and adopt all their resources with new Deployments.

Defining Deployment:

Here we are making use of imperative command to create a deployment

named: test-deploy, with an docker image = nginx having 3 replicas, as using the Kubectl CLI as shown below:

kubectl create deployment test-deploy --image=nginx --replicas=3

When you run this command you will see the,


Fig: 1.0

As seen in Fig 1.0, our test-deploy deployment has been created successfully and is in a ready state. We have made use of :

kubectl get deployment


kubectl describe deployment test-deploy

To view the details of the deployment, we have created


We can create a deployment using a declarative way as shown below in our YAML file definition, here

  • kind is of type Deployment
  • apiVersion: apps/v1(These needs to be aways confirmed with Kubernetes API doc, as it may change in future Kubernetes API version updates. )

Here we are deploying the Pod using the pod definition under the template section as shown below:

Using the selector under the spec, as shown below

Here label is matched with the given pod label, if the label is not matched or missing our deployment will fail

Use the below command to,

fig 2.0

We can see from fig 2.0, that our deployment has been created successfully and is in a ready state.

When you inspect the Deployments in your cluster using the command

, the following fields are displayed:

You will see the following as output:

  • NAME lists the names of the Deployments in the namespace.
  • READY displays how many replicas of the application are available to your users. It follows the pattern ready/desired.
  • UP-TO-DATE displays the number of replicas that have been updated to achieve the desired state.
  • AVAILABLE displays how many replicas of the application are available to your users.
  • AGE displays the amount of time that the application has been running.

The number of desired replicas is 3 according to the below field on our YAML definition.

Updating the Deployment :

Now that we have successfully deployed our deployment : demo-deployment

let’s update the same with new nginx, image version, nginx:1.16.1.

One can do so by using the set image command, as shown below:

If it succeeds you will see the output as shown below, where demo-deployment is updated successfully

Fig 3.0

Let’s describe our deployment to get more details about our updated deployment

Fig 4.0

As can be seen in fig 4.0, we have updated the pod with the new image nginx:1.16.1, as a rolling update, with all the 3 desired replicas being created successfully.

One can also edit the deployment YAML file Alternatively, using the following edit command:

kubectl edit deployment.v1.apps/demo-deployment

and change the,.spec.template.spec.containers[0].image from nginx to nginx:1.16.1,

save the file in the vim editor and your deployment will be updated with new, nginx:1.16.1, image version.

What's Next?

We saw

  • What is the Deployment workload in Kubernetes?
  • How to create deployment?
  • How to edit and update the deployment?

Next, we will continue to learn more about deployment where we will cover

  • How to rollback the update using deployment?
  • How to check the rollback and rollout status?

and more ……

Thanks for being there and supporting…..


Learn System Designing | Architecting | DevOps| Microservices | Clean Coding | Data Science


We share our knowledge regarding scalable architectures, clean coding, DevOps, CI/CD to help you learn and grow fast


Written by

Everything About Artificial Intelligence | Machine Learning | Applied statistics| Data Science. Let’s learn AI & ML together


We share our knowledge regarding scalable architectures, clean coding, DevOps, CI/CD to help you learn and grow fast

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store