KongIngress에서 어노테이션과 KongUpstreamPolicy로 마이그레이션
KongIngress에서 어노테이션과 KongUpstreamPolicy로 마이그레이션 (Migrating from KongIngress to annotations and KongUpstreamPolicy)
KongIngress 커스텀 리소스는 Kong Ingress Controller 3.5부터 지원 중단되었고 Kong Operator 2.0.0에서는 완전히 제거돼요. 이 문서에서는 proxy와 route 섹션을 전용 어노테이션으로, upstream 섹션은 KongUpstreamPolicy 리소스로 옮기는 방법을 단계별로 안내해요. Gateway API 리소스에서는 KongIngress를 지원하지 않으니 업그레이드 전에 반드시 마이그레이션을 해두세요
출처: 문서
본문
중요: KongIngress 지원 중단 안내
KongIngress커스텀 리소스는 Kong Ingress Controller 3.5부터 **지원 중단(deprecated)**되었고, Kong Operator 2.0.0에서는 완전히 제거될 예정이에요.Kong Operator 2.0.0으로 업그레이드하기 전에 마이그레이션이 반드시 필요해요:
proxy와route섹션은 이미 지원 중단되었고 전용 어노테이션으로 대체되었어요upstream섹션은 새로운KongUpstreamPolicy리소스로 대체되고 있어요KongIngress는 Gateway API 리소스(HTTPRoute, TCPRoute 등)에서는 지원되지 않아요이 가이드를 사용해서 기존
KongIngress리소스를 최신 방식으로 마이그레이션하세요.
KongIngress 리소스는 원래 표준 Kubernetes Ingress 리소스의 기능을 확장하기 위해 설계되었어요. 하지만 Kubernetes 생태계가 발전하고 Gateway API가 성숙해지면서 KongIngress는 중복이 되었고, 다음 항목들이 그 자리를 대신하고 있어요:
- 어노테이션: 간단한 프록시 및 라우트 설정에 사용해요
- KongUpstreamPolicy: 복잡한 업스트림 설정에 사용해요
- Gateway API: 고급 라우팅 및 트래픽 관리에 사용해요
마이그레이션 전략
마이그레이션 방식은 KongIngress의 어떤 섹션을 사용 중인지에 따라 달라져요.
upstream 섹션은 KongUpstreamPolicy 리소스로 대체돼요.
프록시와 라우트 섹션(이미 지원 중단됨)은 전용 어노테이션으로 대체돼요:
| KongIngress 필드 | 대체 어노테이션 |
|---|---|
proxy.connect_timeout |
konghq.com/connect-timeout |
proxy.read_timeout |
konghq.com/read-timeout |
proxy.write_timeout |
konghq.com/write-timeout |
proxy.retries |
konghq.com/retries |
route.methods |
konghq.com/methods |
route.headers.* |
konghq.com/headers.* |
route.protocols |
konghq.com/protocols |
route.regex_priority |
konghq.com/regex-priority |
route.strip_path |
konghq.com/strip-path |
route.preserve_host |
konghq.com/preserve-host |
route.https_redirect_status_code |
konghq.com/https-redirect-status-code |
프록시 및 라우트 섹션 마이그레이션
다음은 프록시와 라우트 섹션을 마이그레이션하는 방법 예시예요.
다음과 같은 KongIngress가 있다면:
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: example-kongingress
proxy:
connect_timeout: 30000
read_timeout: 60000
retries: 5
route:
methods:
- GET
- POST
strip_path: true
preserve_host: true
Service나 Ingress에 어노테이션을 붙여서 대체하세요:
apiVersion: v1
kind: Service
metadata:
name: example-service
annotations:
konghq.com/connect-timeout: "30000"
konghq.com/read-timeout: "60000"
konghq.com/retries: "5"
konghq.com/methods: "GET,POST"
konghq.com/strip-path: "true"
konghq.com/preserve-host: "true"
spec:
# service configuration...
헤더 설정 마이그레이션
konghq.com/headers.* 어노테이션은 특별한 형식을 사용해서 헤더를 설정해요. 어노테이션 이름에서 . 뒤에 오는 문자열이 헤더 이름이고, 어노테이션 값이 헤더 값이 돼요. 예를 들어 요청에 x-custom-header-a: example,otherexample과 x-custom-header-b: example 헤더를 적용하려면 KongIngress 설정은 다음과 같아요:
route:
headers:
x-custom-header-a:
- example
- otherexample
x-custom-header-b:
- example
동일한 역할을 하는 어노테이션 설정은 다음과 같아요:
konghq.com/headers.x-custom-header-a: example,otherexample
konghq.com/headers.x-custom-header-b: example
같은 헤더 어노테이션을 여러 번 적용해서 여러 헤더 값을 설정할 수는 없어요. 여러 값을 설정하려면 하나의 헤더 안에 CSV 형식으로 설정해야 해요.
KongUpstreamPolicy
KongIngress 리소스의 upstream 섹션은 어노테이션으로는 쉽게 표현하기 어려운 복잡한 객체를 담고 있어요. 3.x 버전에서는 새로운 KongUpstreamPolicy 리소스를 사용해서 업스트림 설정을 구성해요. KongUpstreamPolicy의 spec 필드는 KongIngress의 upstream 섹션과 비슷하지만, 다음과 같은 차이가 있어요:
- 필드 이름은 Kubernetes API와의 일관성을 위해
snake_case대신lowerCamelCase를 사용해요. hash_on,hash_fallback과 관련 필드인has_on_*,hash_fallback_*는 이제hashOn과hashOnFallback객체로 바뀌었어요. 기본 해싱 전략을 정의하려면hashOn의 필드 하나를 채워서 사용하세요(예를 들어 헤더를 기준으로 해싱하고 싶다면hashOn.header에 헤더 이름을 채우면 돼요). 마찬가지로 보조 해싱 전략을 정의하려면hashOnFallback을 사용하세요.
정확한 스키마는 KongUpstreamPolicy 참조 문서를 확인하세요.
예를 들어 이전에 다음과 같은 KongIngress를 사용했다면:
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: sample-customization
upstream:
hash_on: header
hash_on_header: x-lb
hash_fallback: ip
algorithm: consistent-hashing
다음과 같은 KongUpstreamPolicy를 사용해야 해요:
apiVersion: configuration.konghq.com/v1beta1
kind: KongUpstreamPolicy
metadata:
name: sample-customization
spec:
hashOn:
header: x-lb
hashOnFallback:
input: ip
algorithm: consistent-hashing
konghq.com/upstream-policy: sample-customization 어노테이션을 사용해서 Service 리소스에 적용하세요.
관련 리소스
더 알아보기 (Learn more)
- route.headers 설정을 어노테이션으로 옮길 때 필요한
konghq.com/headers.*어노테이션 사용법은 어노테이션 참고 문서에서 확인해 보세요 —konghq.com/headers.*annotation - upstream 섹션을 대체하는 KongUpstreamPolicy 커스텀 리소스의 전체 스펙은 참고 문서에서 살펴볼 수 있어요 — KongUpstreamPolicy reference
- Ingress 기반 구성을 Gateway API로 전환하는 방법이 궁금하다면 Gateway API 마이그레이션 가이드를 참고해 보세요 — Gateway API Migration