본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

다른 HTTPRoute 간 서비스 결합

원문 보기 위키 갱신

다른 HTTPRoute 간 서비스 결합 (Combining Services from different HTTPRoutes)

Kong Ingress Controller는 같은 백엔드 서비스를 가리키는 여러 HTTPRoute의 규칙을 하나의 Kong Gateway 서비스로 묶어주는 기능을 제공해요 이 문서에서는 --combined-services-from-different-httproutes CLI 플래그나 Helm을 통해 이 기능을 활성화하는 방법을 소개해요 그리고 같은 네임스페이스 안에서 백엔드 서비스 조합이 동일한 규칙들이 하나의 Kong Gateway 서비스로 변환되는 과정과, 네임스페이스·이름·포트·가중치를 기반으로 서비스 이름이 계산되는 방식까지 설명해요

출처: 문서

본문

기능 활성화하기

이 기능을 활성화하려면 --combined-services-from-different-httproutes CLI 플래그를 사용하거나, Helm을 통해 활성화하세요:

ingressController:
  enabled: true
  installCRDs: true
  env:
    # this will inject CONTROLLER_COMBINED_SERVICES_FROM_DIFFERENT_HTTPROUTES="true"
    combined_services_from_different_httproutes: "true"
    

Combined Services From Different HTTPRoutes는 어떻게 동작하나요?

동일한 네임스페이스 내의 모든 HTTPRoute에서, 백엔드 서비스 조합(규칙의 backendRefs에 포함된 네임스페이스, 이름, 포트, 가중치의 조합)이 서로 같은 규칙들은 하나의 Kong Gateway Service로 변환돼요.

변환은 어떻게 이뤄지나요?

이 기능이 활성화되면 변환된 Kong Gateway Service의 이름이 변경돼요. 소스 HTTPRoute와 규칙에서 이름을 생성하는 대신, Kong Gateway Service 이름은 통합된 백엔드로부터 생성돼요.

Service 이름 계산하기

Kong Gateway Service의 이름은 네임스페이스, 이름, 포트, 가중치(지정된 경우)로부터 계산돼요. 이름의 패턴은 다음과 같아요:

httproute.NAMESPACE.svc.BACKEND_NS.BACKEND_NAME.BACKEND_PORT.[BACKEND_WEIGHT]_[NEXT_BACKENDs]...

각 구성 요소의 의미는 다음과 같아요:

  • namespace는 HTTPRoute들의 네임스페이스예요.
  • backend_ns는 첫 번째 백엔드 서비스의 네임스페이스예요.
  • backend_name은 첫 번째 백엔드 서비스의 이름이에요.
  • backend_port는 첫 번째 백엔드 서비스의 포트 번호예요.
  • backend_weight는 지정된 경우 첫 번째 백엔드 서비스의 가중치예요.
  • next_backends는 다른 백엔드 서비스들로부터 계산된 섹션이에요. 백엔드 서비스는 네임스페이스와 이름을 기준으로 정렬돼요.

계산된 이름이 512자(Konnect에서의 Service 이름 길이 제한)를 초과하면, 다음 규칙에 따라 백엔드 서비스 이름이 잘려요:

  • backend_ns, backend_name,backend_port, backend_weight만 사용하고,
  • 이름의 고유성을 보장하기 위해 _combined.<hash>를 붙여요. 여기서 hash는 계산된 서비스 이름의 SHA256 다이제스트예요.

예를 들어, 다음은 같은 포트와 가중치를 사용하며 동일한 백엔드를 가리키는 규칙을 가진 두 개의 HTTPRoute예요:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: httproute-consolidated-1
  namespace: default
spec:
  parentRefs:
  - name: kong
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /httproute-testing
    backendRefs:
    - name: echo-1
      kind: Service
      port: 80
      weight: 75
    - name: echo-2
      kind: Service
      port: 8080
      weight: 25
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: httproute-consolidated-2
  namespace: default
spec:
  parentRefs:
  - name: kong
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /httproute-testing
    backendRefs:
    - name: echo-1
      kind: Service
      port: 80
      weight: 75
    - name: echo-2
      kind: Service
      port: 8080
      weight: 25

이 기능이 비활성화된 경우(기본값)에는 두 HTTPRoutes의 규칙이 서로 다른 두 개의 Kong Gateway Service인 httproute.default.httproute-consolidated-1.0과 httproute.default.httproute-consolidated-2.0으로 변환돼요.

이 기능이 활성화되면 httproute-consolidated-1과 httproute-consolidated-2라는 두 HTTPRoute의 규칙이 httproute.default.svc.default.echo-1.80.75.default.echo-2.80.25라는 이름의 단일 Kong Gateway Service로 변환돼요.

더 알아보기 (Learn more)

이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.