This commit is contained in:
s871077
2026-09-11 10:11:09 +08:00
parent e25c995560
commit 58587d19a8
25 changed files with 1643 additions and 54 deletions
+90
View File
@@ -0,0 +1,90 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "it-cost-dashboard.fullname" . }}-server
labels:
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "server") | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "server") | nindent 6 }}
template:
metadata:
labels:
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "server") | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
# Without this the server starts before MySQL, Prisma throws, the pod
# CrashLoopBackOffs, and `helm --atomic --wait` rolls the whole release
# back.
- name: wait-for-db
image: busybox:1.36
command:
- sh
- -c
- |
until nc -z {{ include "it-cost-dashboard.dbServiceName" . }} {{ .Values.db.port }}; do
echo "waiting for {{ include "it-cost-dashboard.dbServiceName" . }}:{{ .Values.db.port }}..."
sleep 3
done
echo "database is accepting connections"
containers:
- name: server
image: "{{ required "server.image.repository is required" .Values.server.image.repository }}:{{ required "server.image.tag is required" .Values.server.image.tag }}"
imagePullPolicy: {{ .Values.server.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.server.service.port }}
protocol: TCP
env:
- name: NODE_ENV
value: "production"
- name: NEXT_TELEMETRY_DISABLED
value: "1"
envFrom:
- secretRef:
name: {{ include "it-cost-dashboard.fullname" . }}-server-secret
# Readiness hits a DB-backed route on purpose: a pod only takes
# traffic once MySQL is reachable AND the schema is right.
# NOTE (SSO restore): /api/years will 307 to /login once the
# middleware is back on, which is non-2xx — add a public /api/health
# route and probe that instead.
readinessProbe:
httpGet:
path: /api/years
port: http
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
# 12 x 5s tolerates a slow first-boot seed.
failureThreshold: 12
# Liveness deliberately differs: /login needs no DB, so a transient
# MySQL blip makes pods unready (traffic stops) without kubelet
# killing them in a restart storm.
livenessProbe:
httpGet:
path: /login
port: http
initialDelaySeconds: 30
periodSeconds: 20
timeoutSeconds: 5
failureThreshold: 6
resources:
{{- toYaml .Values.server.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}