From e916cec273aebb597972090b15e54ce32077d8c2 Mon Sep 17 00:00:00 2001 From: kappa Date: Wed, 25 Mar 2026 15:20:15 +0900 Subject: [PATCH] =?UTF-8?q?Traefik=20=EC=A0=84=ED=99=98=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC:=20APISIX=E2=86=92Traefik=20=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EA=B5=90=EC=B2=B4=20(2026-03-25)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/apisix.md | 66 ++++++++---------------------------------- infra/gateway-api.md | 58 +++++++++++++++++++++---------------- infra/k3s-migration.md | 12 ++++++-- 3 files changed, 54 insertions(+), 82 deletions(-) diff --git a/infra/apisix.md b/infra/apisix.md index 76158b6..bbbc13d 100644 --- a/infra/apisix.md +++ b/infra/apisix.md @@ -37,65 +37,23 @@ BunnyCDN(inouter, ID 5316471) → apisix-osaka(172.233.93.180) → 백엔드 - 보안: SafeLine WAF + CrowdSec 연동 - upstream: incus-jp1 내부(10.253.x), K3s Traefik -### 서울 (K3s 새 클러스터, apisix 네임스페이스) +### 서울 (K3s 새 클러스터, apisix 네임스페이스) — SafeLine WAF 전용 ``` -인터넷 → OpenWrt HAProxy(:80/:443) → 3노드 hostPort(80→9080, 443→9443) → APISIX → K3s 서비스 → pods +SafeLine WAF → APISIX(replica 1) → K3s 서비스 ``` -- 용도: KR존 리버스 프록시 +- 용도: SafeLine WAF 전용 리버스 프록시 (메인 라우팅은 Traefik으로 이전) - 클러스터: K3s 새 클러스터 (Supabase PostgreSQL 백엔드, kr2+kr1+hp2) -- 배포: K3s apisix 네임스페이스, Deployment replica 3, hostPort 80/443 -- APISIX: 3.15.0-ubuntu, node_listen 9080, SSL 9443 -- **관리 방식: Ingress Controller 2.0.1 + Gateway API CRD** (Admin API 수동 관리 불필요) - - GatewayClass: `apisix` (controllerName: `apisix.apache.org/apisix-ingress-controller`) - - Gateway: `apisix-gateway` (HTTP 9080, HTTPS 9443) - - GatewayProxy: `apisix-proxy` (ControlPlane, apisix-admin:9180) - - 라우트: HTTPRoute/TCPRoute CRD로 관리 → Ingress Controller가 Admin API를 통해 자동 sync -- SSL: Gateway listener에서 cert-manager 와일드카드 시크릿 참조 - - `*.inouter.com` (wildcard-inouter-tls) - - `*.anvil.it.com` (wildcard-anvil-it-com-tls) - - `*.actions.it.com` (wildcard-actions-it-com-tls) +- 배포: K3s apisix 네임스페이스, **Deployment replica 1** (축소됨) +- APISIX: 3.15.0-ubuntu - etcd: apisix-etcd StatefulSet (K3s 내부) -- Admin API: `apisix-admin` ClusterIP (9180), Ingress Controller 전용 -- 2026-03-25 Admin API 수동 관리에서 CRD 자동 관리로 전환 완료 +- 2026-03-25 메인 라우팅 역할을 Traefik으로 이전, APISIX는 SafeLine WAF 전용으로 축소 +- Ingress Controller + Gateway API CRD 제거됨 (GatewayProxy 모드에서 ApisixRoute CRD 미지원, HTTPRoute에 플러그인 개별 적용 불가 문제) -#### 라우트 관리 (CRD 기반) - -라우트 추가/수정은 HTTPRoute CRD로: -```yaml -apiVersion: gateway.networking.k8s.io/v1 -kind: HTTPRoute -metadata: - name: my-service - namespace: my-namespace -spec: - hostnames: ["my-service.inouter.com"] - parentRefs: - - name: apisix-gateway - namespace: apisix - rules: - - backendRefs: - - name: my-service-svc - port: 8080 - matches: - - path: - type: PathPrefix - value: / -``` - -플러그인 적용: `apisix.apache.org/plugin-config-name` 어노테이션으로 PluginConfig 참조. - -#### global_rules (기존 etcd 직접 등록) -- `real-ip` — source: http_x_real_ip, trusted: 0.0.0.0/0 -- `http-logger` → CrowdSec (10.253.100.240:8085, auth_header: apisix-crowdsec-log-2024) - -#### 라우트 및 플러그인 - -| 라우트 ID | 호스트 | upstream | chaitin-waf | limit-req (rate/burst) | -|-----------|--------|----------|-------------|----------------------| -| gitea-anvil-it-com | gitea.anvil.it.com | K3s Traefik :443 (roundrobin) | block, match: `.git/` 제외 | 50/30 | -| hcv-inouter-com | hcv.inouter.com | K3s Traefik :443 (roundrobin) | block | 20/10 | -| nocodb | nocodb.inouter.com | K3s Traefik :443 (roundrobin) | block | 100/50 | -| nocodb-nuxt | nocodb.inouter.com | K3s Traefik :443 (roundrobin) | block | 100/50 | +#### 이전 사유 (2026-03-25) +- Ingress Controller 2.0 GatewayProxy 모드가 ApisixRoute CRD를 sync하지 않음 +- Gateway API HTTPRoute에 플러그인 개별 적용 방법이 없음 +- global_rules를 Ingress Controller가 덮어쓰려는 충돌 발생 +- → Traefik으로 메인 라우팅 교체, APISIX는 SafeLine WAF 연동 전용으로 유지 ### BunnyCDN Pull Zone 매핑 diff --git a/infra/gateway-api.md b/infra/gateway-api.md index 5751509..cc88f3a 100644 --- a/infra/gateway-api.md +++ b/infra/gateway-api.md @@ -1,44 +1,52 @@ --- -title: K3s Gateway API 마이그레이션 -updated: 2026-03-22 +title: K3s Gateway API — Traefik 메인 라우팅 +updated: 2026-03-25 tags: [k3s, traefik, gateway-api] --- ## 개요 -K3s Ingress → Gateway API 전환 완료 (2026-03-21). Traefik v3.6.9의 Gateway API provider 사용. +K3s 메인 라우팅을 Traefik이 담당 (2026-03-25 APISIX에서 전환). -## Traefik 설정 +### 전환 이력 +- 2026-03-21: K3s Ingress → Gateway API 전환 (기존 클러스터, Traefik v3.6.9) +- 2026-03-24: 새 클러스터(kr2)에서 APISIX + Ingress Controller 2.0으로 구성 +- 2026-03-25: APISIX Ingress Controller의 Gateway API 플러그인 제한으로 **Traefik으로 교체** + - APISIX는 SafeLine WAF 전용 replica 1로 축소 -HelmChartConfig로 Gateway API provider 활성화: +## Traefik 배포 (새 클러스터) -```yaml -providers: - kubernetesGateway: - enabled: true -gateway: - listeners: - web: - namespacePolicy: - from: All - websecure: - port: 8443 - protocol: HTTPS - certificateRefs: - - name: wildcard-inouter-com-tls - namespace: cert-manager - namespacePolicy: - from: All -``` +- **DaemonSet** (kube-system 네임스페이스) +- hostPort: 80 (HTTP), 443 (HTTPS) +- Gateway API provider 활성화 +- TLSStore CRD로 와일드카드 인증서 기본 로드 +- 와일드카드 인증서: *.inouter.com, *.anvil.it.com, *.actions.it.com, *.ironclad.it.com, *.keepanker.com, *.servidor.it.com ## Gateway - GatewayClass: `traefik` (traefik.io/gateway-controller) - Gateway: `traefik-gateway` (kube-system) -- Listeners: web (HTTP 8000) + websecure (HTTPS 8443) -- TLS: cert-manager의 wildcard-inouter-com-tls 참조 +- Listeners: web (HTTP 80) + websecure (HTTPS 443) +- TLS: TLSStore로 기본 인증서, Gateway listener에서 추가 인증서 참조 - ReferenceGrant: cert-manager → kube-system (Secret 참조 허용) +## 서비스 상태 (2026-03-25 전환 완료) + +| 서비스 | 도메인 | 상태 | +|--------|--------|------| +| NocoDB | nocodb.inouter.com | 200 ✅ | +| Gitea | gitea.anvil.it.com | 200 ✅ | +| n8n | n8n.inouter.com | 200 ✅ | +| ArgoCD | argocd.inouter.com | 200 ✅ | +| Grafana | grafana.inouter.com | 302 ✅ | +| SearXNG | searxng.inouter.com | 200 ✅ | +| SafeLine | safeline.inouter.com | 200 ✅ | +| Namecheap API | namecheap-api.anvil.it.com | 403 ✅ | +| Vultr API | vultr-api.anvil.it.com | 403 ✅ | +| OpenMemory | mem0.inouter.com | MCP 서버 (웹 응답 없음) | +| BunnyCDN MCP | bunny.inouter.com | MCP 서버 (웹 응답 없음) | +| Gitea Runner | declare successfully ✅ | Tailscale 직접 접속, 와일드카드 인증서 정상 | + ## HTTPRoute 목록 | Namespace | Name | Hosts | Port | diff --git a/infra/k3s-migration.md b/infra/k3s-migration.md index 560a59b..8f65cfd 100644 --- a/infra/k3s-migration.md +++ b/infra/k3s-migration.md @@ -71,12 +71,18 @@ hp2: k3s server (컨트롤 플레인 + 워커) 192.168.9.134 ## 마이그레이션 순서 -### Phase 0: 새 클러스터 인프라 구성 ✅ 완료 (2026-03-24) +### Phase 0: 새 클러스터 인프라 구성 ✅ 완료 (2026-03-24~25) - cert-manager v1.20.0 + Google Trust ClusterIssuer ✅ - 와일드카드 인증서 6개 (inouter/anvil/actions/ironclad/keepanker/servidor) ✅ - Reflector ✅ -- Traefik v3.6.11 (DaemonSet, Gateway API, HTTP/HTTPS/TCP) ✅ -- APISIX (hostNetwork, replica 1) ✅ +- **Traefik DaemonSet (hostPort 80/443) + Gateway API → 메인 라우팅** ✅ (2026-03-25) + - TLSStore CRD로 와일드카드 인증서 기본 로드 + - 전 서비스 정상 확인 (NocoDB, Gitea, n8n, ArgoCD, Grafana, SearXNG, SafeLine 등) + - Gitea Runner: Tailscale 직접 접속 + 와일드카드 인증서 정상 + - CoreDNS hairpin: traefik.kube-system.svc.cluster.local +- APISIX replica 1 (SafeLine WAF 전용으로 축소) ✅ + - APISIX Ingress Controller 제거 (GatewayProxy 모드 플러그인 제한 문제) +- HAProxy 80/443 → Traefik hostPort로 복원 ✅ - Longhorn v1.8.2 ✅ - HAProxy/nftables에서 kr2 제거 완료 ✅