🔧 DevOps

Deployment

Deployment

The process of releasing an application to a production environment. Many strategies exist, such as Blue-Green, Canary, and Rolling.

Detailed Explanation

Deployment refers both to the process of deploying an application to a production environment and to a workload resource in Kubernetes. It is a core DevOps activity that safely delivers code from development to production.

A Kubernetes Deployment manages declarative updates for Pods. It creates a ReplicaSet, performs zero-downtime deployments through rolling updates, and keeps a history to support rollback. Once you define the desired state in the spec, the controller works to bring the current state into line with it.

Deployment strategies include Recreate (stop everything, then recreate), RollingUpdate (gradual replacement), Blue-Green (environment switch), and Canary (partial traffic validation). Each strategy involves trade-offs in downtime, resource usage, and ease of rollback.

In practice, a CI/CD pipeline automatically triggers the Deployment. GitHub Actions, GitLab CI, ArgoCD, and others detect a Git push and perform build, test, and deploy. Separating configuration per environment (dev/staging/prod) and approval gates are essential.

Code Example

# Kubernetes Deployment 매니페스트
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1          # 초과 Pod 허용 수
      maxUnavailable: 0    # 최소 가용성 보장
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: web
        image: myapp:v1.2.0
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "256Mi"
            cpu: "250m"
          limits:
            memory: "512Mi"
            cpu: "500m"
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 5
        env:
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: db-credentials
              key: host
---
# kubectl 배포 명령어
# kubectl apply -f deployment.yaml
# kubectl rollout status deployment/web-app
# kubectl rollout history deployment/web-app
# kubectl rollout undo deployment/web-app --to-revision=2

How It's Said in Practice

Senior: "This deployment includes a DB migration, so the order matters. Migration first, then the deployment."

Junior: "Yes, I've set up the pipeline so that the Deployment is triggered after the migration runs as a Job."

Interviewer: "Please explain how a rolling update of a Kubernetes Deployment works."

Candidate: "It creates a new ReplicaSet and gradually replaces the Pods. maxSurge sets the number of Pods that can be created at the same time, and maxUnavailable sets the minimum availability. The next Pod is replaced only after the readinessProbe passes."

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

Reviewer: "There's no resources setting. Will that be a problem in production?"

Developer: "Based on the load test results, I'll add settings with a request of 256Mi and a limit of 512Mi."

Cautions

Learn More