---
title: "Kubernetes thực chiến: Triển khai Blue-Green và Canary Argo Rollouts"
description: "Hướng dẫn triển khai Blue-Green và Canary Deployment trên Kubernetes bằng Argo Rollouts. Giảm thiểu downtime và tự động rollback khi phát hiện lỗi."
canonical: "https://thuecloud.vn/kubernetes-thuc-chien-trien-khai-blue-green-va-canary-argo-rollouts"
markdown_url: "https://thuecloud.vn/kubernetes-thuc-chien-trien-khai-blue-green-va-canary-argo-rollouts.md"
locale: "vi"
kind: "article"
published_at: "2026-11-22T16:18:17.286Z"
updated_at: "2026-11-22T16:18:15.649Z"
site: "ThueCloud.Vn"
estimated_tokens: 1819
---
# Kubernetes thực chiến: Triển khai Blue-Green và Canary Argo Rollouts

> Hướng dẫn triển khai Blue-Green và Canary Deployment trên Kubernetes bằng Argo Rollouts. Giảm thiểu downtime và tự động rollback khi phát hiện lỗi.

- Canonical HTML: https://thuecloud.vn/kubernetes-thuc-chien-trien-khai-blue-green-va-canary-argo-rollouts
- Markdown URL: https://thuecloud.vn/kubernetes-thuc-chien-trien-khai-blue-green-va-canary-argo-rollouts.md
- Organization: ThueCloud.Vn
- Support Email: support@thuecloud.vn
- Hotline: 03333 499 48
- Published: 2026-11-22
- Updated: 2026-11-22

## Mục lục

- So sánh Blue-Green vs Canary với Argo Rollouts
- Cài đặt Argo Rollouts và cấu hình Blue-Green mẫu
  - Bước 1: Cài đặt Argo Rollouts Controller lên Cluster
  - Bước 2: Định nghĩa Rollout chiến lược Blue-Green
- Câu hỏi thường gặp (FAQ)
  - Argo Rollouts có cần Ingress Controller đặc biệt (như Istio hay NGINX) không?
  - Nếu Pod mới bị CrashLoopBackOff, Argo Rollouts có tự chuyển traffic sang không?
  - Có thể chuyển đổi file Deployment hiện có sang Rollout dễ dàng không?

