Istio์˜ edge proxy์ธ Ingress Gateway์— ๋Œ€ํ•ด ๊ผผ๊ผผํ•˜๊ฒŒ ์‚ดํŽด๋ณด๊ธฐ! ๐Ÿ•ต๏ธ Mesh Gateway๋ž‘์€ ๋ญ๊ฐ€ ๋‹ค๋ฅธ ๊ฑธ๊นŒ?

13 minute read

Ingress Gateway๋ž€?

bookinfo ์˜ˆ์ œ์—์„œ ๋งŒ๋“  VirtualService์™€ DestinationRule์€ K8s ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด๋ถ€์—์„œ ํ๋ฅด๋Š” ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” ๋ฆฌ์†Œ์Šค์ด๋‹ค.

๊ทธ๋Ÿผ istio ๋„คํŠธ์›Œํฌ ์ƒ์—์„œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ K8s ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€๋กœ ๋…ธ์ถœ ํ•˜๋ ค๊ณ  ํ•œ๋‹ค๋ฉด, ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ??

K8s Ingress๋ž‘ ์ด๋ฆ„์ด ๋น„์Šทํ•˜๋„ค์š”

์ผ๋‹จ ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ K8s Service๋‚˜ K8s Ingress๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด๋ ‡๊ฒŒ ์ ‘๊ทผํ•˜๋ฉด, VirtualService์™€ DestinationRule๋กœ ์„ค์ •ํ•œ ๋„คํŠธ์›Œํฌ ๊ทœ์น™์ด ์ ์šฉ ๋˜์ง€ ์•Š๋Š”๋‹ค.

์™œ๋ƒํ•˜๋ฉด, K8s Ingress์™€ K8s Service์—์„œ ๋“ค์–ด์˜ค๋Š” ๋„คํŠธ์›Œํฌ ํŠธ๋ž˜ํ”ฝ์€ istiod๊ฐ€ ์•„๋‹ˆ๋ผ K8s ์ปจํŠธ๋กคํ”Œ๋ ˆ์ธ์˜ kube-proxy๋ฅผ ํ†ตํ•ด ์ œ์–ด๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!

Istio์—๋Š” Ingress Gateway๋ผ๋Š”๊ฒŒ ์žˆ์Šต๋‹ˆ๋‹ค.

Istio์˜ vs, dr์˜ ๊ทœ์น™์„ ๋”ฐ๋ฅด๊ฒŒ ํ•˜๋ ค๋ฉด ๋ฐฉ๋ฒ•์€ ๊ฐ„๋‹จํ•˜๋‹ค.

Envoy Proxy๊ฐ€ ๋„คํŠธ์›Œํฌ ์š”์ฒญ์„ ํ•˜๊ฒŒ ํ•˜๋ผ!

๊ทธ๋ž˜์„œ Istio๋Š” Envoy Proxy ์ปจํ…Œ์ด๋„ˆ ํ•˜๋‚˜๋งŒ ์žˆ๋Š” Ingress Gateway๋ผ๋Š” ์ด๋ฆ„์˜ ๋ฆฌ์†Œ์Šค๋ฅผ ์ •์˜ํ–ˆ๋‹ค!!!

Istio๋Š” ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์—์„œ ๋“ค์–ด์˜ค๋Š” ๋ชจ๋“  ์š”์ฒญ์„ ์š” Ingress Gateway์— ์œ„์ž„ํ•œ๋‹ค.

์œ„์˜ ๊ทธ๋ฆผ์„ ๋ณด๋ฉด, Ingress Gateway๋„ โ€œEnvoy Proxyโ€๊ฐ€ ์žˆ๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋‹ค๋ฅธ Application๊ณผ ๋‹ค๋ฅด๊ฒŒ Service์˜ ์ปจํ…Œ์ดํ„ฐ๋Š” ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค!! ์˜ค์ง Envoy Proxy ์ปจํ…Œ์ด๋„ˆ๋งŒ ๋‹จ๋…์œผ๋กœ ์กด์žฌํ•œ๋‹ค!!

Ingress Gateway๋Š” ์–ด๋–ป๊ฒŒ ์“ฐ๋‚˜์š”?

