Nginx (Nginx Ingress Controller)
Nginx Ingress Controller는 하나 이상의 Ingress 객체를 통해 트래픽 관리 기능을 제공하며, 파드로 직접 트래픽을 라우팅하도록 Nginx 배포를 구성해요. Argo Rollouts는 canary Ingress라는 두 번째 Ingress를 만들어 버전 간 트래픽을 분할합니다. 이 페이지에서는 Nginx 트래픽 라우팅을 위한 필수 필드와 구성 방법을 다룹니다.
출처: Argo Rollouts 문서
본문
Nginx Ingress Controller는 하나 이상의 Ingress 객체를 통해 파드로 직접 트래픽을 라우팅하는 Nginx 배포를 구성함으로써 트래픽 관리를 가능하게 합니다. 각 Nginx Ingress는 Nginx Deployment의 동작을 수정하는 여러 어노테이션을 포함합니다. 애플리케이션의 서로 다른 버전 간 트래픽 관리를 위해, Nginx Ingress Controller는 특별한 어노테이션을 가진 두 번째 Ingress 객체(canary Ingress라고 함)를 도입해 트래픽을 분할하는 기능을 제공합니다. 이 canary 어노테이션에 대한 자세한 내용은 공식 canary 어노테이션 문서 페이지에서 확인할 수 있습니다. canary Ingress는 다른 비-canary nginx 어노테이션을 무시합니다. 대신 기본 Ingress의 어노테이션 설정을 활용합니다.
Rollout 컨트롤러는 항상 canary Ingress에 다음 두 어노테이션을 설정합니다(구성한 접두사 또는 기본 nginx.ingress.kubernetes.io 접두사 사용):
canary: true— 이것이 canary Ingress임을 나타냅니다.canary-weight: <num>— canary로 보낼 트래픽의 비율(%)을 나타냅니다. 모든 트래픽이 stable Service로 라우팅되면 0으로 설정됩니다.
additionalIngressAnnotations 또는 canaryIngressAnnotations 필드를 통해 canary Ingress에 추가할 어노테이션을 지정할 수 있어요. 이를 통해 헤더나 쿠키 기반 라우팅 같은 기능을 활성화할 수 있습니다. 전자는 공통적이고 주입 가능한 nginx 어노테이션 접두사를 재사용할 수 있게 해 주는 반면, 후자는 다른 그룹의 사용자 지정 전체 어노테이션을 정의할 수 있게 해 줍니다. 이는 제3자 메트릭 스크레이퍼 또는 다른 인프라 통합과 같은 독립적인 메커니즘에 유용할 수 있어요.
Argo Rollouts와의 통합 (Integration with Argo Rollouts)
Nginx를 사용해 버전 간 트래픽을 분할하려면 Rollout에 몇 가지 필수 필드가 필요합니다. 그 필드들이 포함된 Rollout 예시는 다음과 같습니다.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
spec:
...
strategy:
canary:
canaryService: canary-service # required
stableService: stable-service # required
trafficRouting:
nginx:
# Either stableIngress or stableIngresses must be configured, but not both.
stableIngress: primary-ingress
stableIngresses:
- primary-ingress
- secondary-ingress
- tertiary-ingress
annotationPrefix: customingress.nginx.ingress.kubernetes.io # optional
additionalIngressAnnotations: # optional
canary-by-header: X-Canary
canary-by-header-value: iwantsit
canaryIngressAnnotations: # optional
my-custom-annotation.mygroup.com/key: value
stable Ingress 필드는 Rollout과 같은 네임스페이스에 있는 Ingress에 대한 참조입니다. Rollout은 기본 Ingress가 stable Service로 트래픽을 라우팅하도록 요구합니다. Rollout은 Ingress에 Rollout의 stableService와 일치하는 백엔드가 있는지 확인해 이 조건을 검사합니다. 컨트롤러는 canary 어노테이션이 있는 두 번째 Ingress를 만들어 canary Service로 트래픽을 라우팅합니다. Rollout이 Canary step들을 진행하면서, 컨트롤러는 두 버전 간의 트래픽 분할을 가능하게 하는 Rollout의 원하는 상태를 반영하도록 canary Ingress의 canary 어노테이션을 업데이트합니다. Nginx Ingress Controller는 사용자가 Ingress 컨트롤러가 사용하는 어노테이션 접두사를 구성할 수 있게 하므로, Rollouts는 선택적 annotationPrefix 필드를 지정할 수 있습니다. canary Ingress는 이 필드가 설정되면 기본 nginx.ingress.kubernetes.io 대신 해당 접두사를 사용합니다. Kubernetes 문서에서 정의한 대로, 어쩌면 다른 그룹의 전체 어노테이션을 선언해야 한다면 canaryIngressAnnotations 필드를 사용할 수 있습니다. 이 필드는 유사한 키-값 구조를 허용하지만 접두사 주입은 수행하지 않습니다. additionalIngressAnnotations와 충돌하는 경우 canaryIngressAnnotations 아래의 값이 우선한다는 점에 유의하세요.
서비스당 여러 NGINX ingress 컨트롤러와 함께 Argo Rollouts 사용하기
v1.5부터, argo rollouts는 canary 배포가 있는 단일 서비스를 가리키는 여러 Nginx ingress 컨트롤러를 지원합니다. ingress 컨트롤러가 하나만 필요하다면 기존 키 stableIngress를 사용하세요. 여러 ingress 컨트롤러가 필요하다면(예: 내부와 외부 트래픽 분리), 대신 stableIngresses 키를 사용하세요. 이는 ingress 컨트롤러의 이름인 문자열 값 배열을 받습니다. Canary step은 모든 ingress 컨트롤러에 동일하게 적용됩니다.
사용자 지정 NGINX ingress 컨트롤러 이름과 함께 Argo Rollouts 사용하기
기본적으로 Argo Rollouts 컨트롤러는 kubernetes.io/ingress.class 어노테이션 또는 spec.ingressClassName이 nginx로 설정된 ingress에서만 작동합니다. 사용자는 --nginx-ingress-classes 플래그를 지정해 다른 클래스 이름의 Ingress에서 작동하도록 컨트롤러를 구성할 수 있습니다. Argo Rollouts 컨트롤러가 여러 값에서 작동해야 한다면 --nginx-ingress-classes 플래그를 여러 번 나열할 수 있습니다. 이는 클러스터에 서로 다른 클래스 값으로 작동하는 여러 Ingress 컨트롤러가 있는 경우를 해결합니다. 사용자가 kubernetes.io/ingress.class 어노테이션이나 spec.ingressClassName이 없는 모든 Ingress에서 컨트롤러가 작동하길 원한다면, 다음 --nginx-ingress-classes ''를 추가해야 합니다.
더 알아보기 (Learn more)
- Argo Rollouts 트래픽 관리(Traffic Management) 개요
- Istio 가상 서비스 기반 트래픽 라우팅
- Canary 배포에서 안정(stable)/카나리(canary) 서비스 구성
- 컨트롤러 플래그를 통한 동작 맞춤 설정 (
--nginx-ingress-classes)