Argo CD กับ Istio Service Mesh: Deploy Application พร้อม Traffic Management

Argo CD กับ Istio Service Mesh: Deploy Application พร้อม Traffic Management

Argo CD เป็นเครื่องมือ GitOps ที่ทรงพลังสำหรับการจัดการ Kubernetes Applications ในขณะที่ Istio Service Mesh มอบความสามารถในการจัดการ Traffic ขั้นสูงและ Observability ในระบบ Microservices เมื่อรวมเอา Argo CD และ Istio เข้าด้วยกัน จะสร้างสถาปัตยกรรม Modern DevOps ที่สมบูรณ์แบบสำหรับการ Deploy Applications พร้อมการควบคุม Traffic ที่ละเอียด

Istio Service Mesh คืออะไร?

Istio คือ Service Mesh Platform ที่ทำงานบน Kubernetes เพื่อจัดการการ Communication ระหว่าง Microservices ด้วย Envoy Sidecar Proxies

ความสามารถหลักของ Istio

  • Traffic Management: ควบคุมการไหลของ Traffic ระหว่าง Services
  • Security: Mutual TLS, Authorization Policies
  • Observability: Metrics, Distributed Tracing ผ่าน Kiali
  • Resilience: Circuit Breaking, Retries, Timeouts
  • Canary Deployments: ส่ง Traffic บางส่วนไปยัง Version ใหม่

ทำไมต้องรวม Argo CD กับ Istio?

1. Declarative Application Management

Argo CD ใช้ Git Repository เป็น Single Source of Truth สำหรับเก็บ Istio Configurations

2. Advanced Traffic Control

Istio มอบความสามารถในการควบคุม Traffic ขั้นสูง เช่น แบ่ง Traffic ระหว่าง Versions, Retry Logic, Circuit Breaking

3. Automated Deployment Pipeline

เมื่อ Developer Push Code ไป Git Repository, Argo CD จะ Deploy ใหม่และ Istio จะจัดการ Traffic ตามกฎที่กำหนด

4. Real-time Monitoring

Kiali Dashboard ช่วยให้เห็นการไหลของ Traffic, Response Times, Error Rates แบบ Real-time

ขั้นตอนการ Setup Argo CD กับ Istio

ขั้นตอนที่ 1: ติดตั้ง Istio บน Kubernetes Cluster

ติดตั้ง Istio บน Cloud VPS ของ ผู้ให้บริการโฮสติ้ง ที่รองรับ Kubernetes

# ดาวน์โหลด Istio
curl -L https://istio.io/downloadIstio | sh -
cd istio-1.19.0
./bin/istioctl install --set profile=demo -y
kubectl get pods -n istio-system

ขั้นตอนที่ 2: ติดตั้ง Argo CD

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

ขั้นตอนที่ 3: Enable Istio Injection

kubectl label namespace production istio-injection=enabled

Istio Resources: VirtualService, DestinationRule, และ Gateway

VirtualService: กำหนดกฎการไหลของ Traffic

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: my-app-vs
  namespace: production
spec:
  hosts:
  - my-app.example.com
  http:
  - match:
    - uri:
        prefix: "/api/v1"
    route:
    - destination:
        host: my-app-svc
        port:
          number: 8080
        subset: v1
      weight: 80
    - destination:
        host: my-app-svc
        port:
          number: 8080
        subset: v2
      weight: 20
    timeout: 30s
    retries:
      attempts: 3
      perTryTimeout: 10s

DestinationRule: กำหนดพฤติกรรมของ Traffic

apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: my-app-dr
  namespace: production
spec:
  host: my-app-svc
  trafficPolicy:
    connectionPool:
      tcp:
        maxConnections: 100
      http:
        http1MaxPendingRequests: 100
    outlierDetection:
      consecutive5xxErrors: 5
      interval: 30s
      baseEjectionTime: 30s
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2

Gateway: เปิดเข้าสู่ Service Mesh

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: my-app-gateway
  namespace: production
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "my-app.example.com"
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: my-app-cert
    hosts:
    - "my-app.example.com"

Canary Deployments ด้วย Argo CD และ Istio

หลักการของ Canary Deployments

Canary Deployments เป็นเทคนิคการ Deploy ที่มีความปลอดภัยสูง โดยส่ง Traffic เพียงเล็กน้อยไปยัง Version ใหม่ก่อน

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: my-app-canary
  namespace: production