์š” ingress gateway๋ผ๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด, istio์˜ Gateway๋ผ๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ ์ •์˜ ํ•˜๋Š”๋ฐ

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  # The selector matches the ingress gateway pod labels.
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 8080 # ์š” ํฌํŠธ ๋ฒˆํ˜ธ์— ๋Œ€ํ•œ ์„ค๋ช…์€ ๋’ค์—์„œ ํ•œ๋‹ค!
      name: http
      protocol: HTTP
    hosts:
    - "*"
  • ์–ด๋–ค ingress gateway๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›์„์ง€
  • ์–ด๋–ค ํฌํŠธ์—์„œ (๋’ค์—์„œ ๋” ์ž์„ธํžˆ ์„ค๋ช…)
  • ์–ด๋–ค ํ˜ธ์ŠคํŠธ์—์„œ ์š”์ฒญ์ด ๋“ค์–ด์˜ฌ ๊ฑด์ง€ (์š”๊ฒƒ๋„ ๋’ค์—์„œ ๋” ์ž์„ธํžˆ ์„ค๋ช…!)

์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์ ์–ด์ค€๋‹ค.

์š”๋ ‡๊ฒŒ istio Gateway ๋ฆฌ์†Œ์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ๋‚˜๋ฉด, ์ด์ œ ์š” Gateway ๋ฆฌ์†Œ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ViratualService๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์ค˜์•ผ ํ•œ๋‹ค.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo
spec:
  hosts:
  - "*"
  gateways: # ์š”๊ธฐ์— ์ ์–ด์ค€๋‹ค!
  - bookinfo-gateway
  http:
    ...

์ด VirtualService๋Š” Ingress Gateway๋กœ ๋“ค์–ด์˜จ ํŠธ๋ž˜ํ”ฝ์„ ์–ด๋–ค ๊ณณ์œผ๋กœ ๋ผ์šฐํŒ… ํ• ์ง€๋ฅผ ๊ทœ์น™์ด ์ ํ˜€ ์žˆ๋‹ค. ์ด ๊ทœ์น™๋“ค์„ Ingress Gateway์˜ Envoy Proxy์—์„œ ํŠธ๋ž˜ํ”ฝ์ด ๋‚˜๊ฐˆ ๋•Œ evaluate ๋œ๋‹ค.

Mesh gateway์™€ ๋น„๊ต

Ingress GW์™€ (๊ณง ์‚ดํŽด๋ณผ) Egress GW๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” Envoy Proxy๋Š” ํŠน์ˆ˜ํ•œ ์—ญํ• ์„ ํ•œ๋‹ค. ๊ทธ๋ž˜์„œ ์ด๋“ค์— ๋Œ€ํ•ด์„œ๋Š” spec.gateways์— ์ง์ ‘ Gateway ๋ฆฌ์†Œ์Šค๋ฅผ ๋ช…์‹œํ•ด์„œ ๊ทธ๋“ค์ด ์‚ฌ์šฉํ•˜๋Š” VirtualService๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

๋ฌผ๋ก  ์ด๋ ‡๊ฒŒ ์“ฐ๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
spec:
  gateways:
  - bookinfo-gateway
  - mesh # mesh gateway๋„ ๊ฐ™์ด ์ ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค!
  http:
    ...

์ด๋•Œ โ€œmesh gatewayโ€๋ž€ Ingress/Egress GW๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” Envoy Proxy๋ฅผ ์ œ์™ธํ•œ Istio Service Mesh ๋‚ด์— ์กด์žฌํ•˜๋Š” ๋‹ค๋ฅธ ๋ชจ๋“  Envoy Proxy๋ฅผ ๋งํ•œ๋‹ค.

์ฒ˜์Œ VirtualService๋ฅผ ๋ฐฐ์šธ ๋•Œ๋Š” Service Mesh ๋‚ด๋ถ€์—์„œ์˜ ํŠธ๋ž˜ํ”ฝ๋งŒ์„ ์ œ์–ดํ•˜๊ธฐ ๋•Œ๋ฌธ์— spec.gateways์— ์•„๋ฌด๊ฒƒ๋„ ์ ์ง€ ์•Š์•˜๋‹ค. ์•„๋ฌด๊ฒƒ๋„ ์•ˆ ์ ์œผ๋ฉด mesh gateway๊ฐ€ ๊ธฐ๋ณธ์œผ๋กœ ๋“ค์–ด๊ฐ„๋‹ค.

Ingress Gateway๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ๋‹ค!

