๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ”Ž Service Mesh

[Service Mesh] 4. Istio Traffic Management (1) - Virtual Service & Destination Rule

by Seongpyo Hong 2021. 1. 14.

Service Mesh ์•Œ์•„๋ณด๊ธฐ

  1. [Service Mesh] 1. Service Mesh๋ž€?
  2. [Service Mehs] 2. Envoy Proxy
  3. [Service Mesh] 3. Istio?
  4. [Service Mesh] 4. Istio Traffic Management (1) - Virtual Service & Destination Rule
  5. [Service Mesh] 5. Istio Traffic Managerment (2) - Gateway & Service Entry
  6. [Service Mesh] 6. Service Monitoring in Istio
  7. [Service Mesh] 7. Logging

 


์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Istio์˜ Traffic Management์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Istio์˜ ์ค‘์š”ํ•œ ๊ธฐ๋Šฅ ์ค‘ ํ•˜๋‚˜๋Š” ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ์„ ์ ์ ˆํ•˜๊ฒŒ ๋ผ์šฐํŒ… ํ•ด์ฃผ๋Š” ํŠธ๋ž˜ํ”ฝ ๊ด€๋ฆฌ ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. Istio์—์„œ ์–ด๋–ป๊ฒŒ ํŠธ๋ž˜ํ”ฝ ๊ด€๋ฆฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š”์ง€ ์•Œ๊ธฐ ์œ„ํ•ด์„œ๋Š” Virtual Service์™€ Destination Rule์ด๋ผ๋Š” ๊ฐœ๋…์— ๋Œ€ํ•ด ์•Œ์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. 

Virtual Service?

Virtual Service๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์—์„œ Ingress๊ฐ€ L7 ๊ธฐ๋ฐ˜ ์„œ๋น„์Šค ๋ผ์šฐํŒ…์„ ํ•ด์ฃผ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ํŠธ๋ž˜ํ”ฝ์„ ์ ์ ˆํ•œ Service์— ๋ผ์šฐํŒ…ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 

Destination Rule? 

Destination Rule์€ ํŠธ๋ž˜ํ”ฝ์— ์ ์šฉ๋  ๋ผ์šฐํŒ… ์ •์ฑ…์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. Virtual Service์™€ ํ—ท๊ฐˆ๋ฆด ์ˆ˜๋„ ์žˆ๋Š”๋ฐ ๋จผ์ € ์š”์ฒญ์ด ์–ด๋–ค Service์— ๋ผ์šฐํŒ… ๋˜๋Š”์ง€ ๊ฒฐ์ •ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์ด Virtual Service, ์ดํ›„ Service์—์„œ ์–ด๋–ป๊ฒŒ ํŠธ๋ž˜ํ”ฝ์„ ์ „์†กํ•  ๊ฒƒ์ธ์ง€ ์ •ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ํ•˜๋Š” ๊ฒƒ์ด Destination Rule์ž…๋‹ˆ๋‹ค. ์ถ”๊ฐ€๋กœ Destination Rule์—์„œ๋Š” Load Balancing, Connection Pool Size, ์ด์ƒ ํƒ์ง€ ์„ค์ •๊ณผ ๊ฐ™์€ ๊ธฐ๋Šฅ๋„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„ค๋ช…์œผ๋กœ๋Š” ์ดํ•ด๊ฐ€ ์ž˜ ๊ฐ€์ง€ ์•Š์„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ„๋‹จํ•œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ์„ฑ์„ ํ†ตํ•ด ํŠธ๋ž˜ํ”ฝ ๊ด€๋ฆฌ๋ฅผ ์ˆ˜ํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.


Trrafic Management Tutorial

๋‹ค์Œ์œผ๋กœ Destination Rule ๋ฐ Virtual Service๋ฅผ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์œ„ํ•ด ๊ฐ„๋‹จํ•œ Spring Boot ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋งŒ๋“ค์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์€ Front Application๊ณผ Server Application์œผ๋กœ ๊ตฌ์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋จผ์ € Front Application์€ Minikube ํ™˜๊ฒฝ์—์„œ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด NodePort ํƒ€์ž…์˜ Service๋กœ ๋…ธ์ถœ๋˜๋ฉฐ  /hello๋กœ ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ์„ ๋ฐ›์œผ๋ฉด RestTemplate์„ ํ†ตํ•ด http://webservice:80/๋กœ GET ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค. 
Server Application์€ /๋กœ ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋ฉด ํ˜„์žฌ ์‹œ๊ฐ„๊ณผ ํ•ด๋‹น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ Version์„ ๋ฐ˜ํ™˜ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

