Deployments: Declarative Workloads
A Deployment provides declarative updates for Pods and ReplicaSets. You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate.
1. Deployment Manifest
Section titled “1. Deployment Manifest”apiVersion: apps/v1kind: Deploymentmetadata: name: web-app labels: app: webspec: replicas: 3 selector: matchLabels: app: web strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 template: metadata: labels: app: web spec: containers: - name: web-server image: nginx:1.25-alpine ports: - containerPort: 80 resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 256Mi2. Deployment Operations
Section titled “2. Deployment Operations”# Apply deploymentkubectl apply -f deployment.yaml
# Scale replicas immediatelykubectl scale deployment web-app --replicas=5
# Monitor deployment progresskubectl rollout status deployment/web-app