NGINX Gateway Fabric: North-South Traffic

이번 포스트에서는 NGINX Gateway Fabric(NGF)를 활용하여 North-South 트래픽(외부 → 클러스터 내부 서비스)을 발생시키고, 해당 트래픽의 호출 로그를 확보하는 방법을 소개합니다.

NGINX Gateway Fabric은 Kubernetes Gateway API를 기반으로 한 고성능 Ingress Controller로, 외부 요청을 클러스터 내부 Pod로 안전하고 효율적으로 라우팅합니다. North-South 트래픽은 외부 클라이언트가 Gateway를 통해 내부 서비스에 접근하는 흐름을 의미하며, 이 과정에서 NGINX가 모든 요청을 처리하므로 상세한 접근 로그를 손쉽게 수집할 수 있습니다.

목차

1. North-South 트래픽이란?
2. 실습 환경 구성
2-1. 내부 애플리케이션 배포 (Deployment + Service)
2-2. Gateway 및 HTTPRoute 설정
3. 외부에서 트래픽 발생시키기
4. NGINX Gateway Fabric 로그 확인
5. 결론 및 운영 팁

1. NGINX Gateway Fabric North-South 트래픽이란?

North-South 트래픽은 클러스터 외부(인터넷, 사내 다른 네트워크 등)에서 클러스터 내부로 들어오거나 나가는 트래픽을 의미합니다. 반대로 클러스터 내부 Pod 간 통신은 East-West 트래픽이라고 합니다.

NGINX Gateway Fabric은 North-South 트래픽의 진입점 역할을 하며, Gateway 리스너를 통해 외부 요청을 받아 HTTPRoute 규칙에 따라 적절한 백엔드 Service로 라우팅합니다. 이 과정에서 NGINX가 모든 요청을 처리하므로 접근 IP, 호스트, 경로, 상태 코드 등 상세한 로그를 남길 수 있습니다.

2. NGINX Gateway Fabric 환경 구성

아래 YAML을 순서대로 적용하면 외부에서 접근 가능한 간단한 NGINX 웹 애플리케이션이 배포됩니다.

2-1. 내부 애플리케이션 배포 (Deployment + Service)

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: ngf-shin
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginxstore/webapp-example-1:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: ngf-shin
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: nginx

2-2. Gateway 및 HTTPRoute 설정

Gateway (외부 진입점 정의)

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: ho-ngf-gateway
namespace: ngf-shin
spec:
gatewayClassName: nginx
listeners:
- name: http
port: 80
protocol: HTTP
hostname: "ho-ngf.devopsshin.com"

HTTPRoute (라우팅 규칙 정의)

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: ho-ngf-httproute
namespace: ngf-shin
spec:
parentRefs:
- name: ho-ngf-gateway
sectionName: http
hostnames:
- "ho-ngf.devopsshin.com"
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: nginx
port: 80

위 설정을 적용하면 ho-ngf.devopsshin.com 도메인으로 들어오는 모든 HTTP 요청이 내부 nginx Service로 라우팅됩니다.

3. 외부에서 트래픽 발생시키기

외부에서 간단히 curl로 테스트할 수 있습니다:

curl -H "Host: ho-ngf.devopsshin.com" http://<GATEWAY_EXTERNAL_IP>
# 또는 DNS가 설정된 경우
curl http://ho-ngf.devopsshin.com

반복 요청으로 로그를 충분히 발생시킬 수 있습니다:

for i in {1..100}; do curl -s -o /dev/null -H "Host: ho-ngf.devopsshin.com" http://<GATEWAY_EXTERNAL_IP>; done

4. NGINX Gateway Fabric 로그 확인

NGINX Gateway Fabric은 기본적으로 NGINX Pod에서 상세한 access 로그를 남깁니다.

NGF Gateway Pod 확인:

kubectl get pods -n ngf-shin

로그 확인:

kubectl logs -n ngf-shin <ngf-pod-name> -c nginx

로그 예시 (기본 포맷):

192.168.200.135 - - [30/Dec/2025:07:34:00 +0000] "GET / HTTP/1.1" 200 672 "-" "curl/8.16.0"
2025/12/30 07:34:00 [info] 29#29: *153 client 192.168.200.135 closed keepalive connection
192.168.200.135 - - [30/Dec/2025:07:34:03 +0000] "GET / HTTP/1.1" 200 672 "-" "curl/8.16.0"
2025/12/30 07:34:03 [info] 31#31: *156 client 192.168.200.135 closed keepalive connection
192.168.200.135 - - [30/Dec/2025:07:34:03 +0000] "GET / HTTP/1.1" 200 672 "-" "curl/8.16.0"
2025/12/30 07:34:03 [info] 31#31: *158 client 192.168.200.135 closed keepalive connection
192.168.200.135 - - [30/Dec/2025:07:34:04 +0000] "GET / HTTP/1.1" 200 672 "-" "curl/8.16.0"
2025/12/30 07:34:04 [info] 31#31: *160 client 192.168.200.135 closed keepalive connection
192.168.200.135 - - [30/Dec/2025:07:34:05 +0000] "GET / HTTP/1.1" 200 672 "-" "curl/8.16.0"
2025/12/30 07:34:05 [info] 31#31: *162 client 192.168.200.135 closed keepalive connection
192.168.200.135 - - [30/Dec/2025:07:34:05 +0000] "GET / HTTP/1.1" 200 672 "-" "curl/8.16.0"
2025/12/30 07:34:05 [info] 31#31: *164 client 192.168.200.135 closed keepalive connection

여기서 확인 가능한 주요 정보:

  • 클라이언트 IP (192.168.200.135)
  • 요청 시간
  • HTTP 메서드 및 경로
  • 응답 상태 코드 (200)
  • User-Agent 등

필요 시 ConfigMap으로 로그 포맷을 커스터마이징하거나, Fluent Bit / Prometheus 등으로 로그를 중앙 집중할 수 있습니다.

5. 결론 및 운영 팁

  • NGINX Gateway Fabric은 Gateway API 기반으로 North-South 트래픽을 깔끔하게 처리합니다.
  • 모든 외부 요청은 NGINX를 거치므로 상세한 접근 로그를 기본으로 확보 가능합니다.
  • 로그 분석을 위해 EFK(Elasticsearch + Fluent Bit + Kibana) 또는 Loki 스택 연동을 추천합니다.
  • 보안을 위해 반드시 hostname 기반 리스너와 HTTPRoute를 활용하여 불필요한 도메인 접근 차단하세요.

NGINX Gateway Fabric의 North-South 트래픽 처리 및 로깅 기능에 대해 궁금한 점이 있으시면 언제든 문의 주세요

NGINX STORE를 통한 솔루션 도입 및 기술지원 무료 상담 신청

* indicates required