멀티 클러스터 메시 장애 조치 설정

Cloud Service Mesh를 사용하면 멀티 클러스터 환경에서 고가용성 트래픽 라우팅 전략을 구성할 수 있습니다. 이 설정은 정상 클러스터 간에 트래픽을 균등하게 분산하고 서비스 중단 중에 요청을 활성 클러스터로 자동으로 리디렉션합니다.

다음 표에서는 예상되는 동작을 설명합니다.

클러스터 상태 트래픽 동작
두 클러스터 모두 정상입니다. 트래픽의 50% 는 클러스터 A로, 50% 는 클러스터 B로 전송
클러스터 A를 사용할 수 없게 됨 클러스터 B로 트래픽 100%
클러스터 A 복구 50/50 분할을 자동으로 복원합니다.

기본 요건

이 가이드에서는 사용자가 다음 요건을 이미 충족한다고 가정합니다.

이 실습에서는 다음 리전을 사용합니다.

  • 클러스터 A: europe-west1
  • 클러스터 B: us-central1

멀티 클러스터 메시 장애 조치 설정

  1. Cloud Service Mesh 저장소의 샘플 매니페스트를 사용하여 공개 인그레스 게이트웨이를 배포하고 적용합니다.

    cat <<EOF> istio-ingressgateway.yaml
    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: public-gateway
      namespace: default
    spec:
      selector:
        istio: ingressgateway
      servers:
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - '*'
    EOF
    
    kubectl apply -f istio-ingressgateway.yaml
    

    이 게이트웨이는 hello-world 서비스를 외부에 노출합니다.

  2. 클러스터 A에서 VirtualService를 만들고 적용하여 트래픽을 hello-world 서비스로 라우팅합니다.

    cat <<EOF> virtual-service.yaml
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: hello-world
      namespace: default
    spec:
      hosts:
      - '*'
      gateways:
      - public-gateway
      http:
      - route:
        - destination:
            host: hello-world.default.svc.cluster.local
    EOF
    
    kubectl apply -f virtual-service.yaml
    

    이 구성은 게이트웨이에서 서비스로 HTTP 요청을 전달합니다.

  3. 지역 기반 장애 조치를 위한 DestinationRule 구성 및 적용

    cat <<EOF> destination-rule.yaml
    apiVersion: networking.istio.io/v1alpha3
    kind: DestinationRule
    metadata:
      name: hello-world
      namespace: default
    spec:
      host: hello-world.default.svc.cluster.local
      trafficPolicy:
        connectionPool:
          http:
            http2MaxRequests: 100
        outlierDetection:
          consecutive5xxErrors: 1
          interval: 1s
          baseEjectionTime: 30s
          maxEjectionPercent: 100
        loadBalancer:
          localityLbSetting:
            enabled: true
            distribute:
            - from: europe-west1
              to:
                europe-west1: 50
                us-central1: 50
            - from: us-central1
              to:
                us-central1: 50
                europe-west1: 50
    EOF
    
    kubectl apply -f destination-rule.yaml
    

다음에 유의하세요.

  • DestinationRule 아래의 localityLbSetting은 균등한 트래픽 분할 및 자동 장애 조치를 사용 설정합니다.
  • maxEjectionPercent를 사용하면 한 지역의 모든 엔드포인트가 비정상인 경우 Istio가 모든 트래픽을 장애 조치할 수 있습니다.
  • distribute: 소스 클러스터의 리전을 기준으로 클러스터 간에 50/50으로 균등하게 분할합니다.
  • 장애 조치: 한 위치를 사용할 수 없게 되면 암시적으로 처리됩니다. Istio는 트래픽의 100% 를 정상 리전으로 라우팅합니다.
  • outlierDetection: 최소 오류 기준점 이후 실패한 엔드포인트를 제거합니다.

검증

이제 다음을 통해 이 동작을 검증할 수 있습니다.

  1. 클러스터 A의 인그레스 게이트웨이를 통해 요청을 전송합니다.
  2. europe-west1의 hello-world 포드를 0으로 축소합니다.
  3. us-central1로의 트래픽 장애 조치를 관찰합니다.
  4. europe-west1에서 포드를 다시 확장하고 트래픽 분할이 재개되는지 확인합니다.