MeshHTTPRoute 트래픽 분할
MeshHTTPRoute 트래픽 분할 (Traffic Split)
이 문서는 MeshHTTPRoute 정책을 사용해 여러 MeshService 사이에서 HTTP 트래픽을 나누는 방법을 설명해요 backendRefs에 가중치를 지정해 트래픽의 90%는 v1 버전으로, 10%는 v2 버전으로 보내는 식의 점진적 배포를 구성할 수 있어요 Kubernetes와 Universal 두 환경에서 kuma.io/service 태그 기반 방식과 MeshService 리소스 기반 방식으로 설정하는 YAML 예제를 소개해요
출처: 문서
본문
트래픽 분할
MeshHTTPRoute를 사용해 서로 다른 MeshService 간에 HTTP 트래픽을 분할해요.
구성
Kubernetes
kuma.io/service 태그 기반 네이밍을 사용하는 경우:
apiVersion: kuma.io/v1alpha1
kind: MeshHTTPRoute
metadata:
name: http-split
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend_kuma-demo_svc_3001
rules:
- matches:
- path:
type: PathPrefix
value: "/"
default:
backendRefs:
- kind: MeshServiceSubset
name: backend_kuma-demo_svc_3001
weight: 90
tags:
version: v1
- kind: MeshServiceSubset
name: backend_kuma-demo_svc_3001
weight: 10
tags:
version: v2
MeshService Kubernetes 리소스를 사용하는 경우:
apiVersion: kuma.io/v1alpha1
kind: MeshHTTPRoute
metadata:
name: http-split
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend
namespace: kuma-demo
sectionName: http
rules:
- matches:
- path:
type: PathPrefix
value: "/"
default:
backendRefs:
- kind: MeshService
name: backend-v1
namespace: kuma-demo
port: 3001
weight: 90
- kind: MeshService
name: backend-v2
namespace: kuma-demo
port: 3001
weight: 10
Universal
kuma.io/service 태그 기반 네이밍을 사용하는 경우:
type: MeshHTTPRoute
name: http-split
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend
rules:
- matches:
- path:
type: PathPrefix
value: "/"
default:
backendRefs:
- kind: MeshServiceSubset
name: backend
weight: 90
tags:
version: v1
- kind: MeshServiceSubset
name: backend
weight: 10
tags:
version: v2
MeshService Kubernetes 리소스를 사용하는 경우:
type: MeshHTTPRoute
name: http-split
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend
sectionName: http
rules:
- matches:
- path:
type: PathPrefix
value: "/"
default:
backendRefs:
- kind: MeshService
name: backend-v1
port: 3001
weight: 90
- kind: MeshService
name: backend-v2
port: 3001
weight: 10
Terraform
현재 구성에 맞게 konnect_mesh_control_plane.my_meshcontrolplane.id와 konnect_mesh.my_mesh.name을 조정하세요. {: .text-sm}
resource "konnect_mesh_http_route" "http_split" {
provider = konnect-beta
type = "MeshHTTPRoute"
name = "http-split"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "frontend"
}
}
to = [
{
target_ref = {
kind = "MeshService"
name = "backend"
section_name = "http"
}
rules = [
{
matches = [
{
path = {
type = "PathPrefix"
value = "/"
}
}
]
default = {
backend_refs = [
{
kind = "MeshService"
name = "backend-v1"
port = "3001"
weight = "90"
},
{
kind = "MeshService"
name = "backend-v2"
port = "3001"
weight = "10"
}
]
}
}
]
}
]
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.