Deployment mặc định của Kubernetes chỉ hỗ trợ chiến lược `RollingUpdate` cơ bản, không cho phép kiểm soát tỷ lệ traffic chính xác (ví dụ chỉ đẩy 5% người dùng sang phiên bản mới) hay giữ nguyên bản cũ để chuyển đổi tức thì. Khi vận hành hệ thống production trên [VPS Việt Nam](https://thuecloud.vn/vps-viet-nam), **Argo Rollouts** là giải pháp chuẩn công nghiệp giúp triển khai Blue-Green và Canary an toàn.

> **Tóm tắt nhanh (TL;DR):**
> - **Blue-Green:** Chạy song song 2 phiên bản (`active` và `preview`), kiểm thử kỹ bản mới qua service preview trước khi chuyển 100% traffic.
> - **Canary:** Đẩy dần traffic (5% -> 20% -> 50% -> 100%) kết hợp phân tích metrics từ Prometheus để tự động rollback nếu tỷ lệ lỗi HTTP 5xx tăng.
> - Argo Rollouts thay thế kind `Deployment` bằng `Rollout` mà giữ nguyên cấu trúc Pod template quen thuộc.
> - *Cập nhật: 11/2026*

## So sánh Blue-Green vs Canary với Argo Rollouts

| Tiêu chí | Blue-Green Deployment | Canary Deployment |
| :--- | :--- | :--- |
| **Mức tiêu thụ RAM/CPU** | Gấp đôi trong lúc deploy (2 bản chạy cùng lúc) | Tăng nhẹ theo từng bước (5%, 20%...) |
| **Kiểm thử bản mới** | Test toàn bộ trên URL `preview` trước khi switch | Test trực tiếp với một nhóm nhỏ người dùng thật |
| **Tốc độ Rollback** | Tức thì (< 1 giây, trỏ lại service cũ) | Nhanh (giảm weight về 0%) |
| **Phù hợp với** | App cần chuyển đổi dứt khoát, ít chịu được 2 version song song | API, Microservice lưu lượng lớn |

## Cài đặt Argo Rollouts và cấu hình Blue-Green mẫu

### Bước 1: Cài đặt Argo Rollouts Controller lên Cluster

```bash
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
```

### Bước 2: Định nghĩa `Rollout` chiến lược Blue-Green

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: web-api-rollout
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-api
  template:
    metadata:
      labels:
        app: web-api
    spec:
      containers:
      - name: web-api
        image: registry.yourdomain.vn/web-api:v2.1.0
        ports:
        - containerPort: 8080
  strategy:
    blueGreen:
      activeService: web-api-active
      previewService: web-api-preview
      autoPromotionEnabled: false
```

Với `autoPromotionEnabled: false`, bản mới (Green) sẽ nằm ở `web-api-preview` để QA kiểm tra. Khi sẵn sàng chuyển traffic, bạn chỉ cần chạy:

```bash
kubectl argo rollouts promote web-api-rollout
```

Để hệ thống vận hành đồng bộ, bạn cần nắm vững cách chọn hạ tầng lưu trữ qua bài [phân tích kỹ thuật S3 API vs NFS vs iSCSI](https://thuecloud.vn/phan-tich-ky-thuat-s3-api-vs-nfs-vs-iscsi-khi-nao-nen-dung-trong-thuc-te), thiết lập [sao lưu tự động cho Next.js](https://thuecloud.vn/thiet-lap-sao-luu-tu-dong-va-khoi-phuc-nhanh-cho-next-js-ssr-isr) và phòng tránh [lỗ hổng Prompt Injection](https://thuecloud.vn/sua-loi-vibe-coding-khi-deploy-app-ai-len-vps-nhan-nham-prompt-injection-lam-ro-ri-system-prompt) khi triển khai dịch vụ AI.

> **Xây dựng cụm Kubernetes thực chiến tại ThueCloud.Vn:**
> **Cloud VPS KVM Enterprise NVMe** tại `vn-hn` hỗ trợ mạng nội bộ tốc độ cao giữa các Node, lý tưởng cho K3s/Kubernetes + Argo Rollouts. Các gói **VPS VN 2** (**78.000đ/tháng** trả năm, **90.000đ** theo tháng) và **VPS VN 3** (**139.000đ** / **170.000đ**), **VAT 0%**, **SLA 99,9%**, **hoàn tiền 07 ngày**. Xem [bảng giá](https://thuecloud.vn/pricing) và [giải pháp](https://thuecloud.vn/giai-phap).

## Câu hỏi thường gặp (FAQ)

### Argo Rollouts có cần Ingress Controller đặc biệt (như Istio hay NGINX) không?
Với chiến lược **Blue-Green**, Argo Rollouts không cần Ingress đặc biệt, chỉ cần 2 Kubernetes `Service` chuẩn. Chỉ chiến lược **Canary** chia % traffic mịn (traffic splitting) mới cần tích hợp NGINX Ingress, Traefik hoặc Istio.

### Nếu Pod mới bị `CrashLoopBackOff`, Argo Rollouts có tự chuyển traffic sang không?
Không. Argo Rollouts chờ các Pod của phiên bản mới vượt qua `readinessProbe` thành công hoàn toàn trước khi cho phép promote hoặc tăng tỷ lệ traffic.

### Có thể chuyển đổi file `Deployment` hiện có sang `Rollout` dễ dàng không?
Có. Bạn chỉ cần đổi `apiVersion: argoproj.io/v1alpha1`, `kind: Rollout` và thêm block `spec.strategy`, hoặc dùng trường `workloadRef` trỏ tới Deployment cũ nếu muốn giữ cấu trúc tách biệt.

## References / Sources

- https://argo-rollouts.readthedocs.io/en/stable/
- https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

---

## Navigation & Machine-Readable Endpoints

- [Site Summary (llms.txt)](https://thuecloud.vn/llms.txt)
- [Full Technical Reference (llms-full.txt)](https://thuecloud.vn/llms-full.txt)
- [Pricing Catalog (Markdown)](https://thuecloud.vn/pricing.md)
- [Blog & Technical Guides (Markdown)](https://thuecloud.vn/blog.md)
- [XML Sitemap](https://thuecloud.vn/sitemap.xml)
