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

[Service Mesh] 5. Istio Traffic Management (2) - Gateway & Service Entry

by Seongpyo Hong 2021. 1. 16.

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์˜ Virtual Service์™€ Destination Rule์„ ํ†ตํ•œ ์š”์ฒญ ๋ผ์šฐํŒ…์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์•ž์„œ ๊ตฌ์ถ•ํ–ˆ๋˜ ์˜ˆ์ œ๋“ค์€ ๋ชจ๋“  ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด๋ถ€์— ์กด์žฌํ•œ๋‹ค๋ฉด ๋ฌธ์ œ๊ฐ€ ์—†์ง€๋งŒ ์‹ค์ œ๋กœ๋Š” ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ๋„ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด ์™ธ๋ถ€์— ์กด์žฌํ•˜๋Š” DB์— ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ๊ณผ ๊ฐ™์ด ์™ธ๋ถ€ ์ปดํฌ๋„ŒํŠธ์™€๋„ ์ƒํ˜ธ์ž‘์šฉ์ด ๋ฐœ์ƒํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Istio์—์„œ ์–ด๋–ค ๋ฐฉ์‹์œผ๋กœ ์™ธ๋ถ€ ์ปดํฌ๋„ŒํŠธ์™€์˜ ์ƒํ˜ธ์ž‘์šฉ์ด ์ฒ˜๋ฆฌ๋˜๋Š”์ง€ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 


Istio Gateway

Istio์—์„œ ์™ธ๋ถ€์˜ ๋ชจ๋“  ์š”์ฒญ์— ๋Œ€ํ•œ ์ž…๊ตฌ๋Š” Istio Gateway๋ฅผ ํ†ตํ•ด ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. Istio Gateway๋Š” HTTP ๋ฐ TCP ์„œ๋น„์Šค๋ฅผ ๋…ธ์ถœ์‹œํ‚ค๋ฉฐ TLS์™€ ๊ฐ™์€ ๋ณด์•ˆ ๊ด€๋ จ ๊ธฐ๋Šฅ๋„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋ณดํ†ต Istio Gateway๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ Load Balancer Service์™€ ํ•จ๊ป˜ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค. EKS๋‚˜ GKE๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฒฝ์šฐ, ํด๋ผ์šฐ๋“œ ํ”Œ๋žซํผ์˜ L4 ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๊ฐ€ ์ƒ์„ฑ๋˜์–ด ์™ธ๋ถ€์—์„œ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋Š” Public IP๊ฐ€ ๋ถ€์—ฌ๋ฉ๋‹ˆ๋‹ค.

์ƒ์„ฑ๋œ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๊ฐ€ ์š”์ฒญ์„ ๋ฐ›์œผ๋ฉด  Istio Gateway์— ์š”์ฒญ์„ ์œ„์ž„ํ•˜๊ณ  ์ด์ „ ๊ธ€์—์„œ ์„ค๋ช…ํ–ˆ๋˜ ์š”์ฒญ ๋ผ์šฐํŒ…์„ ํ†ตํ•ด ์ ์ ˆํ•œ ์„œ๋น„์Šค์— ์ „์†ก๋ฉ๋‹ˆ๋‹ค. Istio Gateway์™€ Kubernetes Ingress๊ฐ€ ๋น„์Šทํ•œ ๊ธฐ๋Šฅ์„ ํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์ƒ๊ฐํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ Ingress๋Š” ์ž์ฒด์ ์œผ๋กœ ๊ตฌ์„ฑ๋œ ๋ผ์šฐํŒ… ๊ทœ์น™์„ ๊ฐ€์ง€๋Š” ๋ฐ˜๋ฉด์— Gateway๋Š” ๋ผ์šฐํŒ… ๊ทœ์น™์ด ๋‚ด์žฅ๋˜์–ด ์žˆ์ง€ ์•Š๊ณ  Virtual Service๋ฅผ ํ†ตํ•ด ์ด๋ฃจ์–ด์ง„๋‹ค๋Š” ์ฐจ์ด์ ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.


Gateway Tutorial

