-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (95 loc) · 4.93 KB
/
Copy pathMakefile
File metadata and controls
131 lines (95 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
SHELL := /bin/bash
.DEFAULT_GOAL := help
# ------------------------------------------------------------------ build ---
.PHONY: build console console-test test test-race test-integration schemathesis cloud-run-rollout-test vet lint clean
build: ## Build all binaries into ./bin
go build -o bin/gateway ./cmd/gateway
go build -o bin/tollgate-admin ./cmd/tollgate-admin
go build -o bin/upstream ./cmd/upstream
console: ## Type-check and compile the Vue operator console into the Go binary
npm --prefix web/admin ci
npm --prefix web/admin run build
console-test: ## Exercise authenticated and destructive operator workflows
npm --prefix web/admin ci
npm --prefix web/admin test
test: ## Unit tests
go test ./...
test-race: ## Unit tests with the race detector
go test -race ./...
test-integration: ## Integration tests (needs the compose stack: make up)
TOLLGATE_TEST_REDIS=localhost:6379 go test -count=1 ./internal/ratelimit/ -run TestRedis -v
schemathesis: ## Generated OpenAPI checks against an isolated disposable Postgres
scripts/schemathesis.sh
cloud-run-rollout-test: ## Validate Tollgate and Argus canary/rollback command plans
scripts/cloud-run-rollout_test.sh
vet:
go vet ./...
clean:
rm -rf bin loadtest/results web/admin/node_modules
# ------------------------------------------------------------- local dev ---
.PHONY: up down seed logs demo-hot-reload
up: ## Start the local compose stack
docker compose up -d --build
@echo "gateway: http://localhost:8080"
@echo "console: http://localhost:8080/_admin/ (token: $${ADMIN_TOKEN:-local-dev-admin-token-change-me})"
@echo "admin: http://localhost:9090/metrics"
@echo "prometheus: http://localhost:9091"
@echo "jaeger: http://localhost:16686"
down:
docker compose down -v
seed: ## Migrate + seed demo tenants; prints API key exports
scripts/seed.sh compose
logs:
docker compose logs -f gateway
# ------------------------------------------------------------------ kind ---
.PHONY: kind-up kind-down docker-build kind-load tf-apply tf-destroy \
monitoring-install helm-install helm-install-memory kind-seed deploy
kind-up: ## Create the kind cluster
kind create cluster --config deploy/kind/cluster.yaml --name tollgate || true
kind-down:
kind delete cluster --name tollgate
docker-build: ## Build gateway + upstream images
docker build --target gateway -t tollgate:dev .
docker build --target upstream -t tollgate-upstream:dev .
kind-load: docker-build ## Load images into kind
kind load docker-image tollgate:dev --name tollgate
kind load docker-image tollgate-upstream:dev --name tollgate
tf-apply: ## Terraform: Redis + Postgres into the cluster
terraform -chdir=deploy/terraform init -input=false
terraform -chdir=deploy/terraform apply -auto-approve
tf-destroy:
terraform -chdir=deploy/terraform destroy -auto-approve
monitoring-install: ## Prometheus + prometheus-adapter (for the p99 HPA)
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts >/dev/null 2>&1 || true
helm repo update >/dev/null
helm upgrade --install prometheus prometheus-community/prometheus \
-n monitoring --create-namespace -f deploy/monitoring/prometheus-values.yaml
helm upgrade --install prometheus-adapter prometheus-community/prometheus-adapter \
-n monitoring -f deploy/monitoring/adapter-values.yaml
helm-install: ## Deploy the gateway (3 replicas, redis limiter)
helm upgrade --install tollgate deploy/helm/tollgate -n tollgate --create-namespace \
--set limiter=redis
helm-install-memory: ## Deploy with the NAIVE per-replica limiter (for the demo)
helm upgrade --install tollgate deploy/helm/tollgate -n tollgate --create-namespace \
--set limiter=memory
kind-seed: ## Migrate + seed inside the kind cluster
scripts/seed.sh kind
deploy: kind-up kind-load tf-apply monitoring-install helm-install ## Full kind deployment
# ------------------------------------------------------------- load tests ---
.PHONY: k6-baseline k6-correctness k6-fairness bench bench-limiter-cost \
bench-limiter-cost-local bench-limiter-cost-incluster
bench-limiter-cost: bench-limiter-cost-local bench-limiter-cost-incluster ## Run the matched local and EKS limiter-cost protocol
python3 bench/compare.py bench/results/local bench/results/incluster \
bench/results/limiter_cost_comparison.json > bench/results/limiter_cost_comparison.txt
bench-limiter-cost-local: ## Run the matched limiter-cost protocol in Docker Compose
bench/run-local.sh
bench-limiter-cost-incluster: ## Run the matched limiter-cost protocol in the current Kubernetes context
bench/run-incluster.sh
k6-baseline: ## Latency/throughput at three load levels
scripts/run-k6.sh baseline
k6-correctness: ## Distributed rate limit correctness across replicas
scripts/run-k6.sh correctness
k6-fairness: ## Noisy tenant cannot starve a quiet one
scripts/run-k6.sh fairness
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}'