[Resilience] DestinationRule 기본 실습: 서브셋(Subsets) 구성

y001·2025년 4월 27일

Istio 실전 스터디

목록 보기
18/26

목표

DestinationRule을 생성하여 서비스 버전별로 트래픽을 분리하는 방법을 실습한다.

실습 흐름

1. 서비스 v1, v2 배포

git clone https://github.com/istio/istio.git
cd istio/samples/helloworld

# v1 배포
kubectl apply -f helloworld-v1.yaml

# v2 배포
kubectl apply -f helloworld-v2.yaml

# 확인
kubectl get pods -l app=helloworld

v1과 v2 파드가 모두 떠 있는 것을 확인한다.

2. DestinationRule 생성

destination-rule-helloworld.yaml 파일 생성:

apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: helloworld
spec:
  host: helloworld
  subsets:
  - name: v1
    labels:
      version: v1
  - name: v2
    labels:
      version: v2

적용:

kubectl apply -f destination-rule-helloworld.yaml

3. VirtualService 생성

virtual-service-helloworld.yaml 파일 생성:

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: helloworld
spec:
  hosts:
  - helloworld
  http:
  - route:
    - destination:
        host: helloworld
        subset: v1
      weight: 50
    - destination:
        host: helloworld
        subset: v2
      weight: 50

적용:

kubectl apply -f virtual-service-helloworld.yaml

4. 테스트

테스트용 파드에서 helloworld 서비스 호출:

kubectl run -it --rm --restart=Never test-pod --image=curlimages/curl -- curl helloworld:5000/hello

v1과 v2가 번갈아 응답하는지 확인한다.

  • DestinationRule을 통해 동일 서비스 이름 안에서도 버전별(subset) 분리가 가능하다.
  • VirtualService와 함께 조합하면 트래픽을 자유롭게 분배할 수 있다.

0개의 댓글