πŸ”§ DevOps

Canary

Canary Deployment

A strategy that releases a new version to only some users. Minimizes impact if a problem occurs.

Detailed Explanation

A canary deployment is a progressive deployment strategy that releases a new version to a small number of users first so that problems can be detected early. The name comes from the use of canary birds in mines to detect toxic gases.

Only a portion of the total traffic (e.g., 1–5%) is sent to the new version, while error rate, latency, and business metrics are monitored. If there are no problems, the traffic share is gradually increased until it is finally switched over to 100%. If a problem occurs, traffic is immediately redirected back to the previous version.

In Kubernetes environments, it is implemented with tools such as Argo Rollouts, Flagger, and Istio. Traffic splitting, metric analysis, and even automatic rollback can be automated. In cloud services, AWS App Mesh, GCP Traffic Director, and similar services are used.

In practice, feature flags are used together with canary deployments for finer-grained control. New features are exposed only to specific user groups (beta testers, internal employees), and automatic promotion based on metrics reduces operational burden.

Code Example

# Argo Rollouts - μΉ΄λ‚˜λ¦¬ 배포 μ„€μ •
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: my-app
spec:
  replicas: 10
  strategy:
    canary:
      # μΉ΄λ‚˜λ¦¬ 단계 μ •μ˜
      steps:
        - setWeight: 5      # 5% νŠΈλž˜ν”½
        - pause: {duration: 5m}
        - setWeight: 20     # 20% νŠΈλž˜ν”½
        - pause: {duration: 5m}
        - setWeight: 50     # 50% νŠΈλž˜ν”½
        - pause: {duration: 10m}
        # 이후 100%둜 μžλ™ μ „ν™˜

      # μžλ™ 뢄석 (Prometheus λ©”νŠΈλ¦­ 기반)
      analysis:
        templates:
          - templateName: success-rate
        startingStep: 1
        args:
          - name: service-name
            value: my-app

      # νŠΈλž˜ν”½ λΌμš°νŒ… (Istio/Nginx 연동)
      trafficRouting:
        istio:
          virtualService:
            name: my-app-vsvc
            routes:
              - primary

  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: myregistry/my-app:v2.0.0

How It's Said in Practice

Senior: "Last time, the outage took 30 minutes to roll back. With a canary deployment, problems would be caught at 5% of traffic, so the blast radius would be much smaller."

Junior: "Which monitoring metrics should I watch?"

Senior: "Error rate, p99 latency, and business metrics (conversion rate, payment success rate, etc.). We set it up so Argo Rollouts analyzes them automatically and rolls back automatically on failure."

Interviewer: "How do you implement traffic splitting in a canary deployment?"

Candidate: "There are several ways. In Kubernetes, you can do it simply with the replica ratio, and the weight in an Istio VirtualService allows precise control. Weighted routing on a load balancer or the A/B testing feature of a CDN can also be used."

Take a mock interview on this topic β†’ WIA SOOM AI Interview Β· Start for free

Reviewer: "The analysis step only looks at success-rate, but adding latency-p99 would also let us detect performance degradation."

Developer: "Good point. I'll update the AnalysisTemplate to analyze with composite metrics."

Cautions

Learn More