Gateway API로 라우팅 관리하기
Gateway
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
spec:
gatewayClassName: <gatewayClassName>
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
- name: https
protocol: HTTPS
port: 443
tls:
name: Terminate
certificateRefs:
- name: <secretName>
allowedRoutes:
namespaces:
from: Same
gatewayClassName: <name>
listeners: []
infrastructure
labels
annotations
parametersRef
- GatewayClass가 인식할 수 있는 리소스를 설정하면 Gateway에 의해 생성되는 리소스를 정의할 수 있습니다.
group
kind
name
HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
spec:
hostnames:
- <host>
parentRefs:
- name: <gatewayName>
namespace: <gatewayNamespace>
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: <serviceName>
port: <servicePort>
rules: []
matches: []
- 리스트 중 하나라도 일치하면 라우팅됩니다.
path
,headers
,queryParams
,method
를 조합할 수 있으며, AND 조건으로 처리됩니다.path
type: PathPrefix|RegularExpression
value: <path>
backendRefs: []
group: <group>
kind: Service
name: <name>
namespace: <namespace>
port: <port>