Skip to content

Commit 2447a64

Browse files
committed
chore: add tilt-based development environment
closes: #41 closes: #135 Introduce a comprehensive Tilt setup for streamlined local development of the Kubeflow Notebooks workspace components (controller, backend, and frontend). Key features: * Orchestrated development workflow: Tiltfile manages the entire development lifecycle including cluster setup, dependency installation, Docker builds, and Kubernetes deployments * Automated infrastructure setup: - Kind cluster creation and verification via setup-kind.sh - Cert-manager installation via setup-cert-manager.sh - CRD installation with proper dependency ordering * Component integration: - Controller: Docker builds with code generation, CRD installation, and Kubernetes deployment with dev-specific overrides (USE_ISTIO=false) - Backend: Docker builds and Kubernetes deployment with port forwarding - Frontend: Local webpack dev server with hot reloading (not containerized for faster iteration) * Frontend Tilt support: - Environment-aware webpack configuration that loads .env.tilt when TILT_ENV=true - New start:tilt npm script for Tilt-specific development - Enables standalone frontend mode with proper backend proxy configuration * Developer experience improvements: - File watching with intelligent exclusions to prevent rebuild loops - Resource dependency management ensuring proper startup order - Optional frontend via ENABLE_FRONTEND environment variable - Comprehensive documentation in DEVELOPMENT.md * Hot reloading and live updates: - Frontend changes reflect immediately via webpack dev server - Controller/backend changes trigger automatic Docker rebuilds and redeployments - Port forwards configured for easy local access This setup enables developers to iterate quickly on all components with minimal manual setup and configuration. Signed-off-by: Andy Stoneberg <[email protected]>
1 parent 2cc4244 commit 2447a64

File tree

7 files changed

+562
-2
lines changed

7 files changed

