Skip to content

Commit c01c4f3

Browse files
committed
chore: use kind and test helm chart on ci
1 parent 9e7f7ad commit c01c4f3

File tree

5 files changed

+213
-35
lines changed

5 files changed

+213
-35
lines changed

.github/workflows/helm-test.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Helm Chart Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "helm/**"
8+
- ".github/workflows/helm-test.yml"
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- "helm/**"
13+
- ".github/workflows/helm-test.yml"
14+
15+
jobs:
16+
test-helm-chart:
17+
name: Test Helm Chart with Kind
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@2856a9e524044420f517685a4655470535401539 # v3.0.0
26+
27+
- name: Build Docker image
28+
uses: docker/build-push-action@e2a61776269e8d6936392d704d05a56504c68377 # v6.0.0
29+
with:
30+
context: .
31+
load: true
32+
tags: toolhive-cloud-ui:latest
33+
cache-from: type=gha
34+
cache-to: type=gha,mode=max
35+
36+
- name: Create Kind cluster
37+
uses: helm/kind-action@026472392573094226832982b6a5182641d20195 # v1.0.0
38+
with:
39+
cluster_name: toolhive-test
40+
wait: 120s
41+
42+
- name: Load image into Kind
43+
run: |
44+
kind load docker-image toolhive-cloud-ui:latest --name toolhive-test
45+
46+
- name: Install Helm chart
47+
run: |
48+
helm upgrade --install toolhive-cloud-ui ./helm \
49+
-f ./helm/values-dev.yaml \
50+
--wait \
51+
--timeout=5m
52+
53+
- name: Check deployment status
54+
run: |
55+
kubectl get pods -l app.kubernetes.io/name=toolhive-cloud-ui
56+
kubectl get svc -l app.kubernetes.io/name=toolhive-cloud-ui
57+
58+
- name: Verify application is responding
59+
run: |
60+
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=toolhive-cloud-ui --timeout=120s
61+
kubectl port-forward svc/toolhive-cloud-ui 8080:80 &
62+
sleep 5
63+
curl -f http://localhost:8080 || (kubectl logs -l app.kubernetes.io/name=toolhive-cloud-ui && exit 1)
64+
65+
- name: Run Helm tests (if any)
66+
run: |
67+
helm test toolhive-cloud-ui || echo "No tests defined"
68+
69+
- name: Show logs on failure
70+
if: failure()
71+
run: |
72+
kubectl get all -l app.kubernetes.io/name=toolhive-cloud-ui
73+
kubectl describe pods -l app.kubernetes.io/name=toolhive-cloud-ui
74+
kubectl logs -l app.kubernetes.io/name=toolhive-cloud-ui --tail=100

.github/workflows/lint-helm.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Lint Helm Chart
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "helm/**"
8+
- ".github/workflows/lint-helm.yml"
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- "helm/**"
13+
- ".github/workflows/lint-helm.yml"
14+
15+
jobs:
16+
lint-chart:
17+
name: Lint Helm Chart
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Helm
27+
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
28+
with:
29+
version: "latest"
30+
31+
- name: Run Helm lint
32+
run: |
33+
helm lint ./helm
34+
helm lint ./helm -f ./helm/values-dev.yaml
35+
36+
- name: Validate templates
37+
run: |
38+
helm template toolhive-ui ./helm --debug
39+
helm template toolhive-ui ./helm -f ./helm/values-dev.yaml --debug
40+
41+
- name: Check for Kubernetes API deprecations
42+
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
43+
44+
- name: Run chart-testing (lint)
45+
run: |
46+
ct lint --target-branch main --charts helm/

Makefile

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,27 @@ PORT := 3000
88

99
## Show this help message
1010
help:
11-
@echo "Available commands:"
12-
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //' | awk 'NR%2==1{printf "\033[36m%-15s\033[0m ",$$1} NR%2==0{print}'
11+
@echo "ToolHive Cloud UI - Available Commands"
12+
@echo ""
13+
@echo "Docker (Local Development):"
14+
@echo " make build - Build production Docker image"
15+
@echo " make start - Start Docker container"
16+
@echo " make stop - Stop Docker container"
17+
@echo " make logs - View container logs"
18+
@echo " make clean - Remove container and image"
19+
@echo " make rebuild - Clean and rebuild"
20+
@echo ""
21+
@echo "Kind (Kubernetes):"
22+
@echo " make kind-setup - Create cluster and deploy (first time)"
23+
@echo " make kind-create - Create Kind cluster"
24+
@echo " make kind-deploy - Build and deploy to Kind"
25+
@echo " make kind-port-forward - Port-forward to localhost:8080"
26+
@echo " make kind-logs - View application logs"
27+
@echo " make kind-uninstall - Uninstall from Kind"
28+
@echo " make kind-delete - Delete Kind cluster"
29+
@echo ""
30+
@echo "Development:"
31+
@echo " make dev - Run Next.js dev server"
1332

