feat: Add Helm chart for Kubernetes deployment (#1)
Some checks are pending
Stale Issues / stale (push) Successful in 1m10s
Release / Release (push) Successful in 3m32s
Release / Build & Push Docker Image (push) Has been skipped
Nightly Build / Build Nightly Image (push) Has started running

## Description

Add complete Helm chart for deploying the CV application to Kubernetes. The chart includes all necessary resources for a production-ready deployment with persistent storage and configurable authentication modes.

## Type of Change

- [x] `feat` - New feature (minor version bump)

## Breaking Changes

- [ ] This is a breaking change (major version bump)

**If breaking, describe the migration path:**

## Checklist

- [x] Commit messages follow [Conventional Commits](CONTRIBUTING.md#commit-guidelines)
- [x] Lint passes (`npm run lint`) - N/A for Helm charts
- [x] Build succeeds (`npm run build`) - N/A for Helm charts
- [x] Tests pass (`npm run test:run`) - N/A for Helm charts
- [ ] API documentation updated (if applicable)

## Testing

- `helm lint` passes on the chart
- `helm template test-release helm/cv-app/` renders 214 lines of valid Kubernetes manifests
- Verified all template helpers function correctly
- Tested conditional rendering (persistence enabled/disabled, simple/keycloak auth modes)

## Screenshots (if applicable)

N/A

## Related Issues

Implements the Helm chart design from `docs/plans/2026-02-23-helm-chart-design.md`

Co-authored-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-02-24 22:27:45 +01:00
parent 8b5e12fa0a
commit 8deb3dcd9f
16 changed files with 1543 additions and 0 deletions

17
helm/cv-app/.helmignore Normal file
View File

@@ -0,0 +1,17 @@
# Patterns to ignore when building packages.
.git/
.github/
.vscode/
.idea/
# Test files
*_test.go
tests/
# Documentation
*.md
!README.md
docs/
# CI/CD
.github/

9
helm/cv-app/Chart.yaml Normal file
View File

@@ -0,0 +1,9 @@
apiVersion: v2
name: cv-app
description: A Helm chart for CV application
type: application
version: 0.1.0
appVersion: "1.0.0"
maintainers:
- name: Tuan-Dat Tran
email: tuan-dat.tran@tudattr.dev

View File

@@ -0,0 +1,27 @@
Your CV application has been deployed!
Access your application at:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}
{{- end }}
{{- else }}
Frontend: http://{{ include "cv-app.fullname" . }}-frontend.{{ .Release.Namespace }}.svc.cluster.local
Backend API: http://{{ include "cv-app.fullname" . }}-backend.{{ .Release.Namespace }}.svc.cluster.local:3001
{{- end }}
{{- if eq .Values.backend.auth.mode "simple" }}
Get the admin password:
kubectl logs deployment/{{ include "cv-app.fullname" . }}-backend | grep "ADMIN PASSWORD"
{{- end }}
API Documentation:
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.tls }}
https://{{ (index .Values.ingress.hosts 0).host }}/api/docs
{{- else }}
http://{{ (index .Values.ingress.hosts 0).host }}/api/docs
{{- end }}
{{- else }}
http://{{ include "cv-app.fullname" . }}-backend.{{ .Release.Namespace }}.svc.cluster.local:3001/api/docs
{{- end }}

View File

@@ -0,0 +1,42 @@
{{- define "cv-app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "cv-app.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{- define "cv-app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "cv-app.labels" -}}
helm.sh/chart: {{ include "cv-app.chart" . }}
{{ include "cv-app.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "cv-app.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cv-app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "cv-app.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cv-app.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,80 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cv-app.fullname" . }}-backend
labels:
{{- include "cv-app.labels" . | nindent 4 }}
app.kubernetes.io/component: backend
spec:
replicas: {{ .Values.backend.replicaCount }}
selector:
matchLabels:
{{- include "cv-app.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: backend
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "cv-app.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: backend
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "cv-app.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: backend
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
ports:
- name: http
containerPort: 3001
protocol: TCP
envFrom:
- configMapRef:
name: {{ include "cv-app.fullname" . }}-config
- secretRef:
name: {{ include "cv-app.fullname" . }}-secret
volumeMounts:
- name: data
mountPath: /app/data
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
resources:
{{- toYaml .Values.backend.resources | nindent 12 }}
volumes:
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "cv-app.fullname" . }}-data
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "cv-app.fullname" . }}-backend
labels:
{{- include "cv-app.labels" . | nindent 4 }}
app.kubernetes.io/component: backend
spec:
type: ClusterIP
ports:
- port: 3001
targetPort: http
protocol: TCP
name: http
selector:
{{- include "cv-app.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: backend

View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "cv-app.fullname" . }}-config
labels:
{{- include "cv-app.labels" . | nindent 4 }}
data:
PORT: "3001"
DB_PATH: "/app/data/cv.db"
AUTH_MODE: {{ .Values.backend.auth.mode | quote }}
{{- if eq .Values.backend.auth.mode "keycloak" }}
KEYCLOAK_URL: {{ .Values.backend.keycloak.url | quote }}
KEYCLOAK_REALM: {{ .Values.backend.keycloak.realm | quote }}
KEYCLOAK_CLIENT_ID: {{ .Values.backend.keycloak.clientId | quote }}
{{- end }}

View File

@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cv-app.fullname" . }}-frontend
labels:
{{- include "cv-app.labels" . | nindent 4 }}
app.kubernetes.io/component: frontend
spec:
replicas: {{ .Values.frontend.replicaCount }}
selector:
matchLabels:
{{- include "cv-app.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: frontend
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "cv-app.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: frontend
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "cv-app.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: frontend
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.frontend.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "cv-app.fullname" . }}-frontend
labels:
{{- include "cv-app.labels" . | nindent 4 }}
app.kubernetes.io/component: frontend
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
{{- include "cv-app.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: frontend

View File

@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "cv-app.fullname" . }}
labels:
{{- include "cv-app.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: Prefix
backend:
service:
name: {{ include "cv-app.fullname" $ }}-{{ .service }}
port:
number: {{ if eq .service "frontend" }}80{{ else }}3001{{ end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,17 @@
{{- if .Values.persistence.enabled -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "cv-app.fullname" . }}-data
labels:
{{- include "cv-app.labels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
{{- if .Values.persistence.storageClass }}
storageClassName: {{ .Values.persistence.storageClass | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}

View File

@@ -0,0 +1,11 @@
{{- if eq .Values.backend.auth.mode "simple" }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "cv-app.fullname" . }}-secret
labels:
{{- include "cv-app.labels" . | nindent 4 }}
type: Opaque
data:
JWT_SECRET: {{ .Values.backend.auth.jwtSecret | default (randAlphaNum 32) | b64enc | quote }}
{{- end }}

57
helm/cv-app/values.yaml Normal file
View File

@@ -0,0 +1,57 @@
frontend:
replicaCount: 1
image:
repository: username/cv-app
tag: latest
pullPolicy: IfNotPresent
resources: {}
backend:
replicaCount: 1
image:
repository: username/cv-app-backend
tag: latest
pullPolicy: IfNotPresent
auth:
mode: simple
jwtSecret: ""
keycloak:
url: ""
realm: ""
clientId: ""
resources: {}
persistence:
enabled: true
size: 1Gi
storageClass: ""
ingress:
enabled: true
className: ""
annotations: {}
hosts:
- host: cv.local
paths:
- path: /api
service: backend
- path: /
service: frontend
tls: []
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
create: true
annotations: {}
name: ""
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
nodeSelector: {}
tolerations: []
affinity: {}