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: 80Creating and Inspecting a Deployment
Apply the YAML:
kubectl apply -f nginx-deployment.yamlView the Deployment:kubectl get deploymentsSee the underlying ReplicaSet:kubectl get replicasetsCheck Pods:kubectl get podsScaling a Deployment
Scale to 5 replicas:
kubectl scale deployment nginx-deployment --replicas=5Deleting a Deployment
Deleting the Deployment deletes the associated ReplicaSet and Pods:
kubectl delete deployment nginx-deploymentTwo Minute Drill
- Deployment manages ReplicaSets and provides rolling updates and rollbacks.
- Define replicas, selector, and pod template.
- Use
kubectl scaleto change replicas. - Deleting a deployment removes its ReplicaSet and Pods.
Need more clarification?
Drop us an email at career@quipoinfotech.com
