Basics on Kubernetes: What exactly is a deployment?

In this article on basics of Kubernetes, we will talk about what is deployment and its uses. If you have missed the previous article you can find them on this series on basics on Kubernetes.

What is deployment in Kubernetes?

In Kubernetes, with help of deployment, you can easily control the rollout and updates of the application. Deployment is nothing but running a replica of pods. It can be done using native Kubernetes objects which is of kind deployment. In short deployment creates a set of identical pods for you and control them for you. You can update them using the deployments.

How pods are controlled by deployment?

When you create a deployment in Kubernetes, a replicaset is created. This replicaset is responsible for keeping the number of replicas of any pod fixed. If a pod goes does, replicaset controller will bring a new pod up to maintain the replica count. Deployment creates replicaset and replicaset creates the pods. You can read more about replicaset below

What happens when a deployment is updated?

There can be two types of updates, one is changing deployment object params which don't affect replicaset. In this scenario, there will be nothing happening on replicaset and on the pods.

Basics on Kubernetes: What is deployment?Basics on Kubernetes: What is deployment?

The other case is where a pod spec can be changed in this scenario, a new replicaset will be created. Deployment controller can decrease the pod of existing replicaset one by one and increase the replica count of new replicaset. In this way,` a new deployment is rolled out.

Let’s look at a simple deployment Kubernetes YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

If you look at the above there is a replica count and spec. With these specs and replica count, a new replicaset is created which takes care of the replicas.

This was very basic of what is deployment in Kubernetes. In the next article, we will talk about statefulsets.

If you like the article please share and subscribe. I am a learner if there is any mistake in the article please let me know I will fix it asap. 🙂


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Are you preparing for DevOps and SRE Interview?

Here is a book for you.


Interview preparation and interview questions for DevOps and SRE






A good reads for last-minute preparations for handling DevOps and SRE interviews at companies like LinkedIn, Visa, Atlassian, etc.