Skip to content

Commit c26fe5b

Browse files
authored
Improve local development experience with new make targets and scripts (#221)
1 parent 5d28f5a commit c26fe5b

File tree

6 files changed

+411
-29
lines changed

6 files changed

+411
-29
lines changed

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,43 @@ dev-envoy: ## Deploy test Envoy instance
416416
dev-frontend: ## Run UI development server (npm run dev)
417417
cd ui && npm run dev
418418

419+
.PHONY: dev-logs
420+
dev-logs: ## Tail controller logs
421+
kubectl -n envoy-xds-controller logs -f deployment/exc-envoy-xds-controller
422+
423+
.PHONY: dev-logs-ui
424+
dev-logs-ui: ## Tail UI logs
425+
kubectl -n envoy-xds-controller logs -f deployment/exc-envoy-xds-controller-ui
426+
427+
.PHONY: dev-status
428+
dev-status: ## Show status of dev environment
429+
@bash scripts/dev-status.sh
430+
431+
.PHONY: dev-restart
432+
dev-restart: ## Restart controller pod without rebuild
433+
kubectl -n envoy-xds-controller rollout restart deployment/exc-envoy-xds-controller
434+
435+
.PHONY: dev-restart-ui
436+
dev-restart-ui: ## Restart UI pod without rebuild
437+
kubectl -n envoy-xds-controller rollout restart deployment/exc-envoy-xds-controller-ui
438+
439+
.PHONY: dev-restart-all
440+
dev-restart-all: ## Restart all pods without rebuild
441+
kubectl -n envoy-xds-controller rollout restart deployment/exc-envoy-xds-controller
442+
kubectl -n envoy-xds-controller rollout restart deployment/exc-envoy-xds-controller-ui || true
443+
444+
.PHONY: dev-port-forward
445+
dev-port-forward: ## Start all port-forwards in background
446+
@bash scripts/dev-port-forward.sh
447+
448+
.PHONY: dev-update-backend
449+
dev-update-backend: ## Rebuild and redeploy only backend
450+
@COMPONENTS=backend bash scripts/dev-update.sh
451+
452+
.PHONY: dev-update-frontend
453+
dev-update-frontend: ## Rebuild and redeploy only frontend
454+
@COMPONENTS=frontend bash scripts/dev-update.sh
455+
419456
.PHONY: install-prometheus
420457
install-prometheus: ## Install Prometheus Operator
421458
kubectl create -f https://github.com/prometheus-operator/prometheus-operator/releases/download/$(PROM_OPERATOR_VERSION)/bundle.yaml

docs/development.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ This document provides guidelines and instructions for developing the Envoy XDS
55
## Table of Contents
66

77
1. [Development Environment Setup](#development-environment-setup)
8+
- [Quick Start with Kind (Recommended)](#quick-start-with-kind-recommended)
9+
- [Running Locally Without Webhook](#running-locally-without-webhook)
10+
- [Running Locally With Webhook (Advanced)](#running-locally-with-webhook-advanced)
811
2. [Project Structure](#project-structure)
912
3. [Building](#building)
1013
4. [Testing](#testing)
@@ -43,6 +46,91 @@ go mod download
4346
make install-tools
4447
```
4548

49+
### Quick Start with Kind (Recommended)
50+
51+
The easiest way to run the full development environment is using Kind with `make dev`:
52+
53+
1. Create a Kind cluster with local registry:
54+
55+
```bash
56+
make kr
57+
```
58+
59+
2. Run the interactive development setup:
60+
61+
```bash
62+
make dev
63+
```
64+
65+
This will prompt you with options (defaults shown in brackets):
66+
67+
```
68+
Enable UI? [Y/n]:
69+
Enable Auth (OIDC via Dex)? [Y/n]:
70+
Install Prometheus Operator? [y/N]:
71+
Development mode (verbose logging)? [Y/n]:
72+
Deploy test Envoy proxy? [Y/n]:
73+
Apply test resources (VirtualServices, etc.)? [y/N]:
74+
```
75+
76+
Press Enter to accept defaults. The script will build images, push to local registry, and deploy via Helm.
77+
78+
3. **Important: Configure /etc/hosts for Dex authentication**
79+
80+
If you enabled Auth (Dex), add the following to your `/etc/hosts`:
81+
82+
```bash
83+
echo "127.0.0.1 dex.dex" | sudo tee -a /etc/hosts
84+
```
85+
86+
This is required because the OIDC issuer URL uses `dex.dex` as the hostname.
87+
88+
4. Start port-forwards (the script will show these commands):
89+
90+
```bash
91+
# UI (in terminal 1)
92+
kubectl -n envoy-xds-controller port-forward svc/exc-envoy-xds-controller-ui 8080:8080
93+
94+
# Dex - required for auth (in terminal 2)
95+
kubectl -n dex port-forward svc/dex 5556:5556
96+
97+
# Envoy proxy (in terminal 3)
98+
kubectl -n default port-forward svc/envoy 10080:80 10443:443 19000:19000
99+
```
100+
101+
5. Access the UI at http://localhost:8080
102+
103+
Test credentials (if Auth enabled):
104+
- Admin: `[email protected]` / `admin`
105+
- User: `[email protected]` / `user`
106+
107+
#### Useful Development Commands
108+
109+
```bash
110+
# Check status of all components
111+
make dev-status
112+
113+
# Start all port-forwards in one terminal
114+
make dev-port-forward
115+
116+
# View logs
117+
make dev-logs # Controller logs
118+
make dev-logs-ui # UI logs
119+
120+
# Restart pods without rebuild
121+
make dev-restart # Restart controller
122+
make dev-restart-ui # Restart UI
123+
make dev-restart-all # Restart all
124+
125+
# Rebuild and redeploy
126+
make dev-update # Rebuild everything
127+
make dev-update-backend # Rebuild only controller
128+
make dev-update-frontend # Rebuild only UI
129+
130+
# Show test credentials
131+
make dev-creds
132+
```
133+
46134
### Running Locally Without Webhook
47135

48136
If you don't need the Validation Webhook for development, you can start the Envoy xDS Controller locally with:
@@ -52,7 +140,7 @@ export WEBHOOK_DISABLE=true
52140
make run
53141
```
54142

55-
### Running Locally With Webhook
143+
### Running Locally With Webhook (Advanced)
56144

57145
For full installation with Validation Webhook logic on a local instance, you need Kubernetes with network access to your workstation. You can use [KIND](https://kind.sigs.k8s.io/) for this purpose.
58146

scripts/dev-port-forward.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
# Start all port-forwards for dev environment
3+
4+
# Colors
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
BLUE='\033[0;34m'
9+
NC='\033[0m'
10+
11+
# Cleanup function
12+
cleanup() {
13+
echo ""
14+
echo -e "${YELLOW}Stopping port-forwards...${NC}"
15+
kill $(jobs -p) 2>/dev/null
16+
exit 0
17+
}
18+
19+
trap cleanup SIGINT SIGTERM
20+
21+
echo -e "${BLUE}============================================${NC}"
22+
echo -e "${BLUE} Starting Port Forwards${NC}"
23+
echo -e "${BLUE}============================================${NC}"
24+
echo ""
25+
26+
PIDS=()
27+
28+
# UI port-forward
29+
if kubectl -n envoy-xds-controller get svc exc-envoy-xds-controller-ui &>/dev/null; then
30+
echo -e "${GREEN}Starting UI port-forward (8080)...${NC}"
31+
kubectl -n envoy-xds-controller port-forward svc/exc-envoy-xds-controller-ui 8080:8080 &
32+
PIDS+=($!)
33+
else
34+
echo -e "${YELLOW}UI service not found, skipping...${NC}"
35+
fi
36+
37+
# Dex port-forward
38+
if kubectl -n dex get svc dex &>/dev/null; then
39+
echo -e "${GREEN}Starting Dex port-forward (5556)...${NC}"
40+
kubectl -n dex port-forward svc/dex 5556:5556 &
41+
PIDS+=($!)
42+
43+
# Check /etc/hosts
44+
if ! grep -q "dex.dex" /etc/hosts 2>/dev/null; then
45+
echo ""
46+
echo -e "${RED}Warning: dex.dex not in /etc/hosts${NC}"
47+
echo -e "Run: ${YELLOW}echo \"127.0.0.1 dex.dex\" | sudo tee -a /etc/hosts${NC}"
48+
fi
49+
else
50+
echo -e "${YELLOW}Dex service not found, skipping...${NC}"
51+
fi
52+
53+
# Envoy port-forward
54+
if kubectl -n default get svc envoy &>/dev/null; then
55+
echo -e "${GREEN}Starting Envoy port-forward (10080/http, 10443/https, 19000/admin)...${NC}"
56+
kubectl -n default port-forward svc/envoy 10080:80 10443:443 19000:19000 &
57+
PIDS+=($!)
58+
else
59+
echo -e "${YELLOW}Envoy service not found, skipping...${NC}"
60+
fi
61+
62+
if [ ${#PIDS[@]} -eq 0 ]; then
63+
echo -e "${RED}No services to forward. Is the dev environment running?${NC}"
64+
echo -e "Run ${YELLOW}make dev${NC} first."
65+
exit 1
66+
fi
67+
68+
echo ""
69+
echo -e "${GREEN}Port forwards active:${NC}"
70+
kubectl -n envoy-xds-controller get svc exc-envoy-xds-controller-ui &>/dev/null && echo " - UI: http://localhost:8080"
71+
kubectl -n dex get svc dex &>/dev/null && echo " - Dex: http://dex.dex:5556"
72+
if kubectl -n default get svc envoy &>/dev/null; then
73+
echo " - Envoy: http://localhost:10080 (http), https://localhost:10443 (https)"
74+
echo " http://localhost:19000 (admin)"
75+
fi
76+
echo ""
77+
echo -e "${YELLOW}Press Ctrl+C to stop all port-forwards${NC}"
78+
echo ""
79+
80+
# Wait for all background processes
81+
wait

scripts/dev-status.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
# Show status of dev environment
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
6+
# Colors
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
BLUE='\033[0;34m'
11+
CYAN='\033[0;36m'
12+
NC='\033[0m'
13+
14+
echo -e "${BLUE}============================================${NC}"
15+
echo -e "${BLUE} Dev Environment Status${NC}"
16+
echo -e "${BLUE}============================================${NC}"
17+
echo ""
18+
19+
# Check Kind cluster
20+
if ! kind get clusters 2>/dev/null | grep -q 'kind'; then
21+
echo -e "${RED}Kind cluster: Not running${NC}"
22+
echo -e "Run ${YELLOW}make kr${NC} to create cluster"
23+
exit 1
24+
fi
25+
echo -e "${GREEN}Kind cluster: Running${NC}"
26+
echo ""
27+
28+
# Check Helm release
29+
if helm status exc -n envoy-xds-controller &>/dev/null; then
30+
echo -e "${GREEN}Helm release 'exc': Installed${NC}"
31+
32+
# Get current config
33+
VALUES=$(helm get values exc -n envoy-xds-controller -o json 2>/dev/null)
34+
UI_ENABLED=$(echo "$VALUES" | grep -o '"ui":{[^}]*"enabled":[^,}]*' | grep -o 'true\|false' | head -1 || echo "unknown")
35+
AUTH_ENABLED=$(echo "$VALUES" | grep -o '"auth":{[^}]*"enabled":[^,}]*' | grep -o 'true\|false' | head -1 || echo "unknown")
36+
37+
echo " UI enabled: $UI_ENABLED"
38+
echo " Auth enabled: $AUTH_ENABLED"
39+
else
40+
echo -e "${YELLOW}Helm release 'exc': Not installed${NC}"
41+
echo -e "Run ${YELLOW}make dev${NC} to deploy"
42+
exit 0
43+
fi
44+
echo ""
45+
46+
# Pods status
47+
echo -e "${CYAN}Pods:${NC}"
48+
kubectl -n envoy-xds-controller get pods -o wide 2>/dev/null || echo " No pods found"
49+
echo ""
50+
51+
# Check Dex
52+
if kubectl get namespace dex &>/dev/null; then
53+
echo -e "${CYAN}Dex (Auth):${NC}"
54+
kubectl -n dex get pods -o wide 2>/dev/null || echo " No pods found"
55+
echo ""
56+
fi
57+
58+
# Check Envoy
59+
if kubectl get deployment envoy -n default &>/dev/null; then
60+
echo -e "${CYAN}Envoy (test proxy):${NC}"
61+
kubectl -n default get pods -l app=envoy -o wide 2>/dev/null || echo " No pods found"
62+
echo ""
63+
fi
64+
65+
# Services
66+
echo -e "${CYAN}Services:${NC}"
67+
kubectl -n envoy-xds-controller get svc 2>/dev/null || echo " No services found"
68+
echo ""
69+
70+
# Port-forward reminder
71+
echo -e "${YELLOW}Port forwards (run in separate terminals or use 'make dev-port-forward'):${NC}"
72+
echo " kubectl -n envoy-xds-controller port-forward svc/exc-envoy-xds-controller-ui 8080:8080"
73+
if kubectl get namespace dex &>/dev/null; then
74+
echo " kubectl -n dex port-forward svc/dex 5556:5556"
75+
fi
76+
if kubectl get deployment envoy -n default &>/dev/null; then
77+
echo " kubectl -n default port-forward svc/envoy 10080:80 10443:443 19000:19000"
78+
fi
79+
echo ""
80+
81+
# Check /etc/hosts for dex
82+
if kubectl get namespace dex &>/dev/null; then
83+
if grep -q "dex.dex" /etc/hosts 2>/dev/null; then
84+
echo -e "${GREEN}/etc/hosts: dex.dex configured${NC}"
85+
else
86+
echo -e "${RED}/etc/hosts: dex.dex NOT configured${NC}"
87+
echo -e " Run: ${YELLOW}echo \"127.0.0.1 dex.dex\" | sudo tee -a /etc/hosts${NC}"
88+
fi
89+
echo ""
90+
fi
91+
92+
# Quick links
93+
echo -e "${CYAN}Access:${NC}"
94+
echo " UI: http://localhost:8080"
95+
if kubectl get namespace dex &>/dev/null; then
96+
echo " Dex: http://dex.dex:5556"
97+
fi

0 commit comments

Comments
 (0)