Skip to content

Commit 292394e

Browse files
paulovmrandyatmiami
authored andcommitted
chore: avoid double slashes in URL (#80)
Signed-off-by: Paulo Rego <[email protected]>
1 parent 4fb9f94 commit 292394e

File tree

8 files changed

+129
-78
lines changed

8 files changed

+129
-78
lines changed

workspaces/developing/DEVELOPMENT.md renamed to developing/DEVELOPMENT.md

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ node --version
4343
npm --version
4444
```
4545

46-
### Install Kind (Optional)
46+
### Install Kind
4747

48-
**Note**: Tilt will automatically create a Kind cluster named `tilt` if it doesn't exist. However, you still need to have `kind` installed.
48+
**Note**: The Makefile will automatically create a Kind cluster named `tilt` if it doesn't exist. However, you still need to have `kind` installed.
4949

5050
```bash
5151
# macOS
@@ -54,21 +54,38 @@ brew install kind
5454
# Or follow instructions at: https://kind.sigs.k8s.io/docs/user/quick-start/#installation
5555
```
5656

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.
57+
58+
### Using Kind Provider (Optional)
59+
60+
You can choose to set the `KIND_EXPERIMENTAL_PROVIDER` environment variable in your shell session:
61+
62+
```bash
63+
export KIND_EXPERIMENTAL_PROVIDER=podman
64+
```
65+
66+
The Makefile will honor this environment variable when creating the Kind cluster.
5867

5968
## Quick Start
6069

6170
1. **Navigate to the developing directory**:
6271
```bash
63-
cd workspaces/developing
72+
cd developing
6473
```
6574

66-
2. **Start Tilt**:
75+
2. **Start Tilt using the Makefile**:
6776
```bash
68-
tilt up
77+
make tilt
6978
```
7079

80+
**Important**: Always use `make tilt` instead of running `tilt up` directly. The Makefile ensures:
81+
- The Kind cluster exists and is properly configured
82+
- The Kubernetes context is switched to `kind-tilt`
83+
- Cert-manager is installed (required for webhooks)
84+
- All prerequisites are met before Tilt starts
85+
7186
This will:
87+
- Set up the Kind cluster (if it doesn't exist)
88+
- Install cert-manager
7289
- Open the Tilt UI in your browser (usually http://localhost:10350)
7390
- Build the controller and backend Docker images
7491
- Deploy them to your Kubernetes cluster
@@ -80,22 +97,20 @@ brew install kind
8097

8198
Watch the Tilt UI in your browser. You should see:
8299

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**:
100+
1. **Local Resources**:
89101
- `controller-generate` - Generating manifests and code
102+
- `install-crds` - Installing CRDs
90103
- `workspaces-frontend` - Running webpack dev server (if enabled)
91104

92-
3. **Docker Resources** (building images):
105+
2. **Docker Resources** (building images):
93106
- `workspaces-controller`
94107
- `workspaces-backend`
95108

96-
4. **Kubernetes Resources** (deploying):
109+
3. **Kubernetes Resources** (deploying):
97110
- Deployments, Services, etc.
98111

112+
**Note**: The Kind cluster and cert-manager setup are handled by the Makefile before Tilt starts, so you won't see those as Tilt resources.
113+
99114
Wait until all resources show green/healthy status.
100115

101116
5. **Access the componenets**:
@@ -107,6 +122,8 @@ brew install kind
107122
```bash
108123
# In the terminal where Tilt is running, press Ctrl+C
109124
# Or in another terminal:
125+
make tilt-down
126+
# Or:
110127
tilt down
111128
```
112129

@@ -128,12 +145,22 @@ kind delete cluster --name tilt
128145

129146
## Configuration
130147

148+
### Makefile Targets
149+
150+
The Makefile provides several targets for managing your development environment:
151+
152+
- `make tilt` or `make` - Set up Kind cluster, install cert-manager, and start Tilt
153+
- `make tilt-up` - Alias for `make tilt`
154+
- `make tilt-down` - Stop Tilt
155+
- `make setup-kind` - Set up the Kind cluster only (without starting Tilt)
156+
- `make setup-cert-manager` - Install cert-manager only (requires Kind cluster)
157+
131158
### Skipping Frontend
132159

133160
To run Tilt without the frontend (useful for backend/controller-only development):
134161

135162
```bash
136-
ENABLE_FRONTEND=false tilt up
163+
ENABLE_FRONTEND=false make tilt
137164
```
138165

139166
### Custom Ports
@@ -206,21 +233,32 @@ export DOCKER_BUILDKIT=0
206233

207234
### Kubernetes Connection Issues
208235

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
236+
The Makefile automatically handles context switching to `kind-tilt`. If you encounter issues:
213237

214-
```bash
215-
# Verify cluster is accessible
216-
kubectl cluster-info
238+
1. **Verify the Kind cluster exists**:
239+
```bash
240+
kind get clusters
241+
```
217242

218-
# Check current context
219-
kubectl config current-context
243+
2. **Check the current context**:
244+
```bash
245+
kubectl config current-context
246+
# Should be: kind-tilt
247+
```
220248

221-
# List available contexts
222-
kubectl config get-contexts
223-
```
249+
3. **If context is wrong, manually switch**:
250+
```bash
251+
kubectl config use-context kind-tilt
252+
```
253+
254+
4. **Verify cluster is accessible**:
255+
```bash
256+
kubectl cluster-info
257+
```
258+
259+
5. **Ensure you have permissions** to create resources in the `kubeflow-workspaces` namespace
260+
261+
**Note**: If you're running `tilt up` directly (not via `make tilt`), you may be on the wrong Kubernetes context. Always use `make tilt` to ensure the correct context is set.
224262

225263
### Port Already in Use
226264

@@ -262,5 +300,6 @@ Also check that you have cluster-admin permissions or appropriate RBAC.
262300
- Node modules: `npm ci` in frontend
263301

264302
3. **Clean up resources**:
265-
- Always run `tilt down` when done
303+
- Always run `make tilt-down` (or `tilt down`) when done
266304
- Optionally: `kubectl delete namespace kubeflow-workspaces`
305+
- Optionally: `kind delete cluster --name tilt` to remove the Kind cluster

developing/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.PHONY: tilt tilt-up tilt-down setup-kind setup-cert-manager
2+
3+
# Default target
4+
.DEFAULT_GOAL := tilt
5+
6+
# Variables
7+
CLUSTER_NAME := tilt
8+
KIND_CONTEXT := kind-$(CLUSTER_NAME)
9+
10+
# Export KIND_EXPERIMENTAL_PROVIDER to honor it if set in user's environment
11+
# (e.g., KIND_EXPERIMENTAL_PROVIDER=podman for podman support)
12+
export KIND_EXPERIMENTAL_PROVIDER
13+
14+
# Ensure kind cluster exists and context is set before running tilt
15+
setup-kind:
16+
@echo "Setting up Kind cluster..."
17+
@if [ -n "$$KIND_EXPERIMENTAL_PROVIDER" ]; then \
18+
echo "Using KIND_EXPERIMENTAL_PROVIDER=$$KIND_EXPERIMENTAL_PROVIDER"; \
19+
fi
20+
@./scripts/setup-kind.sh
21+
22+
# Install cert-manager (depends on kind cluster being set up)
23+
setup-cert-manager: setup-kind
24+
@echo "Setting up cert-manager..."
25+
@./scripts/setup-cert-manager.sh
26+
27+
# Run tilt up with kind cluster and cert-manager setup
28+
tilt: setup-cert-manager
29+
@echo "Starting Tilt..."
30+
@tilt up
31+
32+
# Alias for tilt
33+
tilt-up: tilt
34+
35+
# Stop Tilt
36+
tilt-down:
37+
@echo "Stopping Tilt..."
38+
@tilt down
39+
File renamed without changes.

workspaces/developing/Tiltfile renamed to developing/Tiltfile

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ version_settings(check_updates=True, constraint=">=0.33.0")
1010
# Increase timeout for k8s operations
1111
update_settings(k8s_upsert_timeout_secs=120)
1212

13+
# Allow kind-tilt context (set up by Makefile before tilt runs)
14+
allow_k8s_contexts('kind-tilt')
1315

1416
# Allow skipping frontend via environment variable
1517
enable_frontend = os.getenv("ENABLE_FRONTEND", "true").lower() == "true"
1618

1719
# Get paths relative to Tiltfile location
1820
# Tilt evaluates paths relative to the Tiltfile directory
1921
tilt_root = os.path.dirname(os.path.abspath(__file__))
20-
# Go up 2 levels from Tiltfile location: developing -> workspaces -> repo root
21-
workspace_root = os.path.dirname(os.path.dirname(tilt_root))
22+
# Go up 1 level from Tiltfile location: developing -> repo root
23+
workspace_root = os.path.dirname(tilt_root)
2224

2325
# Define paths relative to workspace root
2426
controller_dir = os.path.join(workspace_root, "workspaces/controller")
@@ -32,43 +34,25 @@ frontend_dir = os.path.join(workspace_root, "workspaces/frontend")
3234
watch_settings(
3335
ignore=[
3436
# Controller generated files
37+
os.path.join(controller_dir, "bin/**"),
3538
os.path.join(controller_dir, "**/zz_generated.*"),
3639
os.path.join(controller_dir, "config/crd/**"),
3740
os.path.join(controller_dir, "config/webhook/manifests.yaml"),
3841
# Backend generated files
42+
os.path.join(backend_dir, "bin/**"),
3943
os.path.join(backend_dir, "openapi/**"),
4044
# Frontend generated files
45+
os.path.join(frontend_dir, "bin/**"),
4146
os.path.join(frontend_dir, "src/generated/**"),
4247
],
4348
)
4449

4550

4651

47-
# ============================================================================
48-
# Setup Resources (must run first)
49-
# ============================================================================
50-
51-
# Kind Cluster Setup - must be first, no dependencies
52-
local_resource(
53-
"setup-kind",
54-
cmd=os.path.join(tilt_root, "scripts/setup-kind.sh"),
55-
labels=["setup"],
56-
resource_deps=[],
57-
allow_parallel=False,
58-
)
59-
60-
# Cert-Manager Installation - depends on Kind cluster
61-
local_resource(
62-
"setup-cert-manager",
63-
cmd=os.path.join(tilt_root, "scripts/setup-cert-manager.sh"),
64-
labels=["setup"],
65-
resource_deps=["setup-kind"],
66-
allow_parallel=False,
67-
)
68-
6952
# ============================================================================
7053
# Controller
7154
# ============================================================================
55+
# Note: Kind cluster and cert-manager are set up by the Makefile before Tilt starts
7256

7357
# Generate manifests and code (needed before Docker build)
7458
# Note: Skip 'fmt' step to prevent infinite rebuild loops (fmt modifies files in place)
@@ -82,20 +66,7 @@ local_resource(
8266
os.path.join(controller_dir, "go.mod"),
8367
os.path.join(controller_dir, "go.sum"),
8468
],
85-
ignore=["bin/", "**/zz_generated.*", "**/config/crd/**"],
86-
labels=["controller"],
87-
)
88-
89-
# CRDs Installation - depends on cert-manager and controller generate
90-
# Runs after controller-generate to ensure we install the latest generated CRDs
91-
# Note: No deps parameter - we don't want to watch for file changes since both
92-
# controller-generate and install-crds run manifests which would create a loop
93-
local_resource(
94-
"install-crds",
95-
cmd="cd {} && make install".format(controller_dir),
9669
labels=["controller"],
97-
resource_deps=["setup-cert-manager", "controller-generate"],
98-
allow_parallel=False,
9970
)
10071

10172
# Docker build for controller using production Dockerfile
@@ -110,7 +81,7 @@ docker_build(
11081

11182
# K8s deployment for controller - use kustomize to build and preprocess YAMLs
11283
# Note: kustomize needs to be available (installed via controller Makefile)
113-
# Note: cert-manager must be installed before deploying (handled by setup-cert-manager)
84+
# Note: cert-manager is already installed by Makefile before Tilt starts
11485
controller_kustomize_path = "config/default"
11586

11687
# Build manifests with kustomize
@@ -152,7 +123,7 @@ k8s_yaml(overridden_manifests)
152123
k8s_resource(
153124
"workspaces-controller",
154125
port_forwards=["8080:8080", "8081:8081"], # metrics and health probe
155-
resource_deps=["controller-generate", "setup-cert-manager", "install-crds"],
126+
resource_deps=["controller-generate"],
156127
labels=["controller"],
157128
)
158129

@@ -194,10 +165,10 @@ k8s_resource(
194165
if enable_frontend:
195166
# Run frontend as local resource using webpack dev server
196167
# This enables hot-reloading and faster development iteration
197-
# Uses the start:tilt script which sets TILT_ENV=true to load .env.tilt
168+
# Uses the start:tilt script which sets DEV_ENV=tilt to load .env.tilt
198169
# Frontend will be available at http://localhost:9000
199170
# Note: This is a long-running process, so it will show as "Updating" in Tilt UI
200-
# Other resources don't need to wait for it (frontend proxies to backend)
171+
# Frontend waits for backend to be ready to avoid 504 errors on initial page load
201172
local_resource(
202173
"workspaces-frontend",
203174
serve_cmd="cd {} && npm run start:tilt".format(frontend_dir),
@@ -209,8 +180,7 @@ if enable_frontend:
209180
os.path.join(frontend_dir, "dist"),
210181
os.path.join(frontend_dir, "coverage"),
211182
],
212-
# No resource_deps - frontend doesn't block other resources
213-
# Frontend will proxy to backend when ready, but doesn't need to wait
183+
resource_deps=["workspaces-backend"],
214184
labels=["frontend"],
215185
)
216186

workspaces/developing/scripts/setup-cert-manager.sh renamed to developing/scripts/setup-cert-manager.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
#!/usr/bin/env bash
22
# Setup script for cert-manager
33
# This script checks if cert-manager is installed and installs it if needed
4+
# Uses the same version as the e2e tests: v1.12.13 (LTS version)
45

56
set -euo pipefail
67

8+
# Use LTS version of cert-manager (matches e2e tests)
9+
CERT_MANAGER_VERSION="v1.12.13"
10+
CERT_MANAGER_URL="https://github.com/jetstack/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.yaml"
11+
712
# Check if cert-manager is already installed
813
if kubectl get crd certificates.cert-manager.io >/dev/null 2>&1; then
914
echo "Cert-manager is already installed"
1015
exit 0
1116
fi
1217

13-
echo "Installing cert-manager..."
14-
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml
18+
echo "Installing cert-manager ${CERT_MANAGER_VERSION}..."
19+
kubectl apply -f "${CERT_MANAGER_URL}"
1520

1621
echo "Waiting for cert-manager to be ready..."
1722
# Wait for cert-manager webhook to be ready (this is the critical component)
File renamed without changes.

workspaces/frontend/config/webpack.dev.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
88

99
const smp = new SpeedMeasurePlugin({ disable: !process.env.MEASURE });
1010

11-
// Use 'tilt' env if TILT_ENV is set, otherwise default to 'development'
12-
// This allows dotenv.js to naturally load .env.tilt without code changes
13-
const env = process.env.TILT_ENV === 'true' ? 'tilt' : 'development';
11+
const env = process.env.DEV_ENV ?? 'development';
1412
setupDotenvFilesForEnv({ env });
1513
const webpackCommon = require('./webpack.common.js');
1614

@@ -85,7 +83,7 @@ module.exports = smp.wrap(
8583
port: PORT,
8684
compress: true,
8785
historyApiFallback: {
88-
index: `${BASE_PATH}/index.html`,
86+
index: `${BASE_PATH}/index.html`.replace('//', '/'),
8987
},
9088
hot: true,
9189
open: [BASE_PATH],

workspaces/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"build:prod": "webpack --config ./config/webpack.prod.js",
2222
"generate:api": "./scripts/generate-api.sh && npm run prettier",
2323
"start:dev": "webpack serve --hot --color --config ./config/webpack.dev.js",
24-
"start:tilt": "TILT_ENV=true webpack serve --hot --color --config ./config/webpack.dev.js",
24+
"start:tilt": "DEV_ENV=tilt npm run start:dev",
2525
"test": "run-s prettier:check test:lint test:type-check test:unit test:cypress-ci",
2626
"test:cypress-ci": "npx concurrently -P -k -s first \"CY_MOCK=1 npm run cypress:server:build && npm run cypress:server\" \"npx wait-on tcp:127.0.0.1:9001 && npm run cypress:run:mock -- {@}\" -- ",
2727
"test:jest": "jest --passWithNoTests",

0 commit comments

Comments
 (0)