์•ž์„œ ์‚ฌ์šฉํ–ˆ๋˜ server application๋ฅผ ์‚ฌ์šฉํ•ด์„œ Gateway์— ๋Œ€ํ•œ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

1. Gateway ๊ตฌ์„ฑ

๋จผ์ € Gateway์— ๋Œ€ํ•œ ์„ค์ •์„ ์ง„ํ–‰ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. 

Gateway

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: web-gateway
spec:
  selector:
    app: istio-ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*.greeting.com"

์œ„์˜ ์ฝ”๋“œ์—์„œ selector๋Š” gateway๋ฅผ ์œ„ํ•œ gateway-controller๋ฅผ ์ง€์ •ํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฒˆ ์˜ˆ์ œ์—์„œ๋Š” Istio์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์น˜๋˜๋Š” Istio-ingressgateway๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ์ง€์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์œ„์˜ ๋ฉ”๋‹ˆํŽ˜์ŠคํŠธ๋ฅผ ์ ์šฉํ•˜๋ฉด Host์˜ ํ•˜์œ„ ๋„๋ฉ”์ธ์ด greeting.com์ด๋ฉฐ 80๋ฒˆ ํฌํŠธ๋กœ ๋“ค์–ด์˜ค๋Š” HTTP ํŠธ๋ž˜ํ”ฝ์„ ๋ฉ”์‹œ๋กœ ๋ฐ›๊ฒŒ๋ฉ๋‹ˆ๋‹ค.


2. Virtual Service ๊ตฌ์„ฑ

Gateway์—์„œ ์™ธ๋ถ€ ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›์•˜๋‹ค๋ฉด ์ด๋ฅผ ๋ฉ”์‹œ ๋‚ด๋ถ€์—์„œ ๋ผ์šฐํŒ…ํ•˜๊ธฐ ์œ„ํ•œ Virtual Service๋ฅผ ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฒˆ์—๋Š” v1/v2 subset์— ๋Œ€ํ•ด 80:20์˜ ๊ฐ€์ค‘์น˜ ๋น„์œจ๋กœ ๋ผ์šฐํŒ… ๋˜๋„๋ก ์„ค์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Virtual Service

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: webservice-vs
spec:
  hosts:
  - webservice
  - webservice.greeting.com
  gateways:
  - web-gateway
  http:
  - route:
    - destination:
        host: webservice
        subset: v1
      weight: 80
    - destination:
        host: webservice
        subset: v2
      weight: 20

์ฒ˜๋ฆฌํ•˜๊ณ ์ž ํ•˜๋Š” ๊ฒŒ์ดํŠธ์›จ์ด๋ฅผ gateways: ํ•„๋“œ์— ์ถ”๊ฐ€ํ•˜๊ณ , gateway์—์„œ ์ •์˜ํ–ˆ๋˜ host์™€ ์ผ์น˜ํ•˜๊ฑฐ๋‚˜ ์ผ๋ถ€์— ์†ํ•˜๋„๋ก ํ˜ธ์ŠคํŠธ ๋ชฉ๋ก์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. 


3. Traffic Management Test

์œ„์˜ Gateway, Virtual Service๊ณผ Server Application์„ ํ†ตํ•ด ๊ตฌ์ถ•ํ•œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ…Œ์ŠคํŠธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ €๋Š” Minikube๋ฅผ ์‚ฌ์šฉํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— Cloud Provider์—์„œ ์ œ๊ณตํ•ด์ฃผ๋Š” ๊ฒƒ๊ณผ ๊ฐ™์ด Load Balancer์— External IP๋ฅผ ํ• ๋‹นํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

 

External IP๊ฐ€ Pending ์ƒํƒœ์ด๋‹ค.

 

 

ํ•˜์ง€๋งŒ minikube service istio-ingressgateway -n istio-system์„ ํ†ตํ•ด ์™ธ๋ถ€์—์„œ ์ด ์„œ๋น„์Šค์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ค๋‹ˆ๋‹ค.

 

Minikube Service

 