spec:
  hosts:
  - my-app.example.com
  http:
  - route:
    - destination:
        host: my-app-svc
        subset: stable
      weight: 80
    - destination:
        host: my-app-svc
        subset: canary
      weight: 20
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: my-app-canary-dr
  namespace: production
spec:
  host: my-app-svc
  subsets:
  - name: stable
    labels:
      version: v1.0.0
  - name: canary
    labels:
      version: v1.1.0

Argo CD Application สำหรับ Canary

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app-canary
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/your-org/my-app
    targetRevision: main
    path: istio-config
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

ขั้นตอนการเพิ่ม Traffic ทีละขั้น

  1. Deploy Version ใหม่ด้วย Argo CD (ส่ง 20% Traffic)
  2. Monitor Metrics ใน Kiali เป็นเวลา 5-10 นาที
  3. หากไม่มี Errors ให้เพิ่มเป็น 50% Traffic
  4. Monitor อีกครั้งเป็นเวลา 10 นาที
  5. หากสำเร็จให้เปลี่ยนเป็น 100% Traffic
  6. ลบ Canary Version เก่าออก

Monitoring ด้วย Kiali

Kiali คือ Service Mesh Observability Dashboard สำหรับ Istio

kubectl port-forward svc/kiali 20000:20000 -n istio-system

สิ่งที่ควร Monitor

  • Request Rate: จำนวน Requests ต่อวินาที
  • Error Rate: เปอร์เซนต์ของ Failed Requests
  • Response Time: ความเร็วของการตอบสนอง
  • Success Rate: เปอร์เซนต์ของ Successful Requests

Best Practices ในการใช้ Argo CD กับ Istio

1. แยกไฟล์ Configuration ให้ชัดเจน

my-app/
├── app/
│   ├── deployment.yaml
│   ├── service.yaml
│   └── configmap.yaml
├── istio/
│   ├── virtualservice.yaml
│   ├── destinationrule.yaml
│   └── gateway.yaml
└── kustomization.yaml

2. ใช้ Kustomize หรือ Helm สำหรับ Template Management

ใช้ Kustomize หรือ Helm เพื่อจัดการ Multiple Environments

3. Version Control ทั้งหมด

เก็บ Application Code, Kubernetes Manifests, และ Istio Configurations ทั้งหมดใน Git Repository

4. ใช้ Notification สำหรับ Deployment Events

ตั้ง Notifications เพื่อได้รับแจ้งเมื่อ Argo CD Deploy หรือ Sync ล้มเหลว

ติดตั้ง Argo CD บน Cloud VPS ของ ผู้ให้บริการโฮสติ้ง

Cloud VPS ของ ผู้ให้บริการโฮสติ้ง มอบ Performance สูงและความเสถียรที่เหมาะสำหรับการรัน Kubernetes Cluster ที่มี Argo CD และ Istio

ข้อดีของการใช้ Cloud VPS ของ ผู้ให้บริการโฮสติ้ง

  • Performance สูง: CPU, Memory และ Storage ที่เพียงพอ
  • Scalability: ปรับขนาด Resources ได้ตามความต้องการ
  • High Availability: รองรับ Multi-Master Kubernetes Cluster
  • Network Bandwidth: Bandwidth ที่มากพอสำหรับ Service Mesh Traffic
  • Security: Firewall Rules, Security Groups
  • Support 24/7: ทีม Technical Support พร้อมช่วยเหลือ

บทสรุป

การรวม Argo CD และ Istio Service Mesh สร้างสถาปัตยกรรม GitOps ที่สมบูรณ์สำหรับการ Deploy และจัดการ Microservices Applications ด้วยความปลอดภัยและการควบคุม Traffic ขั้นสูง

  • Declarative Deployment: เก็บ Configuration ทั้งหมดใน Git
  • Advanced Traffic Management: VirtualService, DestinationRule, Gateway
  • Canary Deployments: ลดความเสี่ยงของการ Deploy ใหม่
  • Real-time Monitoring: ตรวจสอบ Service Health ด้วย Kiali

หากคุณต้องการติดตั้ง Kubernetes Cluster ที่มี Argo CD และ Istio โดยใช้ Cloud VPS ของ ผู้ให้บริการโฮสติ้ง เราพร้อมที่จะช่วยเหลือ

บทความนี้เขียนโดย ผู้ให้บริการโฮสติ้ง

สำหรับข้อมูลเพิ่มเติม โปรดเยี่ยมชม https://de.co.th/cloud-vps

ติดต่อ ผู้ให้บริการโฮสติ้ง: https://de.co.th