ํ์Œโ€ฆ ๋ฐฉ๋ฒ•์„ ์ฐพ๋Š”๊ฒŒ ๊ฝค ์–ด๋ ค์› ๋‹คโ€ฆ (โ•ฅ๏นโ•ฅ)

์ผ๋‹จ Istio ์„ค์น˜ ๋•Œ ์ž๋™์œผ๋กœ ์„ค์น˜ํ•˜๋Š” Ingress Gateway ์™ธ์— ์ถ”๊ฐ€ Ingress GW๋ฅผ ๋„์šฐ๊ณ  ์‹ถ๋‹ค๋ฉด, IstioOperator ๋ฆฌ์†Œ์Šค๋ฅผ ์ˆ˜์ •ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

Istio๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ istioctl, helm chart๋กœ ์„ค์น˜ํ•˜๊ธฐ, Istio Operator๋กœ ์„ค์น˜ํ•˜๊ธฐ ๋“ฑ ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์ด ์žˆ์ง€๋งŒ, ์—ฌ๊ธฐ์„œ๋Š” istioctl์™€ Istio Operator๋ฅผ ์‚ฌ์šฉํ•ด์„œ Ingress GW๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๊ฒ ๋‹ค.

์ผ๋‹จ, ์šฐ๋ฆฌ๊ฐ€ IstioOperator ๋ฆฌ์†Œ์Šค๋ฅผ ์ˆ˜์ • ํ–ˆ์„ ๋•Œ, ๊ทธ๊ฑธ ๋ฐ˜์˜ํ•ด์„œ ๋„์›Œ ์ค„ IstioOperator ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ๋„์›Œ์•ผ ํ•œ๋‹ค.

$ istioctl operator init

์š”๋ ‡๊ฒŒ ํ•˜๋ฉด, ์ด์ œ istio-operator๋ผ๋Š” ns์— IstioOperator ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ๋œฌ๋‹ค! (๊ทธ๋Ÿฐ๋ฐ ์ด๋ฆ„์€ istio-operator-xxx์ด๋‹ˆ ์ฃผ์˜!)

์ข‹๋‹ค! ์ด์ œ IstioOperator๋ฅผ ์ˆ˜์ •ํ•ด๋ณด์ž! ์•„๋ž˜ ๋ช…๋ น์–ด๋กœ ๋ฆฌ์†Œ์Šค๋ฅผ ํ™•์ธํ•œ๋‹ค.

$ kubectl get istiooperator -n istio-system

๊ทธ๋ฆฌ๊ณ  ์กด์žฌํ•˜๋Š” IstioOperator ๋ฆฌ์†Œ์Šค๋ฅผ ์ˆ˜์ •ํ•˜๋Š”๋ฐโ€ฆ

๋จผ์ € annotations์— ์žˆ๋Š” install.istio.io/ignoreReconcile์„ false๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค. ์š”๊ฑธ ๋ฐ”๊พธ์ง€ ์•Š์œผ๋ฉด ๋ฆฌ์†Œ์Šค๋ฅผ ์ˆ˜์ •ํ•ด๋„ IstioOperator ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ๋ฐ˜์˜์„ ์•ˆ ํ•œ๋‹ค!

๊ทธ๋ฆฌ๊ณ  spc.components.ingressGateways ํ•ญ๋ชฉ์—์„œ ์ƒˆ๋กœ์šด Ingress GW๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์ž!

์ด๋•Œ ์ฃผ์˜ํ•  ์ ์€ label.istio๋„ ๊ฐ™์ด ์„ค์ •ํ•ด์ค˜์•ผ ํ•œ๋‹ค! ๋งŒ์•ฝ ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด, default ingress gateway๋ž‘ ๊ฐ™์€ label.istio = "ingressgateway"๋ฅผ ์“ฐ๊ฒŒ ๋˜์–ด์„œ ๋‘ Ingress GW๊ฐ€ ์ œ๋Œ€๋กœ ๋ถ„๋ฆฌ ๋˜์ง€ ์•Š๊ฒŒ ๋œ๋‹ค!

์•ผํ˜ธ!! ์ƒˆ๋กœ์šด Ingress GW๊ฐ€ ์ž˜ ๋–ด๋‹ค!! เดฆเตเดฆเดฟ ห‰อˆฬ€๊’ณห‰อˆฬ )โœง