์šฐ๋ฆฌ๊ฐ€ ์„ค์ •ํ•œ Gateway๋Š” 80 ํฌํŠธ์— ๋Œ€ํ•ด ์—ด๋ ค์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด์— ํ•ด๋‹นํ•˜๋Š” http://192.168.64.2:30829๋กœ ์ ‘๊ทผ์„ ์‹œ๋„ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ Gateway์—์„œ Host ์„ค์ •์œผ๋กœ ํ•˜์œ„ ๋„๋ฉ”์ธ์ด"greeting.com"์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์œ„ ๋„๋ฉ”์ธ์„ ์„ค์ •ํ•  ์ˆ˜๋Š” ์—†์ง€๋งŒ gateway์—์„œ๋Š” ํ—ค๋”์— ์กด์žฌํ•˜๋Š” Host ํ•„๋“œ๋ฅผ ํ™•์ธํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ์š”์ฒญ์„ ๋ณด๋‚ด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. (10๋ฒˆ์˜ ์š”์ฒญ ๊ฒฐ๊ณผ๋ฅผ output.txt์— ์ €์žฅํ•˜๋Š” shell script๋ฅผ ์ด์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.)

Shell Script

#!/bin/bash

for num in `seq 1 10`
do 
    curl -v -HHost:webservice.greeting.com http://192.168.64.2:30829/ | tail -1 >> ~/output.txt
done

 

Output
Virtual Service์—์„œ ๊ฐ€์ค‘์น˜๋ฅผ 80:20์œผ๋กœ ์„ค์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— 10๋ฒˆ์˜ ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด 8๋ฒˆ์˜ v1๊ณผ 2๋ฒˆ์˜ v2์ด ์‘๋‹ต๋ฉ๋‹ˆ๋‹ค. 

โžœ  ~  tail -f output.txt
 version : 1.0 
 version : 2.0 
 version : 1.0 
 version : 1.0 
 version : 1.0 
 version : 2.0 
 version : 1.0 
 version : 1.0 
 version : 1.0 
 version : 1.0 

 

์ฃผ์˜ํ•  ์ ์€ Gateway ์„ค์ •์ด ์ถ”๊ฐ€๋œ Virtual Service๋ฅผ ๊ตฌ์„ฑํ•  ๋•Œ, gateways: ํ•„๋“œ์— mesh ํ‚ค์›Œ๋“œ๊ฐ€ ์—†๋‹ค๋ฉด ์™ธ๋ถ€ ์š”์ฒญ์ด ์•„๋‹Œ ์„œ๋น„์Šค ๋ฉ”์‹œ ๋‚ด๋ถ€์ ์œผ๋กœ ๋ฐœ์ƒํ•˜๋Š” ์„œ๋น„์Šค์— ๋Œ€ํ•ด์„œ๋Š” Virtual Service๊ฐ€ ์ ์šฉ๋˜์ง€ ์•Š๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์œ„์˜ ์„ค์ •์—์„œ mesh ํ‚ค์›Œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ตฌ์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: webservice-vs
spec:
  hosts:
  - webservice
  - webservice.greeting.com
  gateways:
  - web-gateway
  - mesh
  http:
  - route:
    - destination:
        host: webservice
        subset: v1
      weight: 80
    - destination:
        host: webservice
        subset: v2
      weight: 20

Outbound Traffic

์ง€๊ธˆ๊นŒ์ง€ Istio Gateway๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€ ์š”์ฒญ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์„œ๋น„์Šค๋ฅผ ์šด์˜ํ•˜๋ฉด์„œ ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์˜ ์„œ๋น„์Šค์— ์—‘์„ธ์Šค ํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ๋Š” ๋ถ„๋ช… ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ Istio๋Š” ์™ธ๋ถ€ ์„œ๋น„์Šค์— ์ ‘๊ทผํ•˜๋Š” ์‹œ๋„๋ฅผ ์ œํ•œํ•˜์ง€ ์•Š์ง€๋งŒ, ๋ณด์•ˆ๊ณผ ๊ฐ™์€ ์ด์Šˆ๋กœ ์ธํ•ด Outbound ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•ด ์ œ์–ดํ•  ํ•„์š”๊ฐ€ ๋ถ„๋ช… ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด Istio๋Š” outbound ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•ด 2๊ฐ€์ง€ ์ •์ฑ…์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ๊ฐ’์ธ ALLOW_ANY๋Š” ๋ฉ”์‹œ์— ๋“ฑ๋ก๋˜์ง€ ์•Š์€ ์„œ๋น„์Šค๋ผ๋„ ์ฒ˜๋ฆฌ๋˜๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•˜๊ณ , REGISTRY_ONLY๋Š” ๋“ฑ๋ก๋˜์ง€ ์•Š์€ ์„œ๋น„์Šค๋ผ๋ฉด block ๋˜๋Š” ์ •์ฑ…์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ALLOW_ANY๋Š” ์š”์ฒญ์ด ์ฒ˜๋ฆฌ๋˜๊ธด ํ•˜์ง€๋งŒ ๋“ฑ๋ก๋˜์ง€ ์•Š์€ ์„œ๋น„์Šค๋Š” ํ”„๋ก์‹œ๋ฅผ ๊ฑฐ์น˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜(Pod) ๋„คํŠธ์›Œํฌ์—์„œ ๋ฐ”๋กœ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 

