Skip to content

Commit 977494e

Browse files
committed
chore: wip helm chart configuration
1 parent ee9cc3b commit 977494e

File tree

14 files changed

+614
-1
lines changed

14 files changed

+614
-1
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,8 @@ yarn-error.log*
3939
# typescript
4040
*.tsbuildinfo
4141
next-env.d.ts
42+
43+
# helm
44+
*.tgz
45+
helm/charts/
46+
helm/*.lock

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN corepack enable && corepack prepare [email protected] --activate
1010

1111
WORKDIR /app
1212

13-
# Install dependencies based on the preferred package manager
13+
# Install dependencies
1414
COPY package.json pnpm-lock.yaml* ./
1515
RUN pnpm install --frozen-lockfile
1616

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,33 @@ shell:
5151
rebuild: clean build
5252
@echo "Rebuild complete"
5353

54+
## Build image for minikube
55+
minikube-build:
56+
@echo "Building image for minikube..."
57+
@eval $$(minikube docker-env) && docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
58+
@echo "Image built in minikube Docker daemon"
59+
60+
## Deploy to minikube with Helm
61+
minikube-deploy: minikube-build
62+
@echo "Deploying to minikube..."
63+
@helm upgrade --install toolhive-ui ./helm -f ./helm/values-dev.yaml --wait --timeout=5m
64+
@echo "Deployment complete!"
65+
@echo ""
66+
@echo "To access the application:"
67+
@echo "1. Add to /etc/hosts: echo \"\$$(minikube ip) toolhive-ui.local\" | sudo tee -a /etc/hosts"
68+
@echo "2. Open http://toolhive-ui.local"
69+
70+
## Uninstall from minikube
71+
minikube-uninstall:
72+
@helm uninstall toolhive-ui || true
73+
@echo "Uninstalled from minikube"
74+
75+
## View minikube logs
76+
minikube-logs:
77+
@kubectl logs -f deployment/toolhive-ui-toolhive-cloud-ui
78+
79+
## Port-forward to localhost
80+
minikube-port-forward:
81+
@echo "Forwarding to http://localhost:8080"
82+
@kubectl port-forward svc/toolhive-ui-toolhive-cloud-ui 8080:80
83+

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,39 @@ make clean
4747

4848
# Rebuild from scratch
4949
make rebuild
50+
```
5051

5152
The application will be available at [http://localhost:3000](http://localhost:3000).
5253

54+
## Kubernetes / Minikube Deployment
55+
56+
This project includes a complete Helm chart for deploying to Kubernetes (optimized for minikube).
57+
58+
### Quick Start with Minikube
59+
60+
```bash
61+
# Deploy to minikube (includes build and deployment)
62+
make minikube-deploy
63+
64+
# View logs
65+
make minikube-logs
66+
67+
# Port-forward to localhost:8080
68+
make minikube-port-forward
69+
70+
# Uninstall
71+
make minikube-uninstall
72+
```
73+
74+
The Helm chart is located in the `helm/` directory and includes:
75+
76+
- Deployment with configurable replicas
77+
- Service (ClusterIP/NodePort/LoadBalancer)
78+
- Ingress with customizable rules
79+
- Horizontal Pod Autoscaler (optional)
80+
- Configurable resource limits
81+
- Health checks (startup, liveness and readiness probes)
82+
5383
## Learn More
5484

5585
To learn more about Next.js, take a look at the following resources:

helm/.helmignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
24+

helm/Chart.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v2
2+
name: toolhive-cloud-ui
3+
description: A Helm chart for ToolHive Cloud UI - Next.js application
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
keywords:
8+
- nextjs
9+
- react
10+
- frontend
11+
- ui
12+
home: https://github.com/toolhive/cloud-ui
13+
sources:
14+
- https://github.com/toolhive/cloud-ui
15+
maintainers:
16+
- name: ToolHive Team
17+
kubeVersion: ">=1.24.0-0"

helm/templates/_helpers.tpl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "toolhive-cloud-ui.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "toolhive-cloud-ui.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "toolhive-cloud-ui.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels
33+
*/}}
34+
{{- define "toolhive-cloud-ui.labels" -}}
35+
helm.sh/chart: {{ include "toolhive-cloud-ui.chart" . }}
36+
{{ include "toolhive-cloud-ui.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
app.kubernetes.io/component: frontend
42+
app.kubernetes.io/part-of: toolhive
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "toolhive-cloud-ui.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "toolhive-cloud-ui.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "toolhive-cloud-ui.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "toolhive-cloud-ui.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+

helm/templates/deployment.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "toolhive-cloud-ui.fullname" . }}
5+
labels:
6+
{{- include "toolhive-cloud-ui.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "toolhive-cloud-ui.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "toolhive-cloud-ui.labels" . | nindent 8 }}
22+
{{- with .Values.podLabels }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
spec:
26+
{{- with .Values.imagePullSecrets }}
27+
imagePullSecrets:
28+
{{- toYaml . | nindent 8 }}
29+
{{- end }}
30+
serviceAccountName: {{ include "toolhive-cloud-ui.serviceAccountName" . }}
31+
securityContext:
32+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
33+
containers:
34+
- name: {{ .Chart.Name }}
35+
securityContext:
36+
{{- toYaml .Values.securityContext | nindent 12 }}
37+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
38+
imagePullPolicy: {{ .Values.image.pullPolicy }}
39+
ports:
40+
- name: http
41+
containerPort: {{ .Values.service.targetPort }}
42+
protocol: TCP
43+
{{- if .Values.startupProbe }}
44+
startupProbe:
45+
{{- toYaml .Values.startupProbe | nindent 12 }}
46+
{{- end }}
47+
{{- if .Values.livenessProbe }}
48+
livenessProbe:
49+
{{- toYaml .Values.livenessProbe | nindent 12 }}
50+
{{- end }}
51+
{{- if .Values.readinessProbe }}
52+
readinessProbe:
53+
{{- toYaml .Values.readinessProbe | nindent 12 }}
54+
{{- end }}
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
{{- with .Values.env }}
58+
env:
59+
{{- toYaml . | nindent 12 }}
60+
{{- end }}
61+
{{- with .Values.envFrom }}
62+
envFrom:
63+
{{- toYaml . | nindent 12 }}
64+
{{- end }}
65+
{{- with .Values.volumeMounts }}
66+
volumeMounts:
67+
{{- toYaml . | nindent 12 }}
68+
{{- end }}
69+
{{- with .Values.volumes }}
70+
volumes:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- with .Values.nodeSelector }}
74+
nodeSelector:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}
77+
{{- with .Values.affinity }}
78+
affinity:
79+
{{- toYaml . | nindent 8 }}
80+
{{- end }}
81+
{{- with .Values.tolerations }}
82+
tolerations:
83+
{{- toYaml . | nindent 8 }}
84+
{{- end }}
85+