Ingress Gateway ๋” ์ž์„ธํžˆ ์‚ดํŽด๋ณด๊ธฐ

Gateway์˜ port์™€ IngressGateway์˜ containerPort

์šฐ์„ , ์‹ค์Šต์—์„œ ์‚ฌ์šฉํ–ˆ๋˜ Gateway์™€ VirtualService์˜ yaml ํŒŒ์ผ๋ถ€ํ„ฐ ๋‹ค์‹œ ๋ณด์ž!!

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  # The selector matches the ingress gateway pod labels.
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 8080 # ์š”๊ธฐ!
      name: http
      protocol: HTTP
    hosts:
    - "*"
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo
spec:
  hosts:
  - "*"
  gateways:
  - bookinfo-gateway
  http:
  - match:
    - uri:
        exact: /productpage
    ...
    route:
    - destination:
        host: productpage
        port:
          number: 9080 # ์š”๊ธฐ!!

๋‘˜์„ ๋น„๊ต ํ–ˆ์„ ๋•Œ ์ดํ•ด๊ฐ€ ์•ˆ ๋˜๋Š” ๋ถ€๋ถ„์€ ๋ฐ”๋กœ ๋‘˜์˜ port ๋ถ€๋ถ„์ด๋‹ค. Gateway๋Š” 8080 ํฌํŠธ๋ฅผ, VirtualService๋Š” 9080 ํฌํŠธ๋กœ ์„œ๋กœ ๋‹ค๋ฅธ ํฌํŠธ๋ฅผ ๋ช…์‹œํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!

์ผ๋‹จ Gateway ๋ฆฌ์†Œ์Šค์˜ port๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ณ€๊ฒฝํ•ด๋ณด์•˜๋‹ค.

  • 8080 โ†’ 7070์œผ๋กœ ๋ณ€๊ฒฝ: โŒ
  • 8080 โ†’ 9090์œผ๋กœ ๋ณ€๊ฒฝ: โŒ

์˜ค์ง 8080์œผ๋กœ ์„ค์ • ํ–ˆ์„ ๋•Œ๋งŒ, Gateway๋ฅผ ํ†ตํ•œ ๋ผ์šฐํŒ…์ด ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๋˜์—ˆ๋‹ค!! ๋„๋Œ€์ฒด ์™œ์ผ๊นŒ!! /(โ€˜-โ€˜)/


์ผ๋‹จ ๊ฒฐ๋ก ๋ถ€ํ„ฐ ๋งํ•˜๋ฉด, istio-system ns์— ๋– ์žˆ๋Š” default IngressGateway Pod์—์„œ ํŠน์ • ํฌํŠธ๋“ค๋งŒ ํ—ˆ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!!

์˜ค์ง ์•„๋ž˜ ๋‘ ํฌํŠธ์˜ ๊ฒฝ์šฐ๋กœ ์„ค์ •ํ–ˆ์„ ๋•Œ๋งŒ Gateway๊ฐ€ ์ œ๋Œ€๋กœ ๋™์ž‘ํ•œ๋‹ค.

  • 8080์™€ 80(http) ํฌํŠธ
  • 8443์™€ 443(https) ํฌํŠธ

์ผ๋‹จ ๊ทธ ์ด์œ ๋Š” IngressGateway์˜ containerPort์™€ Service์— ์žˆ๋‹ค.


IngressGateway Pod์˜ ์ •๋ณด๋ฅผ ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ • ๋˜์–ด ์žˆ๋‹ค.

# default ingress gateway pod
...
image: docker.io/istio/proxyv2:1.20.2
imagePullPolicy: IfNotPresent
name: istio-proxy
ports:
- containerPort: 15021
  protocol: TCP
- containerPort: 8080
  protocol: TCP
- containerPort: 8443
  protocol: TCP
- containerPort: 15090
  name: http-envoy-prom
  protocol: TCP
...

IngressGateway Service์˜ ์ •๋ณด๋ฅผ ๋ณด๋ฉด ์š”๋ ‡๋‹ค.

# default ingress gateway service
...
ports:
  - name: status-port
    nodePort: 31782
    port: 15021
    protocol: TCP
    targetPort: 15021
  - name: http2
    nodePort: 32514
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    nodePort: 32051
    port: 443
    protocol: TCP
    targetPort: 8443
...