Naver ์ ‘์† ๊ฐ€๋Šฅ ํ™•์ธ (ALLOW_ANY)

 

์ด์™€ ๋ฐ˜๋Œ€๋กœ Istio์˜ ConfigMap ์ค‘ outbound ์„ค์ •์„ REGISTRY_ONLY๋กœ ๋ณ€๊ฒฝํ•œ ํ›„ ๋‹ค์‹œ ํ…Œ์ŠคํŠธํ•˜๋ฉด ์ ‘๊ทผํ•  ์ˆ˜ ์—†๋‹ค๋Š” ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

Service Entry

๋ฌผ๋ก  ๋ฉ”์‹œ ๋‚ด๋ถ€์˜ ์„œ๋น„์Šค๋ฅผ ๋“ฑ๋กํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ฉ”์‹œ ์™ธ๋ถ€์˜ ์„œ๋น„์Šค๋ฅผ registry์— ๋“ฑ๋กํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฐ ๊ธฐ๋Šฅ์„ ๋‹ด๋‹นํ•˜๋Š” ๋ฐฉ๋ฒ•์„ Service Entry๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ALLOW_ANY ๋ชจ๋“œ์—์„œ๋„ ๋ถ„๋ช… ์™ธ๋ถ€๋กœ์˜ ์š”์ฒญ์€ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ํŠธ๋ž˜ํ”ฝ ๊ด€๋ฆฌ๋Š” ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Service Entry๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค๋ฅผ ๋“ฑ๋กํ•˜๋ฉด Sidecar Proxy๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€๋กœ ์š”์ฒญ์ด ๋ณด๋‚ด์ง€๊ณ  ์ด๋กœ ์ธํ•ด ์„œ๋น„์Šค ๋ฉ”์‹œ๋Š” ํŠธ๋ž˜ํ”ฝ ๊ด€๋ฆฌ๋ฅผ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: naver
spec:
  hosts:
  - www.naver.com
  ports:
  - number: 443
    name: https
    protocol: HTTPS
  resolution: DNS
  location: MESH_EXTERNAL

๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค๋ช…ํ•˜๋ฉด ์„œ๋น„์Šค์— ๋Œ€ํ•œ host, port๋ฅผ ์„ค์ •ํ•˜๊ณ  resolution์„ ํ†ตํ•ด address ์กฐํšŒ ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค. ์œ„์˜ ์„ค์ •์€ DNS ๊ธฐ๋ฐ˜์„ ์‚ฌ์šฉํ•˜์˜€๊ณ  ์ •์ ์œผ๋กœ ๊ตฌ์„ฑํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. location์€ ์„œ๋น„์Šค์˜ ์œ„์น˜๋ฅผ ๋‚˜ํƒ€๋‚ด๊ณ  naver.com์€ ๋ฉ”์‹œ ์™ธ๋ถ€์— ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— MESH_EXTERNAL๋กœ ์„ค์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค. 


Egress Gateway