Front ๋ฐ Server Application์˜ ์ฝ”๋“œ๋Š” ๊ธ€์˜ ๋‚ด์šฉ๊ณผ ๋ฌด๊ด€ํ•œ ์ฝ”๋“œ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋”ฐ๋กœ ์–ธ๊ธ‰ํ•˜์ง€ ์•Š๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๊ฐ€ ๊ถ๊ธˆํ•˜์‹œ๊ฑฐ๋‚˜ ํ…Œ์ŠคํŠธ๋ฅผ ์ง์ ‘ ๊ตฌ๋™ํ•ด๋ณด๊ธฐ ์›ํ•˜์‹œ๋Š” ๋ถ„์€ Github์˜ ์ฝ”๋“œ๋ฅผ ์ฐธ๊ณ ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 


1. ๋„์ปค ์ด๋ฏธ์ง€ ์ƒ์„ฑ

Front Application๊ณผ ๋‹ค๋ฅธ ๋ฒ„์ „์„ ๊ฐ–๋Š” Server Application์˜ ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•ด์ค๋‹ˆ๋‹ค.

//front
โžœ docker build . -t front:1.0
//server
โžœ docker build . -t server:1.0 --build-arg version=1.0
โžœ docker build . -t server:2.0 --build-arg version=2.0

2. ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ฆฌ์†Œ์Šค ์ƒ์„ฑ (Front Application)

์ด์ œ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ์— ํ•ด๋‹น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•˜๊ณ  ์„œ๋น„์Šค๋ฅผ ํ†ตํ•ด ๋…ธ์ถœ์‹œ์ผœ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋จผ์ € Front Application์„ ์œ„ํ•œ Service์™€ Deployment๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. Minikube ํ™˜๊ฒฝ์—์„œ ํ…Œ์ŠคํŠธ๋ฅผ ์šฉ์ดํ•˜๊ฒŒ ์ง„ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด Front Application๋Š” NodePort ํƒ€์ž…์œผ๋กœ ๋…ธ์ถœ๋˜๋„๋ก ๊ตฌ์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Service (Front Application)

apiVersion: v1
kind: Service
metadata:
  name: frontservice
spec:
  selector:
    app: front
  type: NodePort
  ports:
  - name: http-frontservice
    port: 8080
    protocol: TCP
    targetPort: 8080

 

Deployment(Front Application)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-front
  labels:
    app: front
spec:
  replicas: 1
  selector:
    matchLabels:
      app: front
  template:
    metadata:
      labels:
        app: front
    spec:
      containers:
      - name: front
        image: front:1.0
        ports:
        - containerPort: 8080

3. ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ฆฌ์†Œ์Šค ์ƒ์„ฑ (Server Application)

๋‹ค์Œ์œผ๋กœ Server Application์„ ์œ„ํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ €๋Š” ๋ฒ„์ „์— ๋”ฐ๋ฅธ Subset ๊ตฌ์„ฑ๊ณผ ๋ผ์šฐํŒ…์„ ํ…Œ์ŠคํŠธ ํ•ด๋ณด๊ธฐ ์œ„ํ•ด Server Application์„ webservice๋ผ๋Š” ํ•˜๋‚˜์˜ Service๋ฅผ ํ†ตํ•ด ๋…ธ์ถœํ•˜๊ณ  ๊ฐ ๋ฒ„์ „์— ๋”ฐ๋ฅธ Deployment๋ฅผ ๊ตฌ์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Service (Server Application)

apiVersion: v1
kind: Service
metadata:
  name: webservice
spec:
  selector:
    app: server
  ports:
  - name: http-webservice
    port: 80
    protocol: TCP
    targetPort: 8080

 

Deployment-v1.0/v2.0 (Server Application)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-server-v1
  labels:
    app: server
    version: v1.0
spec:
  replicas: 1
  selector:
    matchLabels:
      app: server
  template:
    metadata:
      labels:
        app: server
        version: v1.0
    spec:
      containers:
      - name: server
        image: server:1.0
        ports:
        - containerPort: 8080
        
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-server-v2
  labels:
    app: server
    version: v2.0
