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: []infrastructurelabelsannotationsparametersRef- GatewayClass가 인식할 수 있는 리소스를 설정하면 Gateway에 의해 생성되는 리소스를 정의할 수 있습니다.
groupkindname
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 조건으로 처리됩니다.pathtype: PathPrefix|RegularExpressionvalue: <path>
backendRefs: []group: <group>kind: Servicename: <name>namespace: <namespace>port: <port>
GRPCRoute
apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
spec:
hostnames:
- <host>
parentRefs:
- name: <gatewayName>
namespace: <gatewayNamespace>
rules:
- matches:
- method:
type: Exact
service: <service>
backendRefs:
- name: <serviceName>
port: <servicePort>
rules: []matches: []- 리스트 중 하나라도 일치하면 라우팅됩니다.
method,headers를 조합할 수 있으며, AND 조건으로 처리됩니다.methodservice또는method중 적어도 하나는 설정해야 합니다.type: Exact|RegularExpressionservice: <service>- service를 설정하지 않으면 모든 service가 일치합니다.
method: <method>- method를 설정하지 않으면 모든 method가 일치합니다.
backendRefs: []group: <group>kind: Servicename: <name>namespace: <namespace>port: <port>