์ฆ‰, ์šฐ๋ฆฌ๊ฐ€ ๋งŒ๋“  Gateway๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” default ingressGateway์˜ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ 8080๊ณผ 8443 ํฌํŠธ๋งŒ ์—ด๋ ค ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, Gateway๋„ 8080 ํฌํŠธ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒƒ์ด๋‹ค.

The specification describes a set of ports that should be exposed, the type of protocol to use, SNI configuration for the load balancer, etc.

Gateway ๋ฆฌ์†Œ์Šค์— ๋ช…์‹œ๋œ port๋Š” ingressGateway์—์„œ ๋“ค์–ด์˜ค๋Š” ๋ชฉ์ ์œผ๋กœ๋„ ์‚ฌ์šฉํ•˜์ง€๋งŒ, ๋ฐ˜๋Œ€๋กœ Gateway๋ฅผ ์‚ฌ์šฉํ•ด ์„œ๋น„์Šค๋ฅผ ์™ธ๋ถ€์— ๋…ธ์ถœํ•  ๋•Œ๋„ ์‚ฌ์šฉํ•œ๋‹ค. (๋‹จ, ์ด ๊ฒฝ์šฐ์™€ Egress Gateway๋Š” ๋‹ค๋ฅธ ๊ฐœ๋…์ด๋‹ˆ ์ฃผ์˜!)

host-port ์กฐํ•ฉ์€ ํ•˜๋‚˜์˜ Gateway๋งŒ ๊ฐ€๋Šฅ

์ด๋ฒˆ์—๋Š” Bookinfo ์˜ˆ์ œ๋ฅผ default ns์—๋„ ๋„์šฐ๊ณ , test ns์—๋„ ๋„์›Œ๋ณด์ž!! ๐Ÿ“˜๐Ÿ“™

๊ทธ๋ฆฌ๊ณ  ๋‘˜๋‹ค ๋ชจ๋‘ istio์˜ default ingress-gateway๋ฅผ ์‚ฌ์šฉํ•ด Gateway ๋ฆฌ์†Œ์Šค๋ฅผ ์™ธ๋ถ€์— ๋…ธ์ถœ ํ•ด๋ณด์ž!

default ns์—๋Š” ์ด๋ฏธ bookinfo ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋„์› ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ณ , test ns์— bookinfo ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋„์›Œ๋ณด๊ฒ ๋‹ค.

$ kubectl create ns test
$ kubectl label ns test istio-injection=enabled
$ kubectl apply -n test -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/bookinfo/platform/kube/bookinfo.yaml
$ kubectl apply -n test -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/bookinfo/networking/bookinfo-gateway.yaml

๊ทธ๋Ÿฐ๋ฐ ์ด๋ ‡๊ฒŒ ๋„์šฐ๊ฒŒ ๋˜๋ฉด, ์ด์ƒํ•˜๊ฒŒ๋„ test ns์— ๋„์šด bookinfo ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—๋Š” ์ ‘์†์ด ์•ˆ ๋œ๋‹ค!!!

๊ทธ๋ฆฌ๊ณ  Kiali์—์„œ ์ด๋Ÿฐ ์—๋Ÿฌ๋„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

KIA0301: More than one Gateway for the same host port combination

์ฆ‰, ํ•˜๋‚˜์˜ ingress-gateway์—์„œ ์–ด๋–ค Gateway๊ฐ€ (host, port)์˜ ์Œ์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฉด, ๋‚˜์ค‘์— ์ƒ๊ธด ๋‹ค๋ฅธ Gateway๋Š” ๊ทธ ์Œ์„ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•œ๋‹ค!

์ด ๊ฒฝ์šฐ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด,

  • ๋‹ค๋ฅธ ingress-gateway๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ
  • ingress-gateway์˜ ๋‹ค๋ฅธ containerPort ์‚ฌ์šฉํ•˜๊ธฐ (ex: 9443)

์˜ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.

Ingress๋กœ ํŠน์ • host ์ฃผ์†Œ๋กœ ๋“ค์–ด์˜ค๋Š” ํŠธ๋ž˜ํ”ฝ ํ•ธ๋“ค๋งํ•˜๊ธฐ

