시작하기 - Istio
이 가이드는 Argo Rollouts가 트래픽 셰이핑을 위해 Istio Service Mesh와 어떻게 통합되는지 설명해요. 이 가이드는 기본 시작하기 가이드의 개념을 바탕으로 진행해요.
출처: 문서
본문
이 가이드는 Argo Rollouts가 트래픽 셰이핑을 위해 Istio Service Mesh와 어떻게 통합되는지 설명해요. 이 가이드는 기본 시작하기 가이드의 개념을 바탕으로 진행해요.
Requirements
- Istio가 설치된 Kubernetes 클러스터
Tip
Istio를 사용해 로컬 minikube 환경을 설정하는 방법은 environment setup guide for Istio를 참고해요.
1. Deploy the Rollout, Services, Istio VirtualService, and Istio Gateway
Istio가 트래픽 라우터로 사용될 때, Rollout canary 전략은 다음 필수 필드를 정의해야 해요:
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollouts-demo
spec:
strategy:
canary:
# Reference to a Service which the controller updates to point to the canary ReplicaSet
canaryService: rollouts-demo-canary
# Reference to a Service which the controller updates to point to the stable ReplicaSet
stableService: rollouts-demo-stable
trafficRouting:
istio:
virtualServices:
# One or more virtualServices can be configured
# Reference to a VirtualService which the controller updates with canary weights
- name: rollouts-demo-vsvc1
# Optional if there is a single HTTP route in the VirtualService, otherwise required
routes:
- http-primary
# Optional if there is a single HTTPS/TLS route in the VirtualService, otherwise required
tlsRoutes:
# Below fields are optional but if defined, they should match exactly with at least one of the TLS route match rules in your VirtualService
- port: 443 # Only required if you want to match any rule in your VirtualService which contains this port
# Only required if you want to match any rule in your VirtualService which contain all these SNI hosts
sniHosts:
- reviews.bookinfo.com
- localhost
- name: rollouts-demo-vsvc2
# Optional if there is a single HTTP route in the VirtualService, otherwise required
routes:
- http-secondary
# Optional if there is a single HTTPS/TLS route in the VirtualService, otherwise required
tlsRoutes:
# Below fields are optional but if defined, they should match exactly with at least one of the TLS route match rules in your VirtualService
- port: 443 # Only required if you want to match any rule in your VirtualService which contains this port
# Only required if you want to match any rule in your VirtualService which contain all these SNI hosts
sniHosts:
- reviews.bookinfo.com
- localhost
tcpRoutes:
# Below fields are optional but if defined, they should match exactly with at least one of the TCP route match rules in your VirtualService
- port: 8020 # Only required if you want to match any rule in your VirtualService which contains this port
trafficRouting.istio.virtualService 또는 trafficRouting.istio.virtualServices에 참조된 VirtualService와 라우트가 있어요. trafficRouting.istio.virtualServices는 단일 VirtualService만 추가할 수 있는 trafficRouting.istio.virtualService와 달리 하나 이상의 virtualService를 추가할 수 있게 해줘요. 이는 rollout에서 참조하는 stable과 canary 서비스 사이를 분할하는 HTTP, TLS, TCP 또는 혼합 라우트 스펙을 갖추는 데 필요해요. 라우트가 HTTPS/TLS라면 주어진 포트 번호와/또는 SNI 호스트를 기준으로 매칭할 수 있어요. 이 둘 모두 선택 사항이며, 이를 포함하는 VirtualService의 규칙을 매칭하려는 경우에만 필요하다는 점에 주의해요.
이 가이드에서 두 서비스는 각각 rollouts-demo-stable과 rollouts-demo-canary예요. 이 두 서비스의 가중치는 처음에 stable 서비스에 100%, canary 서비스에 0%로 설정되어야 해요. 업데이트 중에는 이 값들이 컨트롤러에 의해 수정돼요. 여러 VirtualService가 있으면 각 VirtualService의 stable·canary 서비스 가중치가 컨트롤러에 의해 동시에 수정돼요.
rollout 스펙에 HTTP와 HTTPS 라우트가 모두 있고 이들이 VirtualService 스펙과 일치하므로, 두 라우트 모두에 대해 가중치가 수정된다는 점에 주의해요.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: rollouts-demo-vsvc1
spec:
gateways:
- rollouts-demo-gateway
hosts:
- rollouts-demo-vsvc1.local
http:
- name: http-primary # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.routes
route:
- destination:
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
port:
number: 15372
weight: 100
- destination:
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
port:
number: 15372
weight: 0
tls:
- match:
- port: 443 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
- reviews.bookinfo.com
- localhost
route:
- destination:
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
weight: 100
- destination:
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
weight: 0
tcp:
- match:
- port: 8020 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tcpRoutes
route:
- destination:
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
weight: 100
- destination:
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
weight: 0
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: rollouts-demo-vsvc2
spec:
gateways:
- rollouts-demo-gateway
hosts:
- rollouts-demo-vsvc2.local
http:
- name: http-secondary # Should match rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.routes
route:
- destination:
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
port:
number: 15373
weight: 100
- destination:
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
port:
number: 15373
weight: 0
tls:
- match:
- port: 443 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
sniHosts: # Should match all the SNI hosts of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tlsRoutes
- reviews.bookinfo.com
route:
- destination:
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
weight: 100
- destination:
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
weight: 0
tcp:
- match:
- port: 8020 # Should match the port number of the route defined in rollout.spec.strategy.canary.trafficRouting.istio.virtualServices.tcpRoutes
route:
- destination:
host: rollouts-demo-stable # Should match rollout.spec.strategy.canary.stableService
weight: 100
- destination:
host: rollouts-demo-canary # Should match rollout.spec.strategy.canary.canaryService
weight: 0
다음 명령을 실행해 배포해요:
-
Rollout 하나
-
두 개의 서비스 (stable과 canary)
-
하나 이상의 Istio VirtualService
-
Istio Gateway 하나
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/rollout.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/services.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/multipleVirtualsvc.yaml
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/istio/gateway.yaml
매니페스트를 적용하고 나면 클러스터에서 다음과 같은 rollout, services, virtualservices, gateway 리소스를 볼 수 있어요:
$ kubectl get ro
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE
rollouts-demo 1 1 1 1
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rollouts-demo-canary ClusterIP 10.103.146.137 <none> 80/TCP 37s
rollouts-demo-stable ClusterIP 10.101.158.227 <none> 80/TCP 37s
$ kubectl get virtualservice
NAME GATEWAYS HOSTS AGE
rollouts-demo-vsvc1 [rollouts-demo-gateway] [rollouts-demo-vsvc1.local] 54s
rollouts-demo-vsvc2 [rollouts-demo-gateway] [rollouts-demo-vsvc2.local] 54s
$ kubectl get gateway
NAME AGE
rollouts-demo-gateway 71s
kubectl argo rollouts get rollout rollouts-demo
2. Perform an update
이미지를 변경해 rollout을 업데이트하고, paused 상태에 도달할 때까지 기다려요.
kubectl argo rollouts set image rollouts-demo rollouts-demo=argoproj/rollouts-demo:yellow
kubectl argo rollouts get rollout rollouts-demo
이 시점에서 Rollout의 canary와 stable 두 버전 모두 실행되고 있으며, 트래픽의 5%가 canary로 전달돼요. 이것이 어떻게 동작하는지 이해하려면 Rollout이 참조하고 있던 VirtualService를 확인해요. 두 VirtualService를 모두 보면 라우트 destination 가중치가 컨트롤러에 의해 canary의 현재 가중치를 반영하도록 수정되었음을 알 수 있어요.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: rollouts-demo-vsvc1
namespace: default
spec:
gateways:
- rollouts-demo-gateway
hosts:
- rollouts-demo-vsvc1.local
http:
- name: http-primary
route:
- destination:
host: rollouts-demo-stable
port:
number: 15372
weight: 95
- destination:
host: rollouts-demo-canary
port:
number: 15372
weight: 5
tls:
- match:
- port: 443
sniHosts:
- reviews.bookinfo.com
- localhost
route:
- destination:
host: rollouts-demo-stable
weight: 95
- destination:
host: rollouts-demo-canary
weight: 5
tcp:
- match:
- port: 8020
route:
- destination:
host: rollouts-demo-stable
weight: 95
- destination:
host: rollouts-demo-canary
weight: 5
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: rollouts-demo-vsvc2
namespace: default
spec:
gateways:
- rollouts-demo-gateway
hosts:
- rollouts-demo-vsvc2.local
http:
- name: http-primary
route:
- destination:
host: rollouts-demo-stable
port:
number: 15373
weight: 95
- destination:
host: rollouts-demo-canary
port:
number: 15373
weight: 5
tls:
- match:
- port: 443
sniHosts:
- reviews.bookinfo.com
route:
- destination:
host: rollouts-demo-stable
weight: 95
- destination:
host: rollouts-demo-canary
weight: 5
tcp:
- match:
- port: 8020
route:
- destination:
host: rollouts-demo-stable
weight: 95
- destination:
host: rollouts-demo-canary
weight: 5
Rollout이 steps를 진행하면서 HTTP, TLS, 그리고/또는 TCP 라우트의 destination 가중치가 steps의 현재 setWeight와 일치하도록 조정돼요.