Deployment Strategies
Deployment Types in Kubernetes
Kubernetes offers multiple deployment strategies to manage application lifecycle and ensure smooth updates and scaling.
Deployment Configuration
graph TD
A[Deployment Strategy] --> B[Recreate]
A --> C[Rolling Update]
A --> D[Blue-Green]
A --> E[Canary]
Basic Deployment Configuration
Deployment Manifest Example
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.14.2
ports:
- containerPort: 80
Deployment Strategies Comparison
| Strategy |
Downtime |
Risk |
Rollback Speed |
| Recreate |
High |
Low |
Fast |
| Rolling Update |
None |
Medium |
Moderate |
| Blue-Green |
Minimal |
Low |
Instant |
| Canary |
None |
Very Low |
Gradual |
Scaling Applications
Horizontal Pod Autoscaler
## Scale deployment
kubectl scale deployment nginx-deployment --replicas=5
## Create horizontal pod autoscaler
kubectl autoscale deployment nginx-deployment --min=2 --max=10 --cpu-percent=50
Rolling Update Process
Update Deployment
## Update deployment image
kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
## Check rollout status
kubectl rollout status deployment/nginx-deployment
## Rollback if needed
kubectl rollout undo deployment/nginx-deployment
Advanced Deployment Techniques
Kubernetes provides sophisticated mechanisms for managing application deployments, ensuring high availability, minimal downtime, and seamless updates across complex distributed systems.