spec:
  replicas: 1
  selector:
    matchLabels:
      app: server
  template:
    metadata:
      labels:
        app: server
        version: v2.0
    spec:
      containers:
      - name: server
        image: server:2.0
        ports:
        - containerPort: 8080

4. Destination Rule ์„ค์ •

Destination Rule์˜ Subset์— v1.0๊ณผ v2.0๋ฅผ ์ •์˜ํ•ด์ค๋‹ˆ๋‹ค. ์•„๋ž˜ ์„ค์ •์—์„œ webservice๋ผ๋Š” host๋กœ ์˜ค๋Š” ์š”์ฒญ์€ v1(v1.0 ๋ฒ„์ „ ๋ ˆ์ด๋ธ”์„ ์ง€๋‹Œ ๊ทธ๋ฃน)๊ณผ v2(v2.0 ๋ฒ„์ „ ๋ ˆ์ด๋ธ”์„ ์ง€๋‹Œ ๊ทธ๋ฃน)์œผ๋กœ ๊ตฌ๋ถ„๋˜์–ด์ง‘๋‹ˆ๋‹ค.

Destination Rule

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

 

์ถ”๊ฐ€๋กœ subset ์ •์˜ ์ด์™ธ์—๋„ Connection Pool, Load Balancing, Outlier Detection๊ณผ ๊ฐ™์€ ๊ธฐ๋Šฅ๋“ค๋„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

1) Connection Pool

Connection Pool์€ ๋ชจ๋“  ์—ฐ๊ฒฐ์„ ์ƒˆ๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ์— ๋Œ€ํ•œ ๋น„์šฉ์„ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ํŠนํžˆ, ์„œ๋น„์Šค ๋ฉ”์‹œ ์•„ํ‚คํ…์ณ์—์„œ TLS๋ฅผ ํ™œ์„ฑํ™” ํ–ˆ์„ ๊ฒฝ์šฐ ์—ฐ๊ฒฐ์„ ๋งบ๋Š”๋ฐ ๋ฐœ์ƒํ•˜๋Š” ๋น„์šฉ์„ ํšจ๊ณผ์ ์œผ๋กœ ๊ฐ์†Œ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Istio์—์„œ๋Š” ์ด๋Ÿฐ ์„ค์ •๋“ค์„ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ง€์›ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋งŽ์€ ์„ค์ •์ด ์กด์žฌํ•˜์ง€๋งŒ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ช‡๊ฐ€์ง€ ์„ค์ •๋“ค๋งŒ ํ™•์ธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

  • maxConnections : Connection ์ˆ˜์˜ ์ตœ๋Œ€๊ฐ’
  • connectionTimeout: TCP ์—ฐ๊ฒฐ์— ๋ฐœ์ƒํ•˜๋Š” timeout ์ œํ•œ
  • Http1MaxPendingRequests: Pending ์ƒํƒœ์˜ HTTP ์š”์ฒญ ์ˆ˜ ์ œํ•œ

์ฐธ๊ณ ๋กœ, Connection Pool์€ Envoy Proxy๋ฅผ ํ†ตํ•ด ๋ชจ๋‹ˆํ„ฐ๋ง๋˜๋ฉฐ ์„ค์ •ํ•œ ์ œํ•œ๊ฐ’๋“ค์— ๋„๋‹ฌํ•˜๊ฒŒ ๋˜๋ฉด ํšŒ๋กœ ์ฐจ๋‹จ๊ธฐ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ํ†ตํ•ด Connection Pool์˜ ์ƒํƒœ๋ฅผ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค.

2) Load Balancing

Destination Rule์—์„œ๋Š” Subset๊ฐ„์˜ ๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ์„ ์œ„ํ•ด ๋‹ค์–‘ํ•œ ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

  • Round Robin : ์‹œ๊ฐ„ ํ€€ํ…€๋งˆ๋‹ค ์ž„์˜ ๋ฐฐ๋ถ„
  • Least Connection : ๊ฐ€์žฅ ์ ์€ ์ˆ˜์˜ ์—ฐ๊ฒฐ์„ ์ œ๊ณตํ•˜๋Š” ํ˜ธ์ŠคํŠธ ์„ ํƒ
  • Random : ์ž„์˜ ๋ฐฐ๋ถ„
  • Consistent Hash : ์š”์ฒญ ํ—ค๋” ๋ฐ ์ฟ ํ‚ค ๊ธฐ๋ฐ˜ ํ•ด์‹ฑ

