Loading

Quipoin Menu

Learn • Practice • Grow

kubernetes / Deployments
tutorial

Deployments

While ReplicaSets are useful, they lack advanced features like rolling updates and rollbacks. Deployments build on top of ReplicaSets to provide declarative updates for Pods and ReplicaSets.

What Is a Deployment?

A Deployment manages a ReplicaSet and provides capabilities like rolling updates, rollbacks, and declarative scaling. It is the most common workload controller for stateless applications.

A Deployment provides declarative updates for Pods and ReplicaSets.

Deployment YAML Example

Here’s a Deployment for Nginx with 3 replicas:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.21
ports:
- containerPort: 80

Creating and Inspecting a Deployment

Apply the YAML:
kubectl apply -f nginx-deployment.yaml
View the Deployment:
kubectl get deployments
See the underlying ReplicaSet:
kubectl get replicasets
Check Pods:
kubectl get pods

Scaling a Deployment

Scale to 5 replicas:
kubectl scale deployment nginx-deployment --replicas=5

Deleting a Deployment

Deleting the Deployment deletes the associated ReplicaSet and Pods:
kubectl delete deployment nginx-deployment


Two Minute Drill
  • Deployment manages ReplicaSets and provides rolling updates and rollbacks.
  • Define replicas, selector, and pod template.
  • Use kubectl scale to change replicas.
  • Deleting a deployment removes its ReplicaSet and Pods.

Need more clarification?

Drop us an email at career@quipoinfotech.com