update
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: it-cost-dashboard
|
||||
description: Global IT Cost Dashboard — Next.js server + MySQL 8 on self-built k8s
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "0.1.0"
|
||||
@@ -0,0 +1,56 @@
|
||||
{{/* Chart name, overridable. */}}
|
||||
{{- define "it-cost-dashboard.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Fully qualified app name. Kept short: it prefixes the StatefulSet name, which
|
||||
in turn prefixes pod names and the generated PVC names.
|
||||
*/}}
|
||||
{{- define "it-cost-dashboard.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "it-cost-dashboard.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/* Labels applied to every object. */}}
|
||||
{{- define "it-cost-dashboard.labels" -}}
|
||||
helm.sh/chart: {{ include "it-cost-dashboard.chart" . }}
|
||||
{{ include "it-cost-dashboard.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "it-cost-dashboard.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "it-cost-dashboard.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Component-scoped labels. The workflow's rollout-restart selects on
|
||||
app.kubernetes.io/component=server so it does not bounce MySQL.
|
||||
Usage: {{ include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "server") }}
|
||||
*/}}
|
||||
{{- define "it-cost-dashboard.componentLabels" -}}
|
||||
{{ include "it-cost-dashboard.labels" .ctx }}
|
||||
app.kubernetes.io/component: {{ .component }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "it-cost-dashboard.componentSelectorLabels" -}}
|
||||
{{ include "it-cost-dashboard.selectorLabels" .ctx }}
|
||||
app.kubernetes.io/component: {{ .component }}
|
||||
{{- end }}
|
||||
|
||||
{{/* ClusterIP Service name for MySQL — the DATABASE_URL host and the
|
||||
wait-for-db initContainer target. */}}
|
||||
{{- define "it-cost-dashboard.dbServiceName" -}}
|
||||
{{- printf "%s-db" (include "it-cost-dashboard.fullname" .) }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-db-secret
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "db") | nindent 4 }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
# Supplied by the workflow: --set-string secrets.dbRootPassword=...
|
||||
# Constrained to [A-Za-z0-9-]: it is interpolated verbatim into DATABASE_URL
|
||||
# in server-secret.yaml and Helm cannot URL-encode.
|
||||
MYSQL_ROOT_PASSWORD: {{ required "secrets.dbRootPassword is required" .Values.secrets.dbRootPassword | quote }}
|
||||
MYSQL_DATABASE: {{ .Values.db.database | quote }}
|
||||
@@ -0,0 +1,40 @@
|
||||
{{/*
|
||||
Headless service: stable per-pod DNS for the StatefulSet
|
||||
(<fullname>-db-0.<fullname>-db-headless). Required by the StatefulSet spec.
|
||||
*/}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-db-headless
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "db") | nindent 4 }}
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: mysql
|
||||
port: {{ .Values.db.port }}
|
||||
targetPort: mysql
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "db") | nindent 4 }}
|
||||
---
|
||||
{{/*
|
||||
Normal ClusterIP service. This is what DATABASE_URL and the wait-for-db
|
||||
initContainer target — simpler than per-pod DNS and sufficient for a
|
||||
single-primary MySQL.
|
||||
*/}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.dbServiceName" . }}
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "db") | nindent 4 }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: mysql
|
||||
port: {{ .Values.db.port }}
|
||||
targetPort: mysql
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "db") | nindent 4 }}
|
||||
@@ -0,0 +1,97 @@
|
||||
{{/*
|
||||
MySQL as a StatefulSet, not a Deployment: volumeClaimTemplates guarantees a
|
||||
single writer on the gp3 volume, the pod name is stable, and the PVC survives
|
||||
`helm uninstall` so an accidental teardown does not destroy data.
|
||||
*/}}
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-db
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "db") | nindent 4 }}
|
||||
spec:
|
||||
# Single-primary MySQL. NEVER raise this without real clustering — two pods
|
||||
# would fight over one RWO volume / diverge.
|
||||
replicas: 1
|
||||
serviceName: {{ include "it-cost-dashboard.fullname" . }}-db-headless
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "db") | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "db") | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: mysql
|
||||
image: "{{ required "db.image.repository is required" .Values.db.image.repository }}:{{ required "db.image.tag is required" .Values.db.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.db.image.pullPolicy }}
|
||||
ports:
|
||||
- name: mysql
|
||||
containerPort: {{ .Values.db.port }}
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-db-secret
|
||||
key: MYSQL_ROOT_PASSWORD
|
||||
- name: MYSQL_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-db-secret
|
||||
key: MYSQL_DATABASE
|
||||
# Generous initialDelay: the first boot runs both
|
||||
# /docker-entrypoint-initdb.d scripts (schema + 430 seed rows) before
|
||||
# opening TCP for real.
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- 'mysqladmin ping -u root -p"${MYSQL_ROOT_PASSWORD}" --silent'
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 12
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- 'mysqladmin ping -u root -p"${MYSQL_ROOT_PASSWORD}" --silent'
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
volumeMounts:
|
||||
- name: mysql-data
|
||||
mountPath: /var/lib/mysql
|
||||
resources:
|
||||
{{- toYaml .Values.db.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 }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: mysql-data
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: {{ .Values.db.storage.storageClassName }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.db.storage.size }}
|
||||
@@ -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 }}
|
||||
@@ -0,0 +1,24 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-server
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "server") | nindent 4 }}
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
||||
spec:
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
# HTTP only for now — no TLS block until certs are issued for these hosts.
|
||||
rules:
|
||||
- host: {{ required "ingress.host is required" .Values.ingress.host | quote }}
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-server
|
||||
port:
|
||||
name: http
|
||||
{{- end }}
|
||||
@@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-server-secret
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "server") | nindent 4 }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
# Built in-template from the db root password + the db ClusterIP Service name.
|
||||
# TRAP: Helm has no URL-encode function, so secrets.dbRootPassword must avoid
|
||||
# URL-reserved characters (@ : / # ? % + & and space) — keep it [A-Za-z0-9-].
|
||||
DATABASE_URL: "mysql://root:{{ required "secrets.dbRootPassword is required" .Values.secrets.dbRootPassword }}@{{ include "it-cost-dashboard.dbServiceName" . }}:{{ .Values.db.port }}/{{ .Values.db.database }}"
|
||||
|
||||
# Auth.js JWT signing key. Required at runtime even with SSO commented out.
|
||||
AUTH_SECRET: {{ required "secrets.authSecret is required" .Values.secrets.authSecret | quote }}
|
||||
AUTH_TRUST_HOST: "true"
|
||||
|
||||
# Break-glass local login. Empty disables it entirely (src/auth.ts fails closed).
|
||||
LOCAL_ADMIN_PASSWORD: {{ .Values.secrets.localAdminPassword | default "" | quote }}
|
||||
|
||||
# --- SSO DISABLED FOR CICD TEST ---
|
||||
# Kept present but optional. To restore SSO: supply these values from the
|
||||
# per-env GitHub secrets and swap `| default ""` for `| required "..."`.
|
||||
AUTH_MICROSOFT_ENTRA_ID_ID: {{ .Values.secrets.entraClientId | default "" | quote }}
|
||||
AUTH_MICROSOFT_ENTRA_ID_SECRET: {{ .Values.secrets.entraClientSecret | default "" | quote }}
|
||||
AUTH_MICROSOFT_ENTRA_ID_ISSUER: {{ .Values.secrets.entraIssuer | default "" | quote }}
|
||||
AUTH_URL: {{ .Values.secrets.authUrl | default "" | quote }}
|
||||
# --- END SSO DISABLED ---
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "it-cost-dashboard.fullname" . }}-server
|
||||
labels:
|
||||
{{- include "it-cost-dashboard.componentLabels" (dict "ctx" . "component" "server") | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.server.service.type }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ .Values.server.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- include "it-cost-dashboard.componentSelectorLabels" (dict "ctx" . "component" "server") | nindent 4 }}
|
||||
@@ -0,0 +1,34 @@
|
||||
# dev overrides. Image tags come from the workflow (--set ...image.tag=<sha>).
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
server:
|
||||
image:
|
||||
repository: jfrog.trendmicro.com/ameait-it-cost-dashboard/it-cost-dashboard-server-dev
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
db:
|
||||
image:
|
||||
repository: jfrog.trendmicro.com/ameait-it-cost-dashboard/it-cost-dashboard-db-dev
|
||||
storage:
|
||||
size: 5Gi
|
||||
storageClassName: gp3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: 1
|
||||
memory: 1Gi
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
# TODO: point this at a hostname resolving to the ingress-nginx external IP.
|
||||
host: it-cost-dashboard-dev.example.com
|
||||
@@ -0,0 +1,34 @@
|
||||
# prod overrides. Image tags come from the workflow (--set ...image.tag=<gitTag>).
|
||||
|
||||
replicaCount: 2
|
||||
|
||||
server:
|
||||
image:
|
||||
repository: jfrog.trendmicro.com/ameait-it-cost-dashboard/it-cost-dashboard-server-prod
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: 1
|
||||
memory: 1Gi
|
||||
|
||||
db:
|
||||
image:
|
||||
repository: jfrog.trendmicro.com/ameait-it-cost-dashboard/it-cost-dashboard-db-prod
|
||||
storage:
|
||||
size: 20Gi
|
||||
storageClassName: gp3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 1Gi
|
||||
limits:
|
||||
cpu: 2
|
||||
memory: 2Gi
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
# TODO: point this at a hostname resolving to the ingress-nginx external IP.
|
||||
host: it-cost-dashboard.example.com
|
||||
@@ -0,0 +1,67 @@
|
||||
# Base defaults. Per-environment overrides live in values-dev.yaml /
|
||||
# values-prod.yaml; image TAGS are always supplied by the CI workflow via --set
|
||||
# (immutable: commit SHA on dev, git tag on prod) and are never pinned here.
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
server:
|
||||
image:
|
||||
repository: ""
|
||||
tag: ""
|
||||
pullPolicy: IfNotPresent
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 3000
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
|
||||
db:
|
||||
image:
|
||||
repository: ""
|
||||
tag: ""
|
||||
pullPolicy: IfNotPresent
|
||||
port: 3306
|
||||
database: it_cost_dashboard
|
||||
storage:
|
||||
size: 5Gi
|
||||
storageClassName: gp3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: 1
|
||||
memory: 1Gi
|
||||
|
||||
ingress:
|
||||
enabled: true
|
||||
className: nginx
|
||||
host: "" # required per-env
|
||||
|
||||
secrets:
|
||||
authSecret: "" # from GitHub secret AUTH_SECRET_<ENV>
|
||||
# MySQL root password. MUST be [A-Za-z0-9-] only — it is interpolated into
|
||||
# DATABASE_URL and Helm has no URL-encode function.
|
||||
dbRootPassword: "" # from GitHub secret DB_ROOT_PASSWORD_<ENV>
|
||||
# Optional; empty disables local login entirely (src/auth.ts fails closed).
|
||||
localAdminPassword: ""
|
||||
# --- SSO restore: set these (and swap `default ""` for `required` in
|
||||
# templates/server-secret.yaml) when Entra ID is re-enabled ---
|
||||
# entraClientId: ""
|
||||
# entraClientSecret: ""
|
||||
# entraIssuer: ""
|
||||
# authUrl: ""
|
||||
|
||||
# Pre-created manually, once per namespace (see the deploy notes). Not templated:
|
||||
# the kubelet needs it independently of Helm.
|
||||
imagePullSecrets:
|
||||
- name: jfrog-registry-creds
|
||||
|
||||
nodeSelector: {}
|
||||
tolerations: []
|
||||
affinity: {}
|
||||
Reference in New Issue
Block a user