GatewayClass ← Gateway ← HTTPRoute / GRPCRoute
parentRefs로 참조, Gateway가 GatewayClass를 gatewayClassName으로 참조apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: example-class
spec:
controllerName: example.com/gateway-controller # 이 클래스를 처리할 컨트롤러 식별자
spec.controllerName을 watch하고 있는 컨트롤러가 이 클래스의 Gateway를 처리gke-l7-global-external-managed 등)가 미리 등록됨apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: example-gateway
namespace: example-namespace
spec:
gatewayClassName: example-class # 어느 GatewayClass(컨트롤러)를 사용할지
listeners:
- name: http
protocol: HTTP
port: 80
hostname: "www.example.com"
allowedRoutes:
namespaces:
from: Same # 기본: 같은 네임스페이스의 Route만 허용
spec.listeners — 수신 포트·프로토콜·호스트 조합. 여러 개 정의 가능 (HTTP 80, HTTPS 443 등)allowedRoutes — 어느 네임스페이스의 Route가 이 Gateway에 붙을 수 있는지 제어
from: Same (기본) — 같은 네임스페이스만from: All — 모든 네임스페이스from: Selector — 라벨로 선택한 네임스페이스addresses를 지정하지 않으면 컨트롤러가 IP·호스트명을 자동 할당apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-httproute
spec:
parentRefs:
- name: example-gateway # 어느 Gateway에 붙을지
hostnames:
- "www.example.com"
rules:
- matches:
- path:
type: PathPrefix
value: /login
backendRefs:
- name: example-svc
port: 8080
parentRefs — 이 Route가 연결될 Gateway (네임스페이스 간 참조도 가능)hostnames — 매칭할 호스트 이름 목록rules — 매칭 조건(matches)과 백엔드(backendRefs)의 쌍. 여러 rule 정의 가능matches에서 path 외에도 header·method·query parameter 매칭을 표준 스펙으로 지원backendRefs에서 가중치(weight)로 트래픽 분배 비율을 지정 가능 — 카나리 배포에 활용apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
metadata:
name: example-grpcroute
spec:
parentRefs:
- name: example-gateway
hostnames:
- "svc.example.com"
rules:
- backendRefs:
- name: example-svc
port: 50051
service와 method 둘 다 지정하면 특정 메서드로, service만 지정하면 그 패키지의 모든 메서드로 라우팅HTTPRoute.spec.rules 안에서 matches / filters / backendRefs.weight로 처리matches는 OR — 여러 match 중 하나라도 맞으면 rule 적용Exact / RegularExpression)GET / POST 등 HTTP 메서드
```yaml
matches:
Exact가 PathPrefix보다, path 길이가 길수록, 매칭 조건(header·query) 수가 많을수록 우선| 필터 | 역할 |
|---|---|
RequestHeaderModifier |
요청 헤더 set / add / remove |
ResponseHeaderModifier |
응답 헤더 set / add / remove |
RequestRedirect |
HTTP 리다이렉트 응답 (백엔드 호출 안 함) |
URLRewrite |
path · hostname 재작성 후 백엔드 전달 |
RequestMirror |
동일 요청을 다른 백엔드에 복제 (응답은 무시) |
rules.filters)에 type 필드로 구분해서 정의
```yaml
filters:
RequestRedirect — 백엔드 호출 없이 즉시 3xx 응답. http→https 강제, 도메인 변경 시 활용RequestMirror — 미러 응답은 클라이언트에 돌아가지 않음 → 트래픽 영향 없이 신버전 검증 가능backendRefs에 여러 Service를 두고 weight로 트래픽 비율 분배weight 값을 점진적으로 조정해 신버전 비중 확대
```yaml
rules:
weight는 정수, 합이 100일 필요 없음 — 전체 합 대비 비율로 환산 (예: 90:10 = 9:1)weight: 0이면 해당 백엔드로 보내지 않음 — 트래픽 차단용matches(예: header x-user-bucket)로 사용자별 분리 필요http://www.example.com로 HTTP 요청을 만들 준비Host 헤더로 매칭되는 Gateway·HTTPRoute 설정을 찾음matches 규칙(path, header, method 등)으로 어느 rule을 적용할지 결정backendRefs의 Service(또는 EndpointSlice) Pod로 요청 forwardparentRefs로 묶인 HTTPRoute가 여러 개여도 Gateway가 한곳에서 일괄 처리Standard(GA·정식)와 Experimental(실험) 채널로 분리Core(필수), Extended(선택 지원), Implementation-specific(구현체 자유)로 분류gateway-api.sigs.k8s.io)에 공개됨Ingress kind가 포함되지 않음Ingress.spec.rules.host → HTTPRoute.spec.hostnamesIngress.spec.rules.http.paths.path → HTTPRoute.spec.rules.matches.pathIngress.spec.tls → Gateway.spec.listeners 의 TLS 설정으로 이동 (인증서는 Gateway에서 종료)ingress2gateway (Gateway API SIG가 제공) 사용 시 기존 Ingress 리소스를 HTTPRoute·Gateway YAML로 변환 가능