1433
## Build the production docker image
1534
build:
@@ -51,33 +70,52 @@ shell:
5170
rebuild: clean build
5271
@echo "Rebuild complete"
5372

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
73+
## Create Kind cluster
74+
kind-create:
75+
@echo "Creating Kind cluster..."
76+
@kind create cluster --name toolhive || echo "Cluster already exists"
77+
@kubectl cluster-info --context kind-toolhive
78+
@echo "Kind cluster ready!"
79+
80+
## Delete Kind cluster
81+
kind-delete:
82+
@echo "Deleting Kind cluster..."
83+
@kind delete cluster --name toolhive
84+
@echo "Cluster deleted"
85+
86+
## Build and load image into Kind
87+
kind-build:
88+
@echo "Building Docker image..."
89+
@docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
90+
@echo "Loading image into Kind cluster..."
91+
@kind load docker-image $(IMAGE_NAME):$(IMAGE_TAG) --name toolhive
92+
@echo "Image loaded successfully"
93+
94+
## Deploy to Kind with Helm
95+
kind-deploy: kind-build
96+
@echo "Deploying to Kind..."
97+
@helm upgrade --install toolhive-cloud-ui ./helm -f ./helm/values-dev.yaml --wait --timeout=5m
6498
@echo "Deployment complete!"
6599
@echo ""
66100
@echo "To access the application, run:"
67-
@echo " make minikube-port-forward"
101+
@echo " make kind-port-forward"
68102
@echo "Then open: http://localhost:8080"
69103

70-
## Uninstall from minikube
71-
minikube-uninstall:
72-
@helm uninstall toolhive-ui || true
73-
@echo "Uninstalled from minikube"
104+
## Uninstall from Kind
105+
kind-uninstall:
106+
@helm uninstall toolhive-cloud-ui || true
107+
@echo "Uninstalled from Kind"
74108

75-
## View minikube logs
76-
minikube-logs:
77-
@kubectl logs -f deployment/toolhive-ui-toolhive-cloud-ui
109+
## View logs
110+
kind-logs:
111+
@kubectl logs -f deployment/toolhive-cloud-ui
78112

79113
## Port-forward to localhost
80-
minikube-port-forward:
114+
kind-port-forward:
81115
@echo "Forwarding to http://localhost:8080"
82-
@kubectl port-forward svc/toolhive-ui-toolhive-cloud-ui 8080:80
116+
@kubectl port-forward svc/toolhive-cloud-ui 8080:80
117+
118+
## Full setup: create cluster and deploy
119+
kind-setup: kind-create kind-deploy
120+
@echo "Setup complete!"
83121

README.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,39 @@ make rebuild
5151

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

54-
## Kubernetes / Minikube Deployment
54+
## Kubernetes / Kind Deployment
5555

56-
This project includes a complete Helm chart for deploying to Kubernetes (optimized for minikube).
56+
This project includes a complete Helm chart for deploying to Kubernetes (optimized for Kind).
5757

58-
### Quick Start with Minikube
58+
### Quick Start with Kind
5959

6060
```bash
61-
# Deploy to minikube (includes build and deployment)
62-
make minikube-deploy
61+
# Create cluster and deploy (first time)
62+
make kind-setup
6363

64-
# View logs
65-
make minikube-logs
64+
# Or step by step:
65+
# 1. Create Kind cluster
66+
make kind-create
67+
68+
# 2. Deploy application
69+
make kind-deploy
6670

67-
# Port-forward to localhost:8080
68-
make minikube-port-forward
71+
# 3. Access the application
72+
make kind-port-forward
73+
# Then open: http://localhost:8080
74+
75+
# View logs
76+
make kind-logs
6977

7078
# Uninstall
71-
make minikube-uninstall
79+
make kind-uninstall
80+
81+
# Delete cluster
82+
make kind-delete
7283
```
7384

85+
### Helm Chart
86+
7487
The Helm chart is located in the `helm/` directory and includes:
7588

7689
- Deployment with configurable replicas
@@ -80,6 +93,13 @@ The Helm chart is located in the `helm/` directory and includes:
8093
- Health checks (startup, liveness and readiness probes)
8194
- Security contexts following Pod Security Standards
8295

96+
### CI/CD
97+
98+
The chart is automatically tested on every push using GitHub Actions with Kind:
99+
100+
- **Helm Lint**: Validates chart syntax and best practices
101+
- **Integration Test**: Deploys to Kind cluster and verifies the app responds
102+
83103
## Learn More
84104

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

helm/values-dev.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Development values for minikube environment
2-
# Usage: helm install toolhive-ui ./helm -f ./helm/values-dev.yaml
1+
# Development values for local Kubernetes (Kind/Minikube)
2+
# Usage: helm install toolhive-cloud-ui ./helm -f ./helm/values-dev.yaml
33

44
# -- Number of replicas for development
55
replicaCount: 1
66

77
image:
88
# -- Image repository
99
repository: toolhive-cloud-ui
10-
# -- Never pull from registry, use local image for minikube
10+
# -- Never pull from registry, use local image
1111
pullPolicy: Never
1212
# -- Override with "latest" for local development
1313
tag: "latest"

0 commit comments

Comments
 (0)