From e7e1801dcbd1a0ea064d74af161e6049c733620f Mon Sep 17 00:00:00 2001 From: ilopez Date: Thu, 11 Jun 2026 21:58:58 -0500 Subject: [PATCH] =?UTF-8?q?feat(gateway-api):=20ADR-060=20Fase=201.1=20?= =?UTF-8?q?=E2=80=94=20chart=20a=20HTTPRoute=20(Traefik=20+=20Gateway=20AP?= =?UTF-8?q?I)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sincronizado desde repo IDP templates/ (CHART-SYNC-IDP-GITEA-DRIFT). Reemplaza el Ingress (rke2-ingress-nginx, EOL marzo 2026) por HTTPRoute (Gateway API) adjunto al Gateway tenant-gateway que crea stack-deployer (§3c). NetworkPolicy egress kube-system -> traefik-system. FQDN DOT (ADR-082) preservado. Co-Authored-By: Claude Opus 4.8 (1M context) --- helm/APP_NAME/Chart.yaml | 10 +++++- helm/APP_NAME/templates/httproute.yaml | 34 ++++++++++++++++++ helm/APP_NAME/templates/ingress.yaml | 41 ---------------------- helm/APP_NAME/templates/networkpolicy.yaml | 11 +++--- helm/APP_NAME/values.yaml | 31 ++++++++-------- 5 files changed, 64 insertions(+), 63 deletions(-) create mode 100644 helm/APP_NAME/templates/httproute.yaml delete mode 100644 helm/APP_NAME/templates/ingress.yaml diff --git a/helm/APP_NAME/Chart.yaml b/helm/APP_NAME/Chart.yaml index ce19645..bdf58d5 100644 --- a/helm/APP_NAME/Chart.yaml +++ b/helm/APP_NAME/Chart.yaml @@ -1,6 +1,14 @@ apiVersion: v2 name: __APP_NAME__ # Helm chart del Golden Path rest-api/python. +# 0.3.0 (2026-06-13): ADR-060 Fase 1 — migración del shape `Ingress` +# (networking.k8s.io/v1, ingressClassName=nginx) a `HTTPRoute` +# (gateway.networking.k8s.io/v1) adjunto al Gateway `tenant-gateway` (ns apps, +# stack-deployer §3c). El cluster tenant pasa de rke2-ingress-nginx (EOL marzo +# 2026) a Traefik Proxy + Gateway API. TLS / force-ssl-redirect / body-size +# salen del recurso de ruta. values: `ingress` → `httpRoute`; networkPolicy +# ingressControllerNamespace kube-system → traefik-system. Paridad con +# web-backend. GATEWAY-API-MIGRATION (P1). # 0.2.0 (2026-05-19): cambio Ingress controller Traefik (IngressRoute CRD) # → rke2-ingress-nginx (networking.k8s.io/v1 Ingress). Razón: # TENANT-INGRESS-CONTROLLER-MISMATCH (APERTURA COVE Sesión 3) — paridad @@ -10,7 +18,7 @@ name: __APP_NAME__ # tenant-id CON guiones (Gap 5). description: Helm chart del Golden Path rest-api/python type: application -version: 0.2.0 +version: 0.3.0 appVersion: "0.1.0" keywords: - fastapi diff --git a/helm/APP_NAME/templates/httproute.yaml b/helm/APP_NAME/templates/httproute.yaml new file mode 100644 index 0000000..5291503 --- /dev/null +++ b/helm/APP_NAME/templates/httproute.yaml @@ -0,0 +1,34 @@ +{{- if .Values.httpRoute.enabled }} +# HTTPRoute (gateway.networking.k8s.io/v1) — ADR-060 Fase 1. +# El cluster tenant usa Traefik Proxy + Gateway API (reemplaza rke2-ingress-nginx, +# EOL marzo 2026). El recurso `Gateway` `tenant-gateway` (ns apps) lo crea +# stack-deployer por tenant (ADR-060 D7 / §3c de su spec); este HTTPRoute se le +# adjunta vía parentRefs. Paridad con el shape web-backend/python. +# +# Lo que NO vive aquí (separación de capas — ADR-060 D6): +# - TLS: lo termina el listener HTTPS del Gateway (Secret `tenant-wildcard-tls`, +# cert-manager local, ADR-060 Fase 2). El HTTPRoute solo declara el hostname. +# - force-ssl-redirect: config global de Traefik Proxy (ports.web.redirectTo). +# - proxy-body-size: config global de Traefik / Middleware si se necesita. +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ .Release.Name }} + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + parentRefs: + - name: {{ .Values.httpRoute.gatewayName | default "tenant-gateway" }} + namespace: {{ .Release.Namespace }} + sectionName: https + hostnames: + - {{ .Values.httpRoute.host | quote }} + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: {{ .Release.Name }} + port: {{ .Values.service.port }} +{{- end }} diff --git a/helm/APP_NAME/templates/ingress.yaml b/helm/APP_NAME/templates/ingress.yaml deleted file mode 100644 index c74540c..0000000 --- a/helm/APP_NAME/templates/ingress.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Values.ingress.enabled }} -# Ingress estándar networking.k8s.io/v1 con ingressClassName=nginx. -# Razón: el cluster tenant nace con rke2-ingress-nginx por default — -# instalar Traefik añade footprint e inconsistencia respecto al control -# plane (donde Traefik sí está). NGINX Ingress es más portable y permite -# que el tenant siga su exit plan sin lock-in. Además RKE2 es la -# distribución certificada CIS Kubernetes Benchmark con soporte SUSE CSP -# — sustituir el ingress controller default rompe la certificación. -# Decisión: APERTURA COVE Sesión 3 (2026-05-19) — ADR-053 §11.1 -# (replicado al shape rest-api/python por paridad). -# Nota: el shape rest-api/python es stateless por diseño; proxyBodySize -# default 1m es suficiente para payloads JSON típicos. Sube vía values -# si necesitás aceptar uploads más grandes. -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ .Release.Name }} - labels: - {{- include "app.labels" . | nindent 4 }} - annotations: - nginx.ingress.kubernetes.io/force-ssl-redirect: "true" - nginx.ingress.kubernetes.io/ssl-redirect: "true" - nginx.ingress.kubernetes.io/proxy-body-size: {{ .Values.ingress.proxyBodySize | default "1m" | quote }} -spec: - ingressClassName: {{ .Values.ingress.className | default "nginx" }} - tls: - - hosts: - - {{ .Values.ingress.host | quote }} - secretName: {{ .Values.ingress.tlsSecretName | default "apps-wildcard-tls" }} - rules: - - host: {{ .Values.ingress.host | quote }} - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: {{ .Release.Name }} - port: - number: {{ .Values.service.port }} -{{- end }} diff --git a/helm/APP_NAME/templates/networkpolicy.yaml b/helm/APP_NAME/templates/networkpolicy.yaml index fad9e47..c11e73b 100644 --- a/helm/APP_NAME/templates/networkpolicy.yaml +++ b/helm/APP_NAME/templates/networkpolicy.yaml @@ -1,9 +1,10 @@ {{- if .Values.networkPolicy.enabled }} # NetworkPolicy mínima del shape rest-api: bajo deny-all-default del namespace, permite: -# - Ingress: rke2-ingress-nginx (público) + Prometheus (scrape de /metrics). +# - Ingress: Traefik Proxy (público) + Prometheus (scrape de /metrics). # - Egress: DNS, Harbor pull HTTPS. # Sin acceso a ns-addons (rest-api no tiene BD por diseño). -# Nota: el cluster tenant usa rke2-ingress-nginx en kube-system, NO Traefik. +# Nota: el cluster tenant usa Traefik Proxy + Gateway API en ns traefik-system +# (ADR-060 Fase 1; reemplaza rke2-ingress-nginx que corría en kube-system). apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: @@ -17,12 +18,12 @@ spec: policyTypes: [Ingress, Egress] ingress: - # Tráfico HTTP desde rke2-ingress-nginx (Ingress estándar). - # El controller corre en kube-system por default en RKE2. + # Tráfico HTTP desde Traefik Proxy (Gateway API, ADR-060 Fase 1). + # El controller corre en ns traefik-system (lo instala el bundle traefik-bootstrap). - from: - namespaceSelector: matchLabels: - kubernetes.io/metadata.name: {{ .Values.networkPolicy.ingressControllerNamespace | default "kube-system" }} + kubernetes.io/metadata.name: {{ .Values.networkPolicy.ingressControllerNamespace | default "traefik-system" }} ports: - protocol: TCP port: 8000 diff --git a/helm/APP_NAME/values.yaml b/helm/APP_NAME/values.yaml index 1343267..052e27a 100644 --- a/helm/APP_NAME/values.yaml +++ b/helm/APP_NAME/values.yaml @@ -44,25 +44,24 @@ service: type: ClusterIP port: 8000 -ingress: +httpRoute: + # HTTPRoute (Gateway API) — el cluster tenant usa Traefik Proxy + Gateway API + # (ADR-060 Fase 1). El tráfico entra por Traefik vía el Gateway `tenant-gateway` + # del ns apps, creado por stack-deployer por tenant (§3c). Paridad con web-backend. enabled: true - # className por defecto = nginx (rke2-ingress-nginx pre-instalado en cluster tenant). - # Cambiar solo si el tenant trae su propio IngressClass. - className: nginx - # FQDN en formato subdominio (ADR-067 / ADR-082): ..apps.coralware.cloud - # Cubierto por el wildcard A record *.{tenant-uuid}.apps.coralware.cloud (un solo record) - # y el Certificate CR tenant-wildcard-tls emitido por cert-manager local del cluster. + # Nombre del Gateway al que se adjunta el HTTPRoute (parentRefs). Default fijo. + gatewayName: tenant-gateway + # FQDN canónico (ADR-067 / ADR-082): ..apps.coralware.cloud + # Cubierto por el wildcard *.{tenant-uuid}.apps.coralware.cloud y el cert + # tenant-wildcard-tls que TERMINA el listener HTTPS del Gateway (no este route). host: __APP_NAME__.__TENANT_ID__.apps.coralware.cloud - # Secret TLS generado por cert-manager local del cluster tenant (ADR-060 Fase 2). - # cert-manager emite *.{tenant-uuid}.apps.coralware.cloud vía DNS-01 Cloudflare. - tlsSecretName: tenant-wildcard-tls - # Body size para subidas/uploads de la app — rest-api es stateless por - # diseño (sin upload), default conservador 1m. Ajustar si la API acepta - # payloads grandes (ej. file POST). - proxyBodySize: 1m + # NOTA: el TLS (Secret tenant-wildcard-tls), el HTTP->HTTPS redirect y el + # body-size ya NO viven en este recurso (ADR-060 D6): el cert lo termina el + # listener del Gateway; el redirect y el body-size son config global de Traefik. networkPolicy: enabled: true # Namespace donde corre el ingress controller del cluster tenant. - # RKE2 instala rke2-ingress-nginx en kube-system por default. - ingressControllerNamespace: kube-system + # ADR-060 Fase 1: el ingress es Traefik Proxy en ns traefik-system + # (bundle traefik-bootstrap), reemplaza rke2-ingress-nginx (kube-system). + ingressControllerNamespace: traefik-system