Service Entry๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€ ์„œ๋น„์Šค์— ๋Œ€ํ•œ ์ œํ•œ์„ ๋‘˜ ์ˆ˜๋Š” ์žˆ์ง€๋งŒ, ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์™ธ๋ถ€ ์„œ๋น„์Šค์— ๋Œ€ํ•ด์„œ๋Š” ๋ฉ”์‹œ ๋‚ด๋ถ€์˜ ๋ชจ๋“  ์„œ๋น„์Šค๊ฐ€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, ์™ธ๋ถ€ ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•œ ์ธ์ฆ ๊ทœ์น™์ด๋‚˜ ๊ถŒํ•œ์— ๋Œ€ํ•œ ๊ฒ€์‚ฌ๋ฅผ ์œ„ํ•ด Ingress Gateway์™€ ๊ฐ™์ด ์™ธ๋ถ€๋กœ ๋‚˜๊ฐ€๋Š” ๋ชจ๋“  ์š”์ฒญ์ด ๊ฑฐ์น˜๋Š” ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด Istio์—์„œ๋Š” Egress Gateway๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

Egress Gateway

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: naver-egressgateway
spec:
  selector:
    app: istio-egressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "www.naver.com"

Egress Gateway์—์„œ ๋ฐ›์€ ์š”์ฒญ์— ๋Œ€ํ•ด ๋ผ์šฐํŒ… ๊ทœ์น™์„ ์ •์˜ํ•˜๋Š” Virtual Service๋„ ์ƒ์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

Virtual Service

apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: naver-egress-gateway
spec:
  hosts:
  - www.naver.com
  gateways:
  - naver-egressgateway
  - mesh
  http:
  - match:
    - gateways:
      - mesh
      port: 80
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
        port:
          number: 80
      weight: 100
  - match:
    - gateways:
      - naver-egressgateway
      port: 80
    route:
    - destination:
        host: www.naver.com
        port:
          number: 80
      weight: 100

์œ„์˜ Virtual Service๋Š” www.naver.com์— ๊ด€ํ•œ ๋ชจ๋“  ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. mesh(sidecar proxy)์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์š”์ฒญ์€ istio-egressgateway๋กœ ๋ผ์šฐํŒ…๋˜๊ณ , egressgateway์— ๊ด€ํ•œ ์š”์ฒญ์€ Service Entry์—์„œ ๋“ฑ๋กํ•œ ์„œ๋น„์Šค ํฌํŠธ ๋ฐ ํ˜ธ์ŠคํŠธ์™€ ์ผ์น˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— sidecar proxy๋ฅผ ๊ฑฐ์ณ www.naver.com์œผ๋กœ ๋ผ์šฐํŒ… ๋ฉ๋‹ˆ๋‹ค. ์ฆ‰, www.naver.com๋กœ ๋‚˜๊ฐ€๋Š” ๋ชจ๋“  ์š”์ฒญ์ด egress-gateway๋ฅผ ๊ฑฐ์ณ ๋‚˜๊ฐ€๊ฒŒ ๋˜๋ฉฐ ์ด๋ฅผ ํ†ตํ•ด ์™ธ๋ถ€ ์—ฐ๊ฒฐ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ธฐ์— ์šฉ์ดํ•œ ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Istio Ingress๋ฅผ ํ†ตํ•œ ์™ธ๋ถ€ ์š”์ฒญ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•๊ณผ Egress Gateway & Service Entry๋ฅผ ํ†ตํ•œ ์™ธ๋ถ€ ์„œ๋น„์Šค ์š”์ฒญ ์ œ์–ด ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ๊ธ€์—์„œ๋Š” Istio ์—์„œ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฉ”ํŠธ๋ฆญ์„ ์–ด๋–ป๊ฒŒ ์ˆ˜์ง‘ํ•˜๋Š”์ง€์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

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


์ฐธ๊ณ ์ž๋ฃŒ

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

[Service Mesh] 7. Logging  (0) 2021.01.28
[Service Mesh] 6. Service Monitoring in Istio  (0) 2021.01.19
[Service Mesh] 4. Istio Traffic Management (1) - Virtual Service & Destination Rule  (0) 2021.01.14
[Service Mesh] 3. Istio?  (0) 2020.12.22
[Service Mesh] 2. Envoy Proxy  (0) 2020.12.21

๋Œ“๊ธ€