3) Outlier Detection

Istio์—์„œ๋Š” ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ ๋Œ€์ƒ ํ˜ธ์ŠคํŠธ์—์„œ ๋น„์ •์ƒ์ ์ธ ๋™์ž‘์„ ํ•˜๋Š” ํ˜ธ์ŠคํŠธ๋ฅผ ํƒ์ง€ํ•ด ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ ํ˜ธ์ŠคํŠธ์—์„œ ์ œ๊ฑฐํ•˜๋Š” ๊ธฐ๋Šฅ์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. Istio๋Š” ์„œ๋น„์Šค์—์„œ ๋ฐœ์ƒํ•œ ์—ฐ์† ์˜ค๋ฅ˜๋ฅผ ๊ธฐ๋กํ•˜๋ฉฐ ์ด ๋•Œ ์—ฐ๊ฒฐ ํƒ€์ž„์•„์›ƒ, 5xx ์‘๋‹ต๊ณผ ๊ฐ™์€ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•˜๋ฉด ์˜ค๋ฅ˜๋กœ ๊ธฐ๋กํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์œ„์˜ ์„ค์ •์—์„œ v1.0์— Load Balacing ๋ฐ Connection Pool ์„ค์ •์„ ์ ์šฉํ•ด Destination Rule์„ ์ˆ˜์ •ํ•˜์—ฌ ์‚ฌ์šฉํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: web-destination
spec:
  host: webservice
  subsets:
  - name: v1
    labels:
      version: v1.0
    trafficPolicy:
      loadBalancer: 
        simple: ROUND_ROBIN
      connectionPool:
        tcp:
          maxConnections: 100
          connectTimeout: 30ms
          tcpKeepalive:
            time: 7200s
            interval: 75s
  - name: v2
    labels:
      version: v2.0

5. Virtual Service ์„ค์ •

Virtual Service๋Š” ์š”์ฒญ์„ ์„œ๋น„์Šค ๋ฉ”์‹œ์— ์ •์˜๋œ ์„œ๋น„์Šค์— ๋งคํ•‘ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ ๊ตฌ์„ฑ ์š”์†Œ์— ๋Œ€ํ•œ ๋ถ„์„์€ Destination Rule์„ ํ†ตํ•ด ์ˆ˜ํ–‰๋ฉ๋‹ˆ๋‹ค. ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์–‘ํ•˜๊ฒŒ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

1) Forwarding
์š”์ฒญ์„ ์„œ๋น„์Šค์— ๊ทธ๋Œ€๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata: 
  name: webservice-vs
spec:
  hosts:
    - web-server
  http:
  - route:
    - destination:
      host: webservice
      subset: v1

์œ„์˜ ์„ค์ •์„ ์ด์šฉํ•˜๊ฒŒ ๋˜๋ฉด ๋ชจ๋“  ์š”์ฒญ์„ webservice์˜ subset v1(v1.0)์œผ๋กœ ๋ผ์šฐํŒ…ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

2) Rewrite
์š”์ฒญ์„ ์žฌ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ์š”์ฒญ์„ ์žฌ์ž‘์„ฑํ•  ๋•Œ์—๋Š” match ์†์„ฑ์„ ํ†ตํ•ด ์žฌ์ž‘์„ฑํ•  ์š”์ฒญ์„ ์ •์˜ํ•˜๊ณ , rewrite ์†์„ฑ์„ ํ†ตํ•ด ์ƒˆ๋กœ์šด URI๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata: 
  name: webservice-vs
spec:
  hosts:
    - web-server
  http:
  - match:
    - headers:
        x-upgrade:
          exact: "TRUE"
    - uri:
      prefix: /hello
    rewrite:
      uri: /
    route:
    - destination:
        host: webservice
        subset: v1

์œ„์˜ ์„ค์ •์„ ์ด์šฉํ•˜๊ฒŒ ๋˜๋ฉด /hello๋กœ ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ ์ค‘ Header์˜ x-upgrade๊ฐ€ TRUE์ธ ์š”์ฒญ์„ ์žฌ์ž‘์„ฑํ•˜์—ฌ subset v1์˜ /๋กœ ์ „์†กํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

