HTTP 헤더 기반 로드 밸런싱
HTTP 헤더 기반 로드 밸런싱 (Load balance from HTTP header)
이 문서는 MeshLoadBalancingStrategy 정책을 사용해 frontend에서 backend로 향하는 요청을 x-header라는 HTTP 헤더 값을 기준으로 로드 밸런싱하는 방법을 설명해요. RingHash 로드 밸런서에 Header 타입의 해시 정책을 설정하면 같은 헤더 값을 가진 요청이 항상 동일한 대상으로 전달되도록 구성할 수 있어요. Kubernetes, Universal, Terraform 세 가지 환경별 설정 예시를 차례로 소개해요
출처: 문서
본문
HTTP 헤더 기반 로드 밸런싱
HTTP 헤더 x-header를 기준으로 frontend에서 backend로 향하는 요청을 로드 밸런싱해요
설정
Kubernetes
kuma.io/service 태그 기반 네이밍을 사용하는 경우:
apiVersion: kuma.io/v1alpha1
kind: MeshLoadBalancingStrategy
metadata:
name: ring-hash
namespace: kuma-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend_kuma-demo_svc_8080
default:
loadBalancer:
type: RingHash
ringHash:
hashPolicies:
- type: Header
header:
name: x-header
MeshService Kubernetes 리소스를 사용하는 경우:
apiVersion: kuma.io/v1alpha1
kind: MeshLoadBalancingStrategy
metadata:
name: ring-hash
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
default:
loadBalancer:
type: RingHash
ringHash:
hashPolicies:
- type: Header
header:
name: x-header
Universal
kuma.io/service 태그 기반 네이밍을 사용하는 경우:
type: MeshLoadBalancingStrategy
name: ring-hash
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend
default:
loadBalancer:
type: RingHash
ringHash:
hashPolicies:
- type: Header
header:
name: x-header
MeshService Kubernetes 리소스를 사용하는 경우:
type: MeshLoadBalancingStrategy
name: ring-hash
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
name: backend
sectionName: http
default:
loadBalancer:
type: RingHash
ringHash:
hashPolicies:
- type: Header
header:
name: x-header
Terraform
현재 설정에 맞게 konnect_mesh_control_plane.my_meshcontrolplane.id와 konnect_mesh.my_mesh.name을 조정하세요. {: .text-sm}
resource "konnect_mesh_load_balancing_strategy" "ring_hash" {
provider = konnect-beta
type = "MeshLoadBalancingStrategy"
name = "ring-hash"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "frontend"
}
}
to = [
{
target_ref = {
kind = "MeshService"
name = "backend"
section_name = "http"
}
default = {
load_balancer = {
type = "RingHash"
ring_hash = {
hash_policies = [
{
type = "Header"
header = {
name = "x-header"
}
}
]
}
}
}
}
]
}
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)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.