์šฐ๋ฆฌ๊ฐ€ Gateway ๋ฆฌ์†Œ์Šค๋ฅผ ์ฒ˜์Œ ๋งŒ๋“ค ๋•, ์•„๋ž˜์™€ ๊ฐ™์ด hosts๋ฅผ ์™€์ผ๋“œ์นด๋“œ "*"๋กœ ์„ค์ • ํ–ˆ์—ˆ๋‹ค.

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  servers:
  - ...
    hosts:
    - "*" # ์™€์ผ๋“œ์นด๋“œ!

๊ทธ๋Ÿฐ๋ฐ ์š”๊ธฐ์— ํŠน์ • host ์ฃผ์†Œ๋ฅผ ๋„ฃ์–ด์„œ ํ•ด๋‹น ์ฃผ์†Œ๋กœ๋งŒ ์˜ค๋Š” ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›์„ ์ˆ˜๋„ ์žˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์ด ๋ง์ด๋‹ค!

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  servers:
  - ...
    hosts:
    - "mybookinfo.com" # host๋ฅผ ๋ช…์‹œํ–ˆ๋‹ค!

์ด๋ ‡๊ฒŒ ํ•  ๊ฒฝ์šฐ, mybookinfo.com๋ผ๋Š” ์ฃผ์†Œ๋กœ ๋“ค์–ด์˜จ ํŠธ๋ž˜ํ”ฝ๋งŒ Gateway ๋ฆฌ์†Œ์Šค๊ฐ€ ํ•ธ๋“ค๋งํ•˜๊ฒŒ ๋œ๋‹ค!

๋ณธ์ธ์€ ๋กœ์ปฌ ๋งฅ๋ถ์—์„œ Rancher Desktop์œผ๋กœ K8s ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๋Œ๋ ค ์‹คํ—˜ํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ด๋ ‡๊ฒŒ Gateway ๋ฆฌ์†Œ์Šค์— Host๋ฅผ ๋ช…์‹œํ•˜๊ฒŒ ๋˜๋ฉด, curl ๋ช…๋ น์–ด์— -HHost ์†์„ฑ์„ ๋” ๋„ฃ์–ด์ค˜์•ผ ํ–ˆ๋‹ค. (--header "Host: ..."๋กœ ๋„ฃ์–ด์ค˜๋„ ๋œ๋‹ค!)

# https://istio.io/latest/docs/tasks/traffic-management/ingress/ingress-control/#using-node-ports-of-the-ingress-gateway-service
$ export INGRESS_NS=istio-system
$ export INGRESS_NAME=istio-ingressgateway
$ export INGRESS_HOST="192.168.64.2"

# ์„ฑ๊ณต!
$ curl -s -I --header "Host:mybookinfo.com" "http://$INGRESS_HOST/productpage"
HTTP/1.1 200 OK
server: istio-envoy

# ์‹คํŒจ...
$ curl -s -I "http://$INGRESS_HOST/productpage"
HTTP/1.1 404 Not Found

๋กœ์ปฌ ๋งฅ๋ถ์ด๋ผ Internal IP๊ฐ€ ๋ถ™์–ด์„œ Host๊ฐ€ ์—†๊ธฐ ๋•Œ๋ฌธ์— Host ํ—ค๋”๊ฐ€ ๊ฐ’์„ ๋„ฃ์–ด์„œ ์šฐํšŒํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ผ๋‹ค.

ํ•˜๋‚˜์˜ Ingress๊ฐ€ ์—ฌ๋Ÿฌ Host๋กœ ๋“ค์–ด์˜ค๋Š” ํŠธ๋ž˜ํ”ฝ ๋ฐ›๊ธฐ

Gateway์— host๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค์€ ํ•˜๋‚˜์˜ Ingress๋กœ ์—ฌ๋Ÿฌ ์„œ๋น„์Šค๋ฅผ ๋…ธ์ถœํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฑธ ๋งํ•˜๊ธฐ๋„ ํ•œ๋‹ค!! ๋ฐฉ๊ธˆ mybookinfo.com์„ ์œ„ํ•ด ๋งŒ๋“ค์—ˆ๋˜ Gateway, VirtualService๋Š” ๊ทธ๋Œ€๋กœ ๋‘๊ณ , helloworld ์›Œํฌ๋กœ๋“œ๋ฅผ ๋…ธ์ถœํ•˜๊ธฐ ์œ„ํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ์ถ”๊ฐ€๋กœ ๋งŒ๋“ค์–ด ๋„์›Œ๋ณด์ž.

๊ทธ๋Ÿฌ๊ณ  ์š”์ฒญ์„ ๋ณด๋‚ด๋ณด๋ฉด

$ curl -s --header "Host:mybookinfo.com" "http://$INGRESS_HOST/productpage"
# ...bookinfo web html...

$ curl -s --header "Host:myhelloworld.com" "http://$INGRESS_HOST/hello"
Hello version: v2, instance: helloworld-v2-77f98b76b-zq5ch

์š”๋ ‡๊ฒŒ Host ์ •๋ณด์— ๋”ฐ๋ผ์„œ ์„œ๋กœ ๋‹ค๋ฅธ ์›Œํฌ๋กœ๋“œ์˜ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค!! โœŒ๏ธ

egress-gateway๋ฅผ ingress ์šฉ๋„๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์„๊นŒ?

๋ฟŒ์Š๋น ์Š?? ์ด ๋ฌด์Šจ ๋ณ€ํƒœ์ ์ธ(?) ์ƒ๊ฐ์ธ๊ฐ€ ใ…‹ใ…‹ ๋‚˜๊ฐ€๋Š”(egress) ๊ณณ์œผ๋กœ ๋“ค์–ด์˜ฌ(ingress) ์ˆ˜ ์žˆ์„๊นŒ? ๋ญ” ์ด๋Ÿฐ ์ƒ๊ฐ์ธ๊ฐ€ ใ…‹ใ…‹

์ผ๋‹จ ๋‹ต์€ โ€œ๋ถˆ๊ฐ€๋Šฅโ€์ด๋‹ค!! โŒ

๊ทธ ์ด์œ ๋Š” Egress GW ๋ฆฌ์†Œ์Šค๋Š” K8s Service๊ฐ€ LoadBalancer ํƒ€์ž…์ด ์•„๋‹ˆ๋ผ ClusterIP์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!!

์ƒ๊ฐํ•ด๋ณด๋ฉด, ์›๋ž˜๋„ ํด๋Ÿฌ์Šคํ„ฐ ๋ฐ–์œผ๋กœ ๋‚˜๊ฐ€๋Š” ๊ฑด ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, ๊ทธ๊ฑธ Egress GW๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋ ค๋Š” ๊ฒƒ ๋ฟ์ด๋‹ค. ๊ทธ๋ž˜์„œ Egress GW๋Š” ClusterIP๋ฅผ ์‚ฌ์šฉํ•ด๋„ ์ถฉ๋ถ„ํ•˜๋‹ค!!


๋งบ์Œ๋ง

๋“œ๋””์–ด Istio์˜ Ingress Gateway์™€ Gateway ๋ฆฌ์†Œ์Šค๋„ ์ญ‰ ์‚ดํŽด๋ดค๋‹ค!! ์ด๊ฒŒ ๋‘˜๋‹ค โ€œGatewayโ€๋ผ๋Š” ์›Œ๋”ฉ์„ ์“ฐ๋‹ˆ๊นŒ Istio ์ฒ˜์Œ ๊ณต๋ถ€ํ•  ๋•Œ ์ง„์งœ ํ—ท๊ฐˆ๋ฆฌ๊ฒŒ ๋งŒ๋“ค์—ˆ๋‹ค O=(โ€˜-โ€˜Q)

๊ฒŒ๋‹ค๊ฐ€ Ingress Gateway๋Š” K8s Pod์ด๋ผ๋„ ์žˆ๋Š”๋ฐ, Gateway ๋ฆฌ์†Œ์Šค๋Š” Pod๋„ ์—†์ง€โ€ฆ ๊ฒฐ๊ตญ VirtualService, DestinationRule, Gateway ๋ชจ๋‘ Istio๊ฐ€ Envoy Proxying ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” Config ๋ฆฌ์†Œ์Šค๋ผ๋Š” ๊ฑธ ์•Œ๊ธฐ ์ „๊นŒ์ง„ ์ •๋ง ํ—ท๊ฐˆ๋ ธ๋‹ค.

์ž! ์ด์   ๋ฐ”๋กœ ์œ„์—์„œ ๋ดค๋˜ โ€œEgress Gatewayโ€๋ฅผ ์‚ดํŽด๋ณผ ์ฐจ๋ก€๋‹ค!! ๊ทธ๋Ÿผ ์•ˆ๋…•~~