+562
-2
lines changed
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# Development Guide with Tilt
2+
3+
This directory contains the Tilt configuration for local development of the Kubeflow Notebooks workspace components (controller, backend, and frontend).
4+
5+
## Table of Contents
6+
7+
- [Prerequisites](#prerequisites)
8+
- [Quick Start](#quick-start)
9+
- [Configuration](#configuration)
10+
- [Development Workflow](#development-workflow)
11+
- [Frontend Development](#frontend-development)
12+
- [Troubleshooting](#troubleshooting)
13+
- [Best Practices](#best-practices)
14+
15+
## Prerequisites
16+
17+
Before using Tilt, ensure you have the following installed:
18+
19+
- [Tilt](https://docs.tilt.dev/install.html) - v0.30.0 or later
20+
- [Docker](https://docs.docker.com/get-docker/) - for building and running containers
21+
- [Kubernetes cluster](https://kubernetes.io/docs/setup/) - a local cluster (e.g., [Kind](https://kind.sigs.k8s.io/))
22+
- [kubectl](https://kubernetes.io/docs/tasks/tools/) - configured to connect to your cluster
23+
- [Go](https://golang.org/doc/install) - v1.21.0 or later (for controller and backend)
24+
- [Node.js](https://nodejs.org/) - v20.0.0 or later (for frontend)
25+
26+
### Verify Prerequisites
27+
28+
```bash
29+
# Check Tilt
30+
tilt version
31+
32+
# Check Docker
33+
docker --version
34+
35+
# Check kubectl
36+
kubectl version --client
37+
38+
# Check Go (for controller/backend)
39+
go version
40+
41+
# Check Node.js (for frontend, if enabled)
42+
node --version
43+
npm --version
44+
```
45+
46+
### Install Kind (Optional)
47+
48+
**Note**: Tilt will automatically create a Kind cluster named `tilt` if it doesn't exist. However, you still need to have `kind` installed.
49+
50+
```bash
51+
# macOS
52+
brew install kind
53+
54+
# Or follow instructions at: https://kind.sigs.k8s.io/docs/user/quick-start/#installation
55+
```
56+
57+
**Alternative**: If you prefer to use a different Kubernetes cluster (Docker Desktop, Minikube, etc.), you can skip Kind installation. Just ensure your cluster is running and `kubectl` is configured to use it. Tilt will detect and use your current `kubectl` context.
58+
59+
## Quick Start
60+
61+
1. **Navigate to the developing directory**:
62+
```bash
63+
cd workspaces/developing
64+
```
65+
66+
2. **Start Tilt**:
67+
```bash
68+
tilt up
69+
```
70+
71+
This will:
72+
- Open the Tilt UI in your browser (usually http://localhost:10350)
73+
- Build the controller and backend Docker images
74+
- Deploy them to your Kubernetes cluster
75+
- Run the frontend locally with webpack dev server (if enabled)
76+
- Set up port forwards for easy access
77+
- Enable live updates when you make code changes
78+
79+
3. **Monitor the Build**:
80+
81+
Watch the Tilt UI in your browser. You should see:
82+
83+
1. **Setup Resources** (one-time setup):
84+
- `setup-kind` - Creating/verifying Kind cluster (if using Kind)
85+
- `setup-cert-manager` - Installing cert-manager (required for webhooks)
86+
- `install-crds` - Installing CRDs
87+
88+
2. **Local Resources**:
89+
- `controller-generate` - Generating manifests and code
90+
- `workspaces-frontend` - Running webpack dev server (if enabled)
91+
92+
3. **Docker Resources** (building images):
93+
- `workspaces-controller`
94+
- `workspaces-backend`
95+
96+
4. **Kubernetes Resources** (deploying):
97+
- Deployments, Services, etc.
98+
99+
Wait until all resources show green/healthy status.
100+
101+
5. **Access the componenets**:
102+
- Controller health: `http://localhost:8081/healthz`
103+
- Backend API: [Swagger UI](http://localhost:4000/api/v1/swagger/)
104+
- Frontend UI: `http://localhost:9000` (if enabled)
105+
106+
6. **Stop Tilt**:
107+
```bash
108+
# In the terminal where Tilt is running, press Ctrl+C
109+
# Or in another terminal:
110+
tilt down
111+
```
112+
113+
This will:
114+
- Stop all Tilt-managed resources
115+
- Clean up deployments (but not the namespace)
116+
117+
### Optional: Clean up namespace
118+
119+
```bash
120+
kubectl delete namespace kubeflow-workspaces
121+
```
122+
123+
### Optional: Delete Kind cluster
124+
125+
```bash
126+
kind delete cluster --name tilt
127+
```
128+
129+
## Configuration
130+
131+
### Skipping Frontend
132+
133+
To run Tilt without the frontend (useful for backend/controller-only development):
134+
135+
```bash
136+
ENABLE_FRONTEND=false tilt up
137+
```
138+
139+
### Custom Ports
140+
141+
Port forwards are configured in the Tiltfile. To change them, edit the `port_forwards` parameter in the `k8s_resource()` calls.
142+
143+
## Development Workflow
144+
145+
1. **Make code changes** in any of the workspace components
146+
- Keep changes focused and small
147+
2. **Tilt automatically detects changes**:
148+
- Controller/Backend: Rebuilds Docker images and redeploys
149+
- Frontend: Webpack dev server hot-reloads changes automatically
150+
3. **View logs** in the Tilt UI or via `tilt logs <resource-name>`
151+
4. **Add tests** for any new features
152+
5. **Run linting checks** to ensure code style consistency
153+
5. **Ensure tests pass** before opening a PR
154+
6. **Write meaningful commit messages** highlighting what your code contribution is doing
155+
7. **Be responsive** to feedback on the PR
156+
157+
## Frontend Development
158+
159+
The frontend runs as a local resource using webpack dev server instead of being built into a Docker image. This provides:
160+
161+
1. **Fast Hot Reloading**: Changes appear instantly in the browser without rebuilding Docker images
162+
2. **Better Developer Experience**: Full webpack dev server features (source maps, hot module replacement, etc.)
163+
3. **Faster Iteration**: No Docker build step needed for frontend changes
164+
4. **Proxy Configuration**: Webpack dev server proxies API requests to the backend running in Kubernetes
165+
166+
The frontend uses the `.env.tilt` file for configuration when running with Tilt, which sets it up for standalone mode with proper proxy settings to connect to the backend.
167+
168+
## Troubleshooting
169+
170+
### Build Failures
171+
172+
If builds fail, check:
173+
174+
```bash
175+
# Controller build issues
176+
cd workspaces/controller && make build
177+
178+
# Backend build issues
179+
cd workspaces/backend && make build
180+
181+
# Frontend dev server issues (for Tilt development)
182+
cd workspaces/frontend && npm ci && npm run start:tilt
183+
184+
# Frontend production build issues (for testing production builds)
185+
cd workspaces/frontend && npm ci && npm run build:prod
186+
```
187+
188+
Also verify:
189+
- All prerequisites are installed
190+
- Makefiles can find their dependencies
191+
- Go modules are downloaded (`go mod download` in controller/backend)
192+
- Node modules are installed (`npm ci` in frontend)
193+
194+
#### BuildKit
195+
196+
If you see the following error while `Tilt` is trying to build an image:
197+
```
198+
Build Failed: failed to dial gRPC: unable to upgrade to h2c, received 404
199+
```
200+
201+
Try disabling Docker BuildKit support in the terminal where you are running `tilt up`:
202+
```bash
203+
export DOCKER_BUILDKIT=0
204+
```
205+
206+
207+
### Kubernetes Connection Issues
208+
209+
Ensure:
210+
- `kubectl` is configured correctly (`kubectl cluster-info`)
211+
- Your cluster is running and accessible
212+
- You have permissions to create resources in the `kubeflow-workspaces` namespace
213+
214+
```bash
215+
# Verify cluster is accessible
216+
kubectl cluster-info
217+
218+
# Check current context
219+
kubectl config current-context
220+
221+
# List available contexts
222+
kubectl config get-contexts
223+
```
224+
225+
### Port Already in Use
226+
227+
If ports are already in use, you can:
228+
229+
1. Stop the conflicting service
230+
2. Or modify port forwards in the Tiltfile
231+
232+
### CRD Installation Fails
233+
234+
If CRDs fail to install:
235+
236+
```bash
237+
# Check if you have permissions
238+
kubectl auth can-i create crds
239+
240+
# Try installing manually
241+
cd workspaces/controller && make install
242+
```
243+
244+
Also check that you have cluster-admin permissions or appropriate RBAC.
245+
246+
## Best Practices
247+
248+
1. **Run tests before committing**:
249+
```bash
250+
# Controller
251+
cd workspaces/controller && make lint && make test
252+
253+
# Backend
254+
cd workspaces/backend && make lint && make test
255+
256+
# Frontend
257+
cd workspaces/frontend && npm run test
258+
```
259+
260+
2. **Keep dependencies up to date**:
261+
- Go modules: `go mod tidy` in controller/backend
262+
- Node modules: `npm ci` in frontend
263+
264+
3. **Clean up resources**:
265+
- Always run `tilt down` when done
266+
- Optionally: `kubectl delete namespace kubeflow-workspaces`

0 commit comments

Comments
 (0)