3) Weight
Istio๋Š” ์„œ๋น„์Šค ๊ฐ„์˜ ์š”์ฒญ์„ ์ •์˜ํ•œ ๋น„์œจ๋กœ ๋ถ„๋ฐฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์œ„์—์„œ ์„ค์ •ํ•œ v1.0, v2.0์— ๋Œ€ํ•ด 50:50์œผ๋กœ ๋ถ„๋ฐฐํ•˜๋Š” ์„ค์ •์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

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

์ฐธ๊ณ ๋กœ match ์†์„ฑ๊ณผ weight๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค์˜ ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜์—ฌ ์นด๋‚˜๋ฆฌ ๋ฐฐํฌ ๋ฐ ๋ธ”๋ฃจ-๊ทธ๋ฆฐ ๋ฐฐํฌ๋ฅผ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

์ด๋ฒˆ ํ…Œ์ŠคํŠธ์—์„œ๋Š” weight ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜์—ฌ v1๊ณผ v2์— 50:50์˜ ๊ฐ€์ค‘์น˜๋กœ ๋ผ์šฐํŒ…๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Virtual Service๋Š” ์œ„์˜ weight ์„ค์ •์„ ์‚ฌ์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.


6. Test ์ˆ˜ํ–‰

๋จผ์ € ๋ชจ๋“  ๋ฆฌ์†Œ์Šค๋ฅผ Istio๊ฐ€ ์„ค์น˜๋œ Minikube ํด๋Ÿฌ์Šคํ„ฐ์— ๋ฐฐํฌํ•œ ํ›„, Front Application Service๋กœ ์ ‘๊ทผํ•ด์ค๋‹ˆ๋‹ค.

โžœ minikube service frontservice
|-----------|--------------|------------------------|---------------------------|
| NAMESPACE |     NAME     |      TARGET PORT       |            URL            |
|-----------|--------------|------------------------|---------------------------|
| default   | frontservice | http-frontservice/8080 | http://192.168.64.2:31410 |
|-----------|--------------|------------------------|---------------------------|
๐ŸŽ‰  Opening service default/frontservice in default browser...

 

weight๋ฅผ 50:50์œผ๋กœ ์„ค์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์œ„์˜ URL์— ์ ‘์†ํ•˜๋ฉด v1.0๊ณผ v2.0์— ๋Œ€ํ•œ ์‘๋‹ต์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (๊ธ€์„ ์“ฐ๋‹ค๊ฐ€ v2.0 ์บก์ณ ์ „์— minikube cluster๊ฐ€ ๋ฉˆ์ถฐ๋ฒ„๋ ค์„œ ์บก์ณ๋ณธ์€ ์—†์Šต๋‹ˆ๋‹ค... ๋งฅ๋ถ ํ”„๋กœ ์‚ฌ๊ณ  ์‹ถ๋‹ค.....)

v1.0 Response


์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Destination Rule ๋ฐ Virtual Service๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค ๋ฉ”์‹œ์— ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ์— ๋Œ€ํ•œ ๋ผ์šฐํŒ…์— ๋Œ€ํ•ด ์•Œ์•„๋ดค์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, ์ด๋ฒˆ๊ธ€์—์„œ ๋‹ค๋ฃฌ ์ž‘์—…๋“ค์€ ์„œ๋น„์Šค ๋ฉ”์‹œ ๋‚ด๋ถ€์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์š”์ฒญ๋“ค์— ๋Œ€ํ•ด์„œ๋Š” ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ์™ธ๋ถ€์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์š”์ฒญ๋“ค์— ๋Œ€ํ•ด์„œ๋Š” ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์—†๋‹ค๋Š” ๋ฌธ์ œ๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์™ธ๋ถ€ ๊ตฌ์„ฑ ์š”์†Œ๋“ค๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ Istio์˜ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ธ”๋กœ๊ทธ์— ์‚ฌ์šฉ๋œ ๋ชจ๋“  ์˜ˆ์ œ๋Š” Github์—์„œ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


์ฐธ๊ณ ์ž๋ฃŒ

'๐Ÿ”Ž Service Mesh' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Service Mesh] 6. Service Monitoring in Istio  (0) 2021.01.19
[Service Mesh] 5. Istio Traffic Management (2) - Gateway & Service Entry  (0) 2021.01.16
[Service Mesh] 3. Istio?  (0) 2020.12.22
[Service Mesh] 2. Envoy Proxy  (0) 2020.12.21
[Service Mesh] 1. Service Mesh๋ž€?  (0) 2020.12.20

๋Œ“๊ธ€