-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
349 lines (307 loc) · 13.3 KB
/
Makefile
File metadata and controls
349 lines (307 loc) · 13.3 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
.PHONY: help build build-mcp docker-build docker-up docker-down docker-logs run-research run-synthesis run-verification run-direct run-orchestration run-orchestration-eino run-all run-all-eino run-direct-verify run-mcp clean install test
.PHONY: k8s-build-images k8s-minikube-setup k8s-minikube-build k8s-minikube-deploy k8s-minikube-delete k8s-eks-deploy k8s-eks-delete helm-lint helm-template
.PHONY: helm-test helm-unittest helm-kubeconform helm-polaris helm-test-all
.PHONY: docs docs-serve docs-clean
# Image registry (override for EKS: make k8s-eks-deploy REGISTRY=123456789.dkr.ecr.us-west-2.amazonaws.com)
REGISTRY ?=
IMAGE_TAG ?= latest
help:
@echo "Statistics Agent - Make targets"
@echo ""
@echo "Docker Commands:"
@echo " make docker-build Build Docker image (all-in-one)"
@echo " make docker-up Start all agents with Docker Compose"
@echo " make docker-down Stop all agents"
@echo " make docker-logs View Docker logs"
@echo ""
@echo "Kubernetes Commands:"
@echo " make k8s-build-images Build individual agent Docker images"
@echo " make k8s-minikube-setup Setup Minikube with required addons"
@echo " make k8s-minikube-build Build images in Minikube's Docker daemon"
@echo " make k8s-minikube-deploy Deploy to Minikube with Helm"
@echo " make k8s-minikube-delete Delete deployment from Minikube"
@echo " make k8s-eks-deploy Deploy to AWS EKS with Helm"
@echo " make k8s-eks-delete Delete deployment from EKS"
@echo ""
@echo "Helm Chart Commands:"
@echo " make helm-lint Lint Helm chart"
@echo " make helm-template Render Helm templates locally"
@echo " make helm-unittest Run helm-unittest tests"
@echo " make helm-kubeconform Validate against K8s schemas"
@echo " make helm-polaris Check security best practices"
@echo " make helm-test-all Run all chart tests"
@echo ""
@echo "Build Commands:"
@echo " make install Install dependencies"
@echo " make build Build all agents"
@echo " make build-mcp Build MCP server"
@echo ""
@echo "Run Commands (Local):"
@echo " make run-research Run research agent"
@echo " make run-synthesis Run synthesis agent"
@echo " make run-verification Run verification agent"
@echo " make run-direct Run direct search agent (with OpenAPI docs)"
@echo " make run-direct-verify Run direct + verification agents (hybrid mode)"
@echo " make run-orchestration Run trpc-agent orchestration"
@echo " make run-orchestration-eino Run Eino orchestration"
@echo " make run-all Run all agents with trpc-agent orchestrator"
@echo " make run-all-eino Run all agents with Eino orchestrator"
@echo " make run-mcp Run MCP server (requires agents running)"
@echo ""
@echo "Documentation Commands:"
@echo " make docs Build MkDocs documentation"
@echo " make docs-serve Serve documentation locally"
@echo " make docs-clean Clean generated docs"
@echo ""
@echo "Other Commands:"
@echo " make test Run tests"
@echo " make clean Clean build artifacts"
install:
go mod download
go get github.com/trpc-group/trpc-agent-go
go get github.com/trpc-group/trpc-a2a-go
go get github.com/cloudwego/eino
build:
@echo "Building agents..."
go build -o bin/research agents/research/main.go
go build -o bin/synthesis agents/synthesis/main.go
go build -o bin/verification agents/verification/main.go
go build -o bin/direct agents/direct/main.go
go build -o bin/orchestration agents/orchestration/main.go
go build -o bin/orchestration-eino agents/orchestration-eino/main.go
go build -o bin/stats-agent main.go
@echo "Build complete!"
build-mcp:
@echo "Building MCP server..."
go build -o bin/mcp-server mcp/server/main.go
@echo "MCP server build complete!"
docker-build:
@echo "Building Docker image..."
docker build -t stats-agent-team:latest .
@echo "Docker build complete!"
docker-up:
@echo "Starting all agents with Docker Compose..."
docker-compose up -d
@echo "All agents started! Use 'make docker-logs' to view logs"
docker-down:
@echo "Stopping all agents..."
docker-compose down
@echo "All agents stopped"
docker-logs:
docker-compose logs -f
run-research:
@echo "Starting Research Agent on :8001 (HTTP) and :9001 (A2A)..."
go run ./agents/research/
run-synthesis:
@echo "Starting Synthesis Agent on :8004..."
go run ./agents/synthesis/
run-verification:
@echo "Starting Verification Agent on :8002 (HTTP) and :9002 (A2A)..."
go run ./agents/verification/
run-direct:
@echo "Starting Direct Agent on :8005 (HTTP)..."
go run ./agents/direct/
run-orchestration:
@echo "Starting Orchestration Agent (trpc-agent) on :8000 (HTTP) and :9000 (A2A)..."
go run ./agents/orchestration/
run-orchestration-eino:
@echo "Starting Orchestration Agent (Eino) on :8000 (HTTP)..."
go run ./agents/orchestration-eino/
run-all:
@echo "Starting all agents with trpc-agent orchestrator..."
@echo "Research Agent: http://localhost:8001 (A2A: 9001)"
@echo "Synthesis Agent: http://localhost:8004"
@echo "Verification Agent: http://localhost:8002 (A2A: 9002)"
@echo "Orchestration Agent (trpc-agent): http://localhost:8000 (A2A: 9000)"
@go run ./agents/research/ & \
go run ./agents/synthesis/ & \
go run ./agents/verification/ & \
go run ./agents/orchestration/ & \
wait
run-all-eino:
@echo "Starting all agents with Eino orchestrator..."
@echo "Research Agent: http://localhost:8001 (A2A: 9001)"
@echo "Synthesis Agent: http://localhost:8004"
@echo "Verification Agent: http://localhost:8002 (A2A: 9002)"
@echo "Orchestration Agent (Eino): http://localhost:8000"
@go run ./agents/research/ & \
go run ./agents/synthesis/ & \
go run ./agents/verification/ & \
go run ./agents/orchestration-eino/ & \
wait
run-direct-verify:
@echo "Starting Direct + Verification agents (hybrid mode)..."
@echo "Direct Agent: http://localhost:8005 (OpenAPI docs at /docs)"
@echo "Verification Agent: http://localhost:8002"
@echo ""
@echo "Usage: ./bin/stats-agent search \"topic\" --direct --direct-verify"
@go run ./agents/direct/ & \
go run ./agents/verification/ & \
wait
run-mcp:
@echo "Starting MCP server (stdio)..."
@echo "Note: Ensure research and verification agents are running first!"
@echo " Terminal 1: make run-research"
@echo " Terminal 2: make run-verification"
@go run mcp/server/main.go
clean:
rm -rf bin/
go clean
test:
go test ./...
# ============================================
# Kubernetes / Helm Commands
# ============================================
# Build individual agent Docker images
k8s-build-images:
@echo "Building individual agent Docker images..."
docker build --build-arg AGENT=research -t stats-agent-research:$(IMAGE_TAG) -f Dockerfile.agent .
docker build --build-arg AGENT=synthesis -t stats-agent-synthesis:$(IMAGE_TAG) -f Dockerfile.agent .
docker build --build-arg AGENT=verification -t stats-agent-verification:$(IMAGE_TAG) -f Dockerfile.agent .
docker build --build-arg AGENT=orchestration-eino -t stats-agent-orchestration-eino:$(IMAGE_TAG) -f Dockerfile.agent .
docker build --build-arg AGENT=direct -t stats-agent-direct:$(IMAGE_TAG) -f Dockerfile.agent .
@echo "All agent images built successfully!"
# Setup Minikube with required addons
k8s-minikube-setup:
@echo "Setting up Minikube..."
minikube start --cpus=4 --memory=8192
minikube addons enable ingress
minikube addons enable metrics-server
@echo "Minikube is ready!"
# Build images directly in Minikube's Docker daemon
k8s-minikube-build:
@echo "Building images in Minikube's Docker daemon..."
@eval $$(minikube docker-env) && \
docker build --build-arg AGENT=research -t stats-agent-research:$(IMAGE_TAG) -f Dockerfile.agent . && \
docker build --build-arg AGENT=synthesis -t stats-agent-synthesis:$(IMAGE_TAG) -f Dockerfile.agent . && \
docker build --build-arg AGENT=verification -t stats-agent-verification:$(IMAGE_TAG) -f Dockerfile.agent . && \
docker build --build-arg AGENT=orchestration-eino -t stats-agent-orchestration-eino:$(IMAGE_TAG) -f Dockerfile.agent . && \
docker build --build-arg AGENT=direct -t stats-agent-direct:$(IMAGE_TAG) -f Dockerfile.agent .
@echo "All images built in Minikube!"
# Deploy to Minikube with Helm
k8s-minikube-deploy:
@echo "Deploying to Minikube..."
helm upgrade --install stats-agent ./helm/stats-agent-team \
-f ./helm/stats-agent-team/values-minikube.yaml \
--namespace stats-agent \
--create-namespace
@echo ""
@echo "Deployment complete! Access the orchestration agent:"
@echo " kubectl port-forward -n stats-agent svc/stats-agent-stats-agent-team-orchestration 8000:8000"
@echo ""
@echo "Or get all services:"
@echo " kubectl get svc -n stats-agent"
# Delete deployment from Minikube
k8s-minikube-delete:
@echo "Deleting deployment from Minikube..."
helm uninstall stats-agent --namespace stats-agent || true
kubectl delete namespace stats-agent || true
@echo "Deployment deleted!"
# Push images to ECR (requires AWS CLI configured)
k8s-eks-push:
@if [ -z "$(REGISTRY)" ]; then echo "Error: REGISTRY not set. Use: make k8s-eks-push REGISTRY=your-ecr-registry"; exit 1; fi
@echo "Pushing images to ECR..."
@for agent in research synthesis verification orchestration-eino direct; do \
docker tag stats-agent-$$agent:$(IMAGE_TAG) $(REGISTRY)/stats-agent-$$agent:$(IMAGE_TAG) && \
docker push $(REGISTRY)/stats-agent-$$agent:$(IMAGE_TAG); \
done
@echo "All images pushed to ECR!"
# Deploy to AWS EKS with Helm
k8s-eks-deploy:
@if [ -z "$(REGISTRY)" ]; then echo "Error: REGISTRY not set. Use: make k8s-eks-deploy REGISTRY=your-ecr-registry"; exit 1; fi
@echo "Deploying to AWS EKS..."
helm upgrade --install stats-agent ./helm/stats-agent-team \
-f ./helm/stats-agent-team/values-eks.yaml \
--namespace stats-agent \
--create-namespace \
--set global.image.registry=$(REGISTRY) \
--set global.image.tag=$(IMAGE_TAG)
@echo ""
@echo "Deployment complete! Get the ALB address:"
@echo " kubectl get ingress -n stats-agent"
# Delete deployment from EKS
k8s-eks-delete:
@echo "Deleting deployment from EKS..."
helm uninstall stats-agent --namespace stats-agent || true
kubectl delete namespace stats-agent || true
@echo "Deployment deleted!"
# Lint Helm chart
helm-lint:
@echo "Linting Helm chart..."
helm lint ./helm/stats-agent-team
helm lint ./helm/stats-agent-team -f ./helm/stats-agent-team/values-minikube.yaml
helm lint ./helm/stats-agent-team -f ./helm/stats-agent-team/values-eks.yaml
@echo "Helm chart is valid!"
# Render Helm templates locally for debugging
helm-template:
@echo "Rendering Helm templates..."
helm template stats-agent ./helm/stats-agent-team -f ./helm/stats-agent-team/values-minikube.yaml
# ============================================
# Helm Chart Testing Commands
# ============================================
# Run helm-unittest (requires: helm plugin install https://github.com/helm-unittest/helm-unittest.git)
helm-unittest:
@echo "Running helm-unittest..."
@if helm plugin list | grep -q unittest; then \
helm unittest ./helm/stats-agent-team; \
else \
echo "Installing helm-unittest plugin..."; \
helm plugin install https://github.com/helm-unittest/helm-unittest.git; \
helm unittest ./helm/stats-agent-team; \
fi
# Validate rendered templates against Kubernetes schemas (requires: kubeconform)
helm-kubeconform:
@echo "Validating Kubernetes schemas with kubeconform..."
@if command -v kubeconform >/dev/null 2>&1; then \
helm template stats-agent ./helm/stats-agent-team | \
kubeconform -strict -summary -kubernetes-version 1.29.0; \
else \
echo "kubeconform not found. Install: brew install kubeconform (or see https://github.com/yannh/kubeconform)"; \
exit 1; \
fi
# Check security best practices with Polaris (requires: polaris)
helm-polaris:
@echo "Running Polaris security audit..."
@if command -v polaris >/dev/null 2>&1; then \
helm template stats-agent ./helm/stats-agent-team | \
polaris audit --audit-path - --format pretty; \
else \
echo "Polaris not found. Install: brew install FairwindsOps/tap/polaris (or see https://github.com/FairwindsOps/polaris)"; \
exit 1; \
fi
# Run all chart tests
helm-test-all: helm-lint helm-unittest helm-kubeconform
@echo ""
@echo "All Helm chart tests passed!"
# Quick test (lint + unittest only, no external tools required)
helm-test: helm-lint helm-unittest
@echo ""
@echo "Helm chart tests passed!"
# ============================================
# Documentation Commands
# ============================================
# Build MkDocs documentation (requires: pip install mkdocs mkdocs-material)
docs:
@echo "Building documentation..."
@if command -v mkdocs >/dev/null 2>&1; then \
mkdocs build; \
else \
echo "MkDocs not found. Install: pip install mkdocs mkdocs-material pymdown-extensions"; \
exit 1; \
fi
@echo "Documentation built in docs/"
# Serve documentation locally for development
docs-serve:
@echo "Starting documentation server..."
@if command -v mkdocs >/dev/null 2>&1; then \
mkdocs serve; \
else \
echo "MkDocs not found. Install: pip install mkdocs mkdocs-material pymdown-extensions"; \
exit 1; \
fi
# Clean generated documentation
docs-clean:
@echo "Cleaning generated documentation..."
rm -rf docs/*
touch docs/.gitkeep
@echo "Documentation cleaned!"