helm/templates/hpa.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "toolhive-cloud-ui.fullname" . }}
6+
labels:
7+
{{- include "toolhive-cloud-ui.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "toolhive-cloud-ui.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}
33+

helm/templates/ingress.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "toolhive-cloud-ui.fullname" . }}
6+
labels:
7+
{{- include "toolhive-cloud-ui.labels" . | nindent 4 }}
8+
{{- with .Values.ingress.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- if .Values.ingress.className }}
14+
ingressClassName: {{ .Values.ingress.className }}
15+
{{- end }}
16+
{{- if .Values.ingress.tls }}
17+
tls:
18+
{{- range .Values.ingress.tls }}
19+
- hosts:
20+
{{- range .hosts }}
21+
- {{ . | quote }}
22+
{{- end }}
23+
secretName: {{ .secretName }}
24+
{{- end }}
25+
{{- end }}
26+
rules:
27+
{{- range .Values.ingress.hosts }}
28+
- host: {{ .host | quote }}
29+
http:
30+
paths:
31+
{{- range .paths }}
32+
- path: {{ .path }}
33+
pathType: {{ .pathType }}
34+
backend:
35+
service:
36+
name: {{ include "toolhive-cloud-ui.fullname" $ }}
37+
port:
38+
number: {{ $.Values.service.port }}
39+
{{- end }}
40+
{{- end }}
41+
{{- end }}
42+

0 commit comments

Comments
 (0)