Kubernetes(k8s) - What are Deployments?
Deployments are a fundamental building block for managing containerized applications in a Kubernetes cluster. A Deployment is an API resource and a higher-level abstraction that provides a declarative way to manage and scale a set of identical pods. You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate.

Common scenarios where deployments are used include the following:
Create a Deployment to roll out a ReplicaSet — A Deployment manages a Replica Set, which, in turn, ensures that a specified number of pod replicas (instances) are running and healthy at all times. It allows you to scale your application by adjusting the desired number of replicas.
Declare the new state of the Pods — Deployments are configured using declarative YAML or JSON files, which specify the desired state of the application. Kubernetes continually works to ensure that the actual state of the application matches this desired state.
Scale up the Deployment to facilitate more load — You can easily scale the number of replicas up or down based on the desired workload. Deployments can automatically adjust the number of replicas to match the specified number
Rollback to an earlier Deployment revision — If a rolling update fails or results in issues, Kubernetes deployments provide automated rollback mechanisms to revert to the previous stable version of the application.
Creating Deployments in Kubernetes
A Kubernetes Deployment YAML file is a configuration file written in YAML (YAML Ain’t Markup Language) that defines the desired state of a Kubernetes Deployment. This YAML file is used to create, update, or delete Deployments in a Kubernetes cluster. It contains a set of key-value pairs that specify various attributes and settings for the Deployment, such as the number of replicas, pod template specifications, labels, and more.
Let’s take a look at an example YAML definition for a Kubernetes Deployments:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-rs
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
Let’s take a look at following fields:
selector — Specifies the labels that the Replica Set uses to select the pods it should manage.
replicas — Specifies the desired number of identical pod replicas to run.
template — Contains the pod template used for creating new pods, including container specifications, image names, and container ports.
apiVersion — Specifies the Kubernetes API version, such as "apps/v1" for Deployments.
kind — Specifies the type of Kubernetes resource, in this case, "Deployment."
spec — Defines the desired state of the Deployment, including the number of replicas, the pod template, and any other related specifications.
metadata — Provides metadata for the Deployment, including the name, labels, and annotations.
kubectl - deploy and interact with Deployments
kubectl, (kube-control, or as some people call it, kube-cuddle) is the Kubernetes command-line tool. It allows us to run commands against Kubernetes clusters.
With kubectl, we can create a Pod using our YAML definition file like so:
kubectl apply -f myyamlfile.yaml
We can list all of our Deployments like so:
kubectl get deployment
Summary and Conclusions
Kubernetes Deployments are vital to automate application lifecycle management to increase productivity and maintain high availability with load-balancing.
Author

Sagar Mehta is Atgen Software Solutions Founder and a recognised expert in the field of Intelligent Automation, including Robotic Process Automation, Workload Automation, DevOps, SRE and Advanced Analytics. Sagar advocates a pragmatic approach to Automation, encouraging a policy of using ‘the best tool for the job’.
Prior to co-founding Atgen Software Solutions, Sagar worked in Senior Automation roles, architecting and delivering robust, scalable solutions for many of the world’s biggest banks and working with leading Automation vendors. He developed his first automated solution in 2006 and has continued to deliver robust, scalable and sophisticated Automation ever since.
Sagar is a regular guest speaker and panellist at Automation seminars, conferences and user group events.
Contact
Have a similar problem to solve, let's work together.
Our Address
#107, Tower B, Escon Arena, Zirakpur, Punjab, India - 140603
Email Us
info@atgensoft.com
Call Us
+91-8806666141