Istio를 이용해 Kubernetes의 Pod가 외부 트래픽을 받기 위한 필수 리소스들 소개

Gateway

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway  # 기본 Istio Gateway 선택
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "example.com"  # 외부에서 접근할 도메인

Istio Gateway vs. Kubernetes Ingress

Istio의 Gateway는 Kubernetes의 Ingress와 유사한 역할을 하지만, 다음과 같은 차이점이 있다.

1. 역할 비교

기능 Kubernetes Ingress Istio Gateway
트래픽 수신 외부에서 클러스터로 HTTP/HTTPS 트래픽 유입 외부에서 Istio Mesh로 트래픽 유입
로드밸런서 기본적으로 LoadBalancer(클라우드 제공) 또는 NodePort 사용 Istio IngressGateway(Envoy) 사용
라우팅 방식 Ingress 리소스 기반, 기본적으로 Service만 연결 가능 VirtualService를 통해 미세한 트래픽 제어 가능
HTTP → HTTPS 리다이렉트 기본 제공 수동 설정 필요
TLS 인증서 관리 Kubernetes TLS Secret 사용 Istio TLS Mode, Cert-Manager와 통합 가능
L7 라우팅 기본 지원 (path, host 기반) 더 정교한 트래픽 제어 (weight, retry, header 기반)
L4 지원 X (HTTP/HTTPS만 가능) O (TCP, gRPC, WebSocket 지원)

2. 구조 비교

① Kubernetes Ingress

Kubernetes 기본 Ingress 컨트롤러(Nginx, Traefik 등)를 사용하면 다음과 같은 구조로 동작한다.

외부 트래픽 → LoadBalancer (Ingress Controller) → Ingress → Service → Pod

② Istio Gateway

Istio는 자체적인 Gateway 리소스를 사용하여 외부 트래픽을 Mesh 내부로 유입한다.

외부 트래픽 → LoadBalancer (Istio IngressGateway) → Gateway → VirtualService → Service → Pod

3. 언제 Kubernetes Ingress vs. Istio Gateway를 사용할까?

상황 Kubernetes Ingress 사용 Istio Gateway 사용
기본적인 HTTP 트래픽 관리 ✅ ✅
L7 트래픽 라우팅 (/api, /web 등) ✅ ✅
TLS Termination (HTTPS 지원) ✅ (Kubernetes Secret 사용) ✅ (Gateway에서 직접 설정 가능)
TCP/gRPC/WebSocket 지원 ❌ (HTTP/HTTPS만 지원) ✅
Canary Deployment (트래픽 분배) ❌ ✅ (weight 기반 트래픽 조절 가능)
Retry / Timeout 설정 ❌ (Ingress에서는 기본적으로 미지원) ✅ (VirtualService에서 설정 가능)
A/B 테스트 및 Blue/Green 배포 ❌ ✅