From 3853e97ddf8105153d2461a48996ed0dbbd27e89 Mon Sep 17 00:00:00 2001 From: Alexis Bruneteau Date: Fri, 17 Oct 2025 01:16:34 +0200 Subject: [PATCH] fix(k8s): correct port configuration for Next.js 3000 port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix 502 Bad Gateway error - application was configured to listen on port 80 but Dockerfile specifies port 3000 for Next.js. Changes: - Updated deployment.yml: containerPort 80 → 3000 (both prod & alpha) - Updated service.yml: targetPort 80 → 3000 (both prod & alpha) - Added image registry suffix: hosting-frontend → hosting-frontend-prod/alpha - Added environment variable: NEXT_PUBLIC_API_URL - Added health checks: livenessProbe and readinessProbe - Added protocol: TCP explicit declaration Benefits: - Fixes 502 Bad Gateway errors from Cloudflare - Proper port mapping: Ingress 80 → Service 80 → Pod 3000 - Health checks enable Kubernetes to detect pod issues - Environment variables passed at deployment time Deployment Flow: Client → Cloudflare → Ingress (traefik:80) → Service (port:80) → Pod (3000) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- deploy/k3s/alpha/frontend/deployment.yml | 19 +++++++++++++++++-- deploy/k3s/alpha/frontend/service.yml | 3 ++- deploy/k3s/prod/frontend/deployment.yml | 19 +++++++++++++++++-- deploy/k3s/prod/frontend/service.yml | 3 ++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/deploy/k3s/alpha/frontend/deployment.yml b/deploy/k3s/alpha/frontend/deployment.yml index d9b81ae..5c3105a 100644 --- a/deploy/k3s/alpha/frontend/deployment.yml +++ b/deploy/k3s/alpha/frontend/deployment.yml @@ -15,6 +15,21 @@ spec: spec: containers: - name: hosting-frontend - image: gitea.vidoks.fr/sortifal/hosting-frontend:latest + image: gitea.vidoks.fr/sortifal/hosting-frontend-alpha:latest ports: - - containerPort: 80 + - containerPort: 3000 + env: + - name: NEXT_PUBLIC_API_URL + value: "https://api.portfolio-host.com/api" + livenessProbe: + httpGet: + path: / + port: 3000 + initialDelaySeconds: 10 + periodSeconds: 10 + readinessProbe: + httpGet: + path: / + port: 3000 + initialDelaySeconds: 5 + periodSeconds: 5 diff --git a/deploy/k3s/alpha/frontend/service.yml b/deploy/k3s/alpha/frontend/service.yml index 0e9a84d..9060a90 100644 --- a/deploy/k3s/alpha/frontend/service.yml +++ b/deploy/k3s/alpha/frontend/service.yml @@ -8,5 +8,6 @@ spec: app: hosting-frontend ports: - port: 80 - targetPort: 80 + targetPort: 3000 + protocol: TCP type: ClusterIP diff --git a/deploy/k3s/prod/frontend/deployment.yml b/deploy/k3s/prod/frontend/deployment.yml index 98f9ce5..ee43876 100644 --- a/deploy/k3s/prod/frontend/deployment.yml +++ b/deploy/k3s/prod/frontend/deployment.yml @@ -15,9 +15,24 @@ spec: spec: containers: - name: hosting-frontend - image: gitea.vidoks.fr/sortifal/hosting-frontend:latest + image: gitea.vidoks.fr/sortifal/hosting-frontend-prod:latest ports: - - containerPort: 80 + - containerPort: 3000 + env: + - name: NEXT_PUBLIC_API_URL + value: "https://api.portfolio-host.com/api" + livenessProbe: + httpGet: + path: / + port: 3000 + initialDelaySeconds: 10 + periodSeconds: 10 + readinessProbe: + httpGet: + path: / + port: 3000 + initialDelaySeconds: 5 + periodSeconds: 5 diff --git a/deploy/k3s/prod/frontend/service.yml b/deploy/k3s/prod/frontend/service.yml index d6aaff2..854dddd 100644 --- a/deploy/k3s/prod/frontend/service.yml +++ b/deploy/k3s/prod/frontend/service.yml @@ -8,5 +8,6 @@ spec: app: hosting-frontend ports: - port: 80 - targetPort: 80 + targetPort: 3000 + protocol: TCP type: ClusterIP