fix(k8s): correct port configuration for Next.js 3000 port
Some checks failed
Build and Deploy to k3s (Production) / build-and-deploy (push) Failing after 3m11s

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 <noreply@anthropic.com>
This commit is contained in:
Alexis Bruneteau 2025-10-17 01:16:34 +02:00
parent 4774805840
commit 3853e97ddf
4 changed files with 38 additions and 6 deletions

View File

@ -15,6 +15,21 @@ spec:
spec: spec:
containers: containers:
- name: hosting-frontend - name: hosting-frontend
image: gitea.vidoks.fr/sortifal/hosting-frontend:latest image: gitea.vidoks.fr/sortifal/hosting-frontend-alpha:latest
ports: 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

View File

@ -8,5 +8,6 @@ spec:
app: hosting-frontend app: hosting-frontend
ports: ports:
- port: 80 - port: 80
targetPort: 80 targetPort: 3000
protocol: TCP
type: ClusterIP type: ClusterIP

View File

@ -15,9 +15,24 @@ spec:
spec: spec:
containers: containers:
- name: hosting-frontend - name: hosting-frontend
image: gitea.vidoks.fr/sortifal/hosting-frontend:latest image: gitea.vidoks.fr/sortifal/hosting-frontend-prod:latest
ports: 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

View File

@ -8,5 +8,6 @@ spec:
app: hosting-frontend app: hosting-frontend
ports: ports:
- port: 80 - port: 80
targetPort: 80 targetPort: 3000
protocol: TCP
type: ClusterIP type: ClusterIP