claude-flow 2.5.0-alpha.141 → 2.7.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/reasoning/README.md +171 -0
- package/.claude/agents/reasoning/agent.md +816 -0
- package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
- package/.claude/agents/reasoning/goal-planner.md +73 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/settings.json +3 -3
- package/.claude/sparc-modes.json +108 -0
- package/README.md +1 -6
- package/bin/claude-flow +1 -1
- package/dist/src/cli/command-registry.js +70 -6
- package/dist/src/cli/command-registry.js.map +1 -1
- package/dist/src/cli/help-formatter.js +0 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +53 -5
- package/dist/src/cli/help-text.js.map +1 -1
- package/dist/src/cli/simple-cli.js +182 -172
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/agent-booster.js +415 -0
- package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
- package/dist/src/cli/simple-commands/agent.js +856 -13
- package/dist/src/cli/simple-commands/agent.js.map +1 -1
- package/dist/src/cli/simple-commands/env-template.js +180 -0
- package/dist/src/cli/simple-commands/env-template.js.map +1 -0
- package/dist/src/cli/simple-commands/init/help.js +23 -0
- package/dist/src/cli/simple-commands/init/help.js.map +1 -1
- package/dist/src/cli/simple-commands/init/index.js +63 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +307 -16
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/proxy.js +304 -0
- package/dist/src/cli/simple-commands/proxy.js.map +1 -0
- package/dist/src/cli/simple-commands/sparc.js +16 -19
- package/dist/src/cli/simple-commands/sparc.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/core/version.js +1 -1
- package/dist/src/execution/agent-executor.js +181 -0
- package/dist/src/execution/agent-executor.js.map +1 -0
- package/dist/src/execution/index.js +12 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/provider-manager.js +110 -0
- package/dist/src/execution/provider-manager.js.map +1 -0
- package/dist/src/hooks/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/memory/swarm-memory.js +340 -421
- package/dist/src/memory/swarm-memory.js.map +1 -1
- package/dist/src/utils/key-redactor.js +108 -0
- package/dist/src/utils/key-redactor.js.map +1 -0
- package/dist/src/utils/metrics-reader.js +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
- package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
- package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
- package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
- package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
- package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
- package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
- package/docs/COMMIT_SUMMARY.md +247 -0
- package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
- package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
- package/docs/ENV-SETUP-GUIDE.md +270 -0
- package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
- package/docs/FINAL_VALIDATION_REPORT.md +165 -0
- package/docs/HOOKS-V2-MODIFICATION.md +146 -0
- package/docs/INDEX.md +568 -0
- package/docs/INTEGRATION_COMPLETE.md +414 -0
- package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
- package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
- package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
- package/docs/README.md +35 -0
- package/docs/REASONING-AGENTS.md +482 -0
- package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
- package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
- package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
- package/docs/REASONINGBANK-BENCHMARK.md +396 -0
- package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
- package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
- package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
- package/docs/REASONINGBANK-DEMO.md +419 -0
- package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
- package/docs/REASONINGBANK-VALIDATION.md +532 -0
- package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
- package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
- package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
- package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
- package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
- package/docs/api/API_DOCUMENTATION.md +721 -0
- package/docs/architecture/ARCHITECTURE.md +1690 -0
- package/docs/ci-cd/README.md +368 -0
- package/docs/development/DEPLOYMENT.md +2348 -0
- package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
- package/docs/development/build-analysis-report.md +252 -0
- package/docs/development/pair-optimization.md +156 -0
- package/docs/development/token-tracking-status.md +103 -0
- package/docs/development/training-pipeline-demo.md +163 -0
- package/docs/development/training-pipeline-real-only.md +196 -0
- package/docs/epic-sdk-integration.md +1269 -0
- package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
- package/docs/experimental/computational_verification.py +436 -0
- package/docs/experimental/novel_approaches.md +560 -0
- package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
- package/docs/experimental/riemann_proof_attempt.md +124 -0
- package/docs/experimental/riemann_synthesis.md +277 -0
- package/docs/experimental/verification_results.json +12 -0
- package/docs/experimental/visualization_insights.md +720 -0
- package/docs/guides/USER_GUIDE.md +1138 -0
- package/docs/guides/token-tracking-guide.md +291 -0
- package/docs/reference/AGENTS.md +1011 -0
- package/docs/reference/MCP_TOOLS.md +2188 -0
- package/docs/reference/SPARC.md +717 -0
- package/docs/reference/SWARM.md +2000 -0
- package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
- package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
- package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
- package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
- package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
- package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
- package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
- package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
- package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
- package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
- package/docs/sdk/epic-sdk-integration.md +1269 -0
- package/docs/setup/remote-setup.md +93 -0
- package/docs/validation/final-validation-summary.md +220 -0
- package/docs/validation/verification-integration.md +190 -0
- package/docs/validation/verification-validation.md +349 -0
- package/docs/wiki/background-commands.md +1213 -0
- package/docs/wiki/session-persistence.md +342 -0
- package/docs/wiki/stream-chain-command.md +537 -0
- package/package.json +4 -2
- package/src/cli/command-registry.js +70 -5
- package/src/cli/help-text.js +26 -5
- package/src/cli/simple-cli.ts +18 -7
- package/src/cli/simple-commands/agent-booster.js +515 -0
- package/src/cli/simple-commands/agent.js +1001 -12
- package/src/cli/simple-commands/agent.ts +137 -0
- package/src/cli/simple-commands/config.ts +127 -0
- package/src/cli/simple-commands/env-template.js +190 -0
- package/src/cli/simple-commands/init/help.js +23 -0
- package/src/cli/simple-commands/init/index.js +84 -6
- package/src/cli/simple-commands/memory.js +363 -16
- package/src/cli/simple-commands/proxy.js +384 -0
- package/src/cli/simple-commands/sparc.js +16 -19
- package/src/execution/agent-executor.ts +306 -0
- package/src/execution/index.ts +19 -0
- package/src/execution/provider-manager.ts +187 -0
- package/src/hooks/redaction-hook.ts +115 -0
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -0,0 +1,2348 @@
|
|
|
1
|
+
# 🚀 Claude-Flow Production Deployment Guide
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Quick Start](#quick-start)
|
|
6
|
+
- [System Requirements](#system-requirements)
|
|
7
|
+
- [Environment Variables](#environment-variables)
|
|
8
|
+
- [Docker Deployment](#docker-deployment)
|
|
9
|
+
- [Kubernetes Deployment](#kubernetes-deployment)
|
|
10
|
+
- [CI/CD Pipeline](#cicd-pipeline)
|
|
11
|
+
- [Monitoring & Observability](#monitoring--observability)
|
|
12
|
+
- [Security Configuration](#security-configuration)
|
|
13
|
+
- [Load Balancing](#load-balancing)
|
|
14
|
+
- [Production Setup](#production-setup)
|
|
15
|
+
- [Cloud Deployment](#cloud-deployment)
|
|
16
|
+
- [Troubleshooting](#troubleshooting)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### Production Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Install from npm registry
|
|
26
|
+
npm install -g claude-flow@alpha
|
|
27
|
+
|
|
28
|
+
# Verify installation
|
|
29
|
+
npx claude-flow@alpha --version
|
|
30
|
+
|
|
31
|
+
# Initialize configuration
|
|
32
|
+
npx claude-flow@alpha init --force
|
|
33
|
+
|
|
34
|
+
# Test installation
|
|
35
|
+
npx claude-flow@alpha swarm "test deployment" --agents 3
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Prerequisites Check
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Check Node.js version (requires ≥20.0.0)
|
|
42
|
+
node --version
|
|
43
|
+
|
|
44
|
+
# Check npm version (requires ≥9.0.0)
|
|
45
|
+
npm --version
|
|
46
|
+
|
|
47
|
+
# Check system resources
|
|
48
|
+
free -h # Memory check
|
|
49
|
+
df -h # Disk space check
|
|
50
|
+
|
|
51
|
+
# Install required tools
|
|
52
|
+
apt-get update && apt-get install -y curl wget jq
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## System Requirements
|
|
58
|
+
|
|
59
|
+
### Production Requirements
|
|
60
|
+
|
|
61
|
+
| Component | Minimum | Recommended | Enterprise |
|
|
62
|
+
|-----------|---------|-------------|------------|
|
|
63
|
+
| Node.js | v20.0.0 | v20 LTS | v20 LTS |
|
|
64
|
+
| RAM | 4 GB | 8 GB | 16 GB |
|
|
65
|
+
| CPU | 2 cores | 4 cores | 8+ cores |
|
|
66
|
+
| Disk Space | 2 GB | 10 GB | 50 GB |
|
|
67
|
+
| Network | 100 Mbps | 1 Gbps | 10 Gbps |
|
|
68
|
+
| Uptime SLA | 99% | 99.9% | 99.99% |
|
|
69
|
+
|
|
70
|
+
### Operating System Support
|
|
71
|
+
|
|
72
|
+
- **Linux**: Ubuntu 20.04+, CentOS 8+, RHEL 8+, Amazon Linux 2
|
|
73
|
+
- **Docker**: Alpine 3.18+, Ubuntu 22.04+
|
|
74
|
+
- **Kubernetes**: 1.24+
|
|
75
|
+
- **Cloud**: AWS, GCP, Azure, DigitalOcean
|
|
76
|
+
|
|
77
|
+
### Network Requirements
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Required ports
|
|
81
|
+
3000/tcp # Main API server
|
|
82
|
+
8080/tcp # MCP server
|
|
83
|
+
5432/tcp # PostgreSQL (if used)
|
|
84
|
+
6379/tcp # Redis (if used)
|
|
85
|
+
9090/tcp # Prometheus metrics
|
|
86
|
+
3001/tcp # Grafana dashboard
|
|
87
|
+
|
|
88
|
+
# Outbound connections
|
|
89
|
+
https://api.anthropic.com # Claude API
|
|
90
|
+
https://api.openai.com # OpenAI API (optional)
|
|
91
|
+
https://registry.npmjs.org # Package registry
|
|
92
|
+
https://github.com # Repository access
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Environment Variables
|
|
98
|
+
|
|
99
|
+
### Production Environment Configuration
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Create production environment file
|
|
103
|
+
cat > .env.production << 'EOF'
|
|
104
|
+
# === Core Configuration ===
|
|
105
|
+
NODE_ENV=production
|
|
106
|
+
PORT=3000
|
|
107
|
+
HOST=0.0.0.0
|
|
108
|
+
|
|
109
|
+
# === API Keys ===
|
|
110
|
+
CLAUDE_API_KEY=sk-ant-api03-...
|
|
111
|
+
OPENAI_API_KEY=sk-...
|
|
112
|
+
GITHUB_TOKEN=ghp_...
|
|
113
|
+
|
|
114
|
+
# === Claude Flow Configuration ===
|
|
115
|
+
CLAUDE_FLOW_DEBUG=false
|
|
116
|
+
CLAUDE_FLOW_LOG_LEVEL=info
|
|
117
|
+
CLAUDE_FLOW_DATA_DIR=/app/data
|
|
118
|
+
CLAUDE_FLOW_MEMORY_DIR=/app/memory
|
|
119
|
+
CLAUDE_FLOW_CONFIG_DIR=/app/config
|
|
120
|
+
|
|
121
|
+
# === Performance Settings ===
|
|
122
|
+
CLAUDE_FLOW_MAX_AGENTS=100
|
|
123
|
+
CLAUDE_FLOW_MAX_CONCURRENT_TASKS=50
|
|
124
|
+
CLAUDE_FLOW_MEMORY_LIMIT=2048
|
|
125
|
+
CLAUDE_FLOW_CACHE_SIZE=512
|
|
126
|
+
CLAUDE_FLOW_WORKER_THREADS=8
|
|
127
|
+
|
|
128
|
+
# === Database Configuration ===
|
|
129
|
+
DATABASE_URL=postgresql://claude_flow:secure_password@postgres:5432/claude_flow
|
|
130
|
+
REDIS_URL=redis://redis:6379/0
|
|
131
|
+
CACHE_TTL=3600
|
|
132
|
+
CONNECTION_POOL_SIZE=20
|
|
133
|
+
|
|
134
|
+
# === Security ===
|
|
135
|
+
JWT_SECRET=your-secure-jwt-secret-256-bits
|
|
136
|
+
ENCRYPTION_KEY=your-encryption-key-256-bits
|
|
137
|
+
ALLOWED_ORIGINS=https://yourdomain.com
|
|
138
|
+
RATE_LIMIT_WINDOW=900000
|
|
139
|
+
RATE_LIMIT_MAX=100
|
|
140
|
+
|
|
141
|
+
# === Features ===
|
|
142
|
+
CLAUDE_FLOW_ENABLE_HOOKS=true
|
|
143
|
+
CLAUDE_FLOW_ENABLE_MCP=true
|
|
144
|
+
CLAUDE_FLOW_ENABLE_SWARM=true
|
|
145
|
+
CLAUDE_FLOW_ENABLE_METRICS=true
|
|
146
|
+
CLAUDE_FLOW_ENABLE_TRACING=true
|
|
147
|
+
|
|
148
|
+
# === Monitoring ===
|
|
149
|
+
PROMETHEUS_PORT=9090
|
|
150
|
+
GRAFANA_ADMIN_PASSWORD=secure-password
|
|
151
|
+
LOG_RETENTION_DAYS=30
|
|
152
|
+
METRICS_RETENTION_DAYS=90
|
|
153
|
+
|
|
154
|
+
# === Cloud Provider (AWS Example) ===
|
|
155
|
+
AWS_REGION=us-west-2
|
|
156
|
+
AWS_ACCESS_KEY_ID=AKIA...
|
|
157
|
+
AWS_SECRET_ACCESS_KEY=...
|
|
158
|
+
S3_BUCKET=claude-flow-backups
|
|
159
|
+
|
|
160
|
+
# === Notifications ===
|
|
161
|
+
SLACK_WEBHOOK_URL=https://hooks.slack.com/...
|
|
162
|
+
EMAIL_SMTP_HOST=smtp.sendgrid.net
|
|
163
|
+
EMAIL_SMTP_PORT=587
|
|
164
|
+
EMAIL_SMTP_USER=apikey
|
|
165
|
+
EMAIL_SMTP_PASS=SG...
|
|
166
|
+
EOF
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Configuration Validation
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Validate environment configuration
|
|
173
|
+
npx claude-flow@alpha config validate --env production
|
|
174
|
+
|
|
175
|
+
# Test API connectivity
|
|
176
|
+
npx claude-flow@alpha diagnostics --api-check
|
|
177
|
+
|
|
178
|
+
# Verify database connection
|
|
179
|
+
npx claude-flow@alpha diagnostics --db-check
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Docker Deployment
|
|
185
|
+
|
|
186
|
+
### Production Docker Image
|
|
187
|
+
|
|
188
|
+
```dockerfile
|
|
189
|
+
# Production Dockerfile
|
|
190
|
+
FROM node:20-alpine AS base
|
|
191
|
+
|
|
192
|
+
# Install system dependencies
|
|
193
|
+
RUN apk add --no-cache \
|
|
194
|
+
python3 \
|
|
195
|
+
make \
|
|
196
|
+
g++ \
|
|
197
|
+
sqlite \
|
|
198
|
+
postgresql-client \
|
|
199
|
+
redis \
|
|
200
|
+
curl \
|
|
201
|
+
jq
|
|
202
|
+
|
|
203
|
+
# Create app directory
|
|
204
|
+
WORKDIR /app
|
|
205
|
+
|
|
206
|
+
# Create non-root user
|
|
207
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
208
|
+
adduser -S claude-flow -u 1001 -G nodejs
|
|
209
|
+
|
|
210
|
+
# === Build Stage ===
|
|
211
|
+
FROM base AS builder
|
|
212
|
+
|
|
213
|
+
# Copy package files
|
|
214
|
+
COPY package*.json ./
|
|
215
|
+
COPY tsconfig*.json ./
|
|
216
|
+
|
|
217
|
+
# Install dependencies
|
|
218
|
+
RUN npm ci --only=production --no-audit --no-fund
|
|
219
|
+
|
|
220
|
+
# Copy source code
|
|
221
|
+
COPY src/ ./src/
|
|
222
|
+
COPY *.js *.ts *.json ./
|
|
223
|
+
|
|
224
|
+
# Build application
|
|
225
|
+
RUN npm run build
|
|
226
|
+
|
|
227
|
+
# === Production Stage ===
|
|
228
|
+
FROM base AS production
|
|
229
|
+
|
|
230
|
+
# Set environment
|
|
231
|
+
ENV NODE_ENV=production \
|
|
232
|
+
CLAUDE_FLOW_DATA_DIR=/app/data \
|
|
233
|
+
CLAUDE_FLOW_MEMORY_DIR=/app/memory \
|
|
234
|
+
CLAUDE_FLOW_CONFIG_DIR=/app/config \
|
|
235
|
+
CLAUDE_FLOW_LOG_LEVEL=info
|
|
236
|
+
|
|
237
|
+
# Copy built application
|
|
238
|
+
COPY --from=builder --chown=claude-flow:nodejs /app/dist ./dist
|
|
239
|
+
COPY --from=builder --chown=claude-flow:nodejs /app/node_modules ./node_modules
|
|
240
|
+
COPY --from=builder --chown=claude-flow:nodejs /app/package*.json ./
|
|
241
|
+
|
|
242
|
+
# Create data directories
|
|
243
|
+
RUN mkdir -p /app/data /app/memory /app/config /app/logs && \
|
|
244
|
+
chown -R claude-flow:nodejs /app
|
|
245
|
+
|
|
246
|
+
# Copy entrypoint script
|
|
247
|
+
COPY docker-entrypoint.sh /usr/local/bin/
|
|
248
|
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
249
|
+
|
|
250
|
+
# Expose ports
|
|
251
|
+
EXPOSE 3000 8080 9090
|
|
252
|
+
|
|
253
|
+
# Health check
|
|
254
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
255
|
+
CMD curl -f http://localhost:3000/health || exit 1
|
|
256
|
+
|
|
257
|
+
# Switch to non-root user
|
|
258
|
+
USER claude-flow:nodejs
|
|
259
|
+
|
|
260
|
+
# Start application
|
|
261
|
+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
262
|
+
CMD ["node", "dist/index.js"]
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Docker Entrypoint Script
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
#!/bin/sh
|
|
269
|
+
# docker-entrypoint.sh
|
|
270
|
+
|
|
271
|
+
set -e
|
|
272
|
+
|
|
273
|
+
# Initialize configuration if not exists
|
|
274
|
+
if [ ! -f "/app/config/config.json" ]; then
|
|
275
|
+
echo "Initializing Claude Flow configuration..."
|
|
276
|
+
npx claude-flow@alpha init --force --config-dir /app/config
|
|
277
|
+
fi
|
|
278
|
+
|
|
279
|
+
# Wait for database if DATABASE_URL is set
|
|
280
|
+
if [ -n "$DATABASE_URL" ]; then
|
|
281
|
+
echo "Waiting for database to be ready..."
|
|
282
|
+
until pg_isready -d "$DATABASE_URL" > /dev/null 2>&1; do
|
|
283
|
+
echo "Database not ready, waiting..."
|
|
284
|
+
sleep 2
|
|
285
|
+
done
|
|
286
|
+
echo "Database is ready!"
|
|
287
|
+
fi
|
|
288
|
+
|
|
289
|
+
# Wait for Redis if REDIS_URL is set
|
|
290
|
+
if [ -n "$REDIS_URL" ]; then
|
|
291
|
+
echo "Waiting for Redis to be ready..."
|
|
292
|
+
until redis-cli -u "$REDIS_URL" ping > /dev/null 2>&1; do
|
|
293
|
+
echo "Redis not ready, waiting..."
|
|
294
|
+
sleep 2
|
|
295
|
+
done
|
|
296
|
+
echo "Redis is ready!"
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
# Run database migrations
|
|
300
|
+
if [ "$NODE_ENV" = "production" ]; then
|
|
301
|
+
echo "Running database migrations..."
|
|
302
|
+
npx claude-flow@alpha db migrate
|
|
303
|
+
fi
|
|
304
|
+
|
|
305
|
+
# Start the application
|
|
306
|
+
echo "Starting Claude Flow..."
|
|
307
|
+
exec "$@"
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Production Docker Compose
|
|
311
|
+
|
|
312
|
+
```yaml
|
|
313
|
+
# docker-compose.production.yml
|
|
314
|
+
version: '3.8'
|
|
315
|
+
|
|
316
|
+
services:
|
|
317
|
+
# === Core Services ===
|
|
318
|
+
claude-flow:
|
|
319
|
+
image: claude-flow:2.0.0-production
|
|
320
|
+
container_name: claude-flow-app
|
|
321
|
+
restart: unless-stopped
|
|
322
|
+
ports:
|
|
323
|
+
- "3000:3000"
|
|
324
|
+
- "8080:8080"
|
|
325
|
+
environment:
|
|
326
|
+
NODE_ENV: production
|
|
327
|
+
CLAUDE_API_KEY: ${CLAUDE_API_KEY}
|
|
328
|
+
DATABASE_URL: postgresql://claude_flow:${DB_PASSWORD}@postgres:5432/claude_flow
|
|
329
|
+
REDIS_URL: redis://redis:6379/0
|
|
330
|
+
CLAUDE_FLOW_MAX_AGENTS: 100
|
|
331
|
+
CLAUDE_FLOW_MEMORY_LIMIT: 2048
|
|
332
|
+
volumes:
|
|
333
|
+
- claude-flow-data:/app/data
|
|
334
|
+
- claude-flow-memory:/app/memory
|
|
335
|
+
- claude-flow-config:/app/config
|
|
336
|
+
- claude-flow-logs:/app/logs
|
|
337
|
+
networks:
|
|
338
|
+
- claude-flow-net
|
|
339
|
+
depends_on:
|
|
340
|
+
postgres:
|
|
341
|
+
condition: service_healthy
|
|
342
|
+
redis:
|
|
343
|
+
condition: service_healthy
|
|
344
|
+
healthcheck:
|
|
345
|
+
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
|
346
|
+
interval: 30s
|
|
347
|
+
timeout: 10s
|
|
348
|
+
retries: 3
|
|
349
|
+
start_period: 60s
|
|
350
|
+
|
|
351
|
+
# === Database Services ===
|
|
352
|
+
postgres:
|
|
353
|
+
image: postgres:15-alpine
|
|
354
|
+
container_name: claude-flow-postgres
|
|
355
|
+
restart: unless-stopped
|
|
356
|
+
environment:
|
|
357
|
+
POSTGRES_DB: claude_flow
|
|
358
|
+
POSTGRES_USER: claude_flow
|
|
359
|
+
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
360
|
+
POSTGRES_INITDB_ARGS: "--auth-host=md5"
|
|
361
|
+
ports:
|
|
362
|
+
- "5432:5432"
|
|
363
|
+
volumes:
|
|
364
|
+
- postgres-data:/var/lib/postgresql/data
|
|
365
|
+
- ./init-scripts:/docker-entrypoint-initdb.d
|
|
366
|
+
networks:
|
|
367
|
+
- claude-flow-net
|
|
368
|
+
healthcheck:
|
|
369
|
+
test: ["CMD-SHELL", "pg_isready -U claude_flow -d claude_flow"]
|
|
370
|
+
interval: 30s
|
|
371
|
+
timeout: 10s
|
|
372
|
+
retries: 5
|
|
373
|
+
|
|
374
|
+
redis:
|
|
375
|
+
image: redis:7-alpine
|
|
376
|
+
container_name: claude-flow-redis
|
|
377
|
+
restart: unless-stopped
|
|
378
|
+
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
|
|
379
|
+
ports:
|
|
380
|
+
- "6379:6379"
|
|
381
|
+
volumes:
|
|
382
|
+
- redis-data:/data
|
|
383
|
+
networks:
|
|
384
|
+
- claude-flow-net
|
|
385
|
+
healthcheck:
|
|
386
|
+
test: ["CMD", "redis-cli", "ping"]
|
|
387
|
+
interval: 30s
|
|
388
|
+
timeout: 10s
|
|
389
|
+
retries: 3
|
|
390
|
+
|
|
391
|
+
# === Load Balancer ===
|
|
392
|
+
nginx:
|
|
393
|
+
image: nginx:alpine
|
|
394
|
+
container_name: claude-flow-nginx
|
|
395
|
+
restart: unless-stopped
|
|
396
|
+
ports:
|
|
397
|
+
- "80:80"
|
|
398
|
+
- "443:443"
|
|
399
|
+
volumes:
|
|
400
|
+
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
401
|
+
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
|
402
|
+
- ./ssl:/etc/nginx/ssl:ro
|
|
403
|
+
- nginx-cache:/var/cache/nginx
|
|
404
|
+
networks:
|
|
405
|
+
- claude-flow-net
|
|
406
|
+
depends_on:
|
|
407
|
+
- claude-flow
|
|
408
|
+
healthcheck:
|
|
409
|
+
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
|
|
410
|
+
interval: 30s
|
|
411
|
+
timeout: 10s
|
|
412
|
+
retries: 3
|
|
413
|
+
|
|
414
|
+
# === Monitoring Stack ===
|
|
415
|
+
prometheus:
|
|
416
|
+
image: prom/prometheus:latest
|
|
417
|
+
container_name: claude-flow-prometheus
|
|
418
|
+
restart: unless-stopped
|
|
419
|
+
ports:
|
|
420
|
+
- "9090:9090"
|
|
421
|
+
volumes:
|
|
422
|
+
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
423
|
+
- prometheus-data:/prometheus
|
|
424
|
+
networks:
|
|
425
|
+
- claude-flow-net
|
|
426
|
+
command:
|
|
427
|
+
- '--config.file=/etc/prometheus/prometheus.yml'
|
|
428
|
+
- '--storage.tsdb.path=/prometheus'
|
|
429
|
+
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
|
430
|
+
- '--web.console.templates=/etc/prometheus/consoles'
|
|
431
|
+
- '--storage.tsdb.retention.time=90d'
|
|
432
|
+
- '--web.enable-lifecycle'
|
|
433
|
+
|
|
434
|
+
grafana:
|
|
435
|
+
image: grafana/grafana:latest
|
|
436
|
+
container_name: claude-flow-grafana
|
|
437
|
+
restart: unless-stopped
|
|
438
|
+
ports:
|
|
439
|
+
- "3001:3000"
|
|
440
|
+
environment:
|
|
441
|
+
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD}
|
|
442
|
+
GF_INSTALL_PLUGINS: grafana-clock-panel,grafana-simple-json-datasource
|
|
443
|
+
volumes:
|
|
444
|
+
- grafana-data:/var/lib/grafana
|
|
445
|
+
- ./monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards
|
|
446
|
+
- ./monitoring/grafana/datasources:/etc/grafana/provisioning/datasources
|
|
447
|
+
networks:
|
|
448
|
+
- claude-flow-net
|
|
449
|
+
|
|
450
|
+
# === Backup Service ===
|
|
451
|
+
backup:
|
|
452
|
+
image: postgres:15-alpine
|
|
453
|
+
container_name: claude-flow-backup
|
|
454
|
+
restart: "no"
|
|
455
|
+
volumes:
|
|
456
|
+
- ./backups:/backups
|
|
457
|
+
- ./scripts/backup.sh:/backup.sh:ro
|
|
458
|
+
networks:
|
|
459
|
+
- claude-flow-net
|
|
460
|
+
environment:
|
|
461
|
+
DATABASE_URL: postgresql://claude_flow:${DB_PASSWORD}@postgres:5432/claude_flow
|
|
462
|
+
depends_on:
|
|
463
|
+
- postgres
|
|
464
|
+
profiles:
|
|
465
|
+
- backup
|
|
466
|
+
|
|
467
|
+
volumes:
|
|
468
|
+
postgres-data:
|
|
469
|
+
redis-data:
|
|
470
|
+
prometheus-data:
|
|
471
|
+
grafana-data:
|
|
472
|
+
claude-flow-data:
|
|
473
|
+
claude-flow-memory:
|
|
474
|
+
claude-flow-config:
|
|
475
|
+
claude-flow-logs:
|
|
476
|
+
nginx-cache:
|
|
477
|
+
|
|
478
|
+
networks:
|
|
479
|
+
claude-flow-net:
|
|
480
|
+
driver: bridge
|
|
481
|
+
ipam:
|
|
482
|
+
config:
|
|
483
|
+
- subnet: 172.20.0.0/16
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Building and Deployment
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
# Build production image
|
|
490
|
+
docker build -f Dockerfile.production -t claude-flow:2.0.0-production .
|
|
491
|
+
|
|
492
|
+
# Tag for registry
|
|
493
|
+
docker tag claude-flow:2.0.0-production your-registry.com/claude-flow:2.0.0
|
|
494
|
+
|
|
495
|
+
# Push to registry
|
|
496
|
+
docker push your-registry.com/claude-flow:2.0.0
|
|
497
|
+
|
|
498
|
+
# Deploy with Docker Compose
|
|
499
|
+
cp .env.production .env
|
|
500
|
+
docker-compose -f docker-compose.production.yml up -d
|
|
501
|
+
|
|
502
|
+
# View logs
|
|
503
|
+
docker-compose -f docker-compose.production.yml logs -f claude-flow
|
|
504
|
+
|
|
505
|
+
# Scale services
|
|
506
|
+
docker-compose -f docker-compose.production.yml up -d --scale claude-flow=3
|
|
507
|
+
|
|
508
|
+
# Health check
|
|
509
|
+
curl -f http://localhost/health
|
|
510
|
+
|
|
511
|
+
# Stop services
|
|
512
|
+
docker-compose -f docker-compose.production.yml down
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Docker Registry Setup
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
# Setup private registry (optional)
|
|
519
|
+
docker run -d -p 5000:5000 --name registry \
|
|
520
|
+
-v /opt/docker-registry:/var/lib/registry \
|
|
521
|
+
registry:2
|
|
522
|
+
|
|
523
|
+
# Build and push to private registry
|
|
524
|
+
docker build -t localhost:5000/claude-flow:2.0.0 .
|
|
525
|
+
docker push localhost:5000/claude-flow:2.0.0
|
|
526
|
+
|
|
527
|
+
# Pull from registry
|
|
528
|
+
docker pull localhost:5000/claude-flow:2.0.0
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Docker Deployment
|
|
534
|
+
|
|
535
|
+
### Dockerfile
|
|
536
|
+
|
|
537
|
+
```dockerfile
|
|
538
|
+
# Multi-stage build for optimal size
|
|
539
|
+
FROM node:20-alpine AS builder
|
|
540
|
+
|
|
541
|
+
# Install build dependencies
|
|
542
|
+
RUN apk add --no-cache python3 make g++ sqlite-dev
|
|
543
|
+
|
|
544
|
+
WORKDIR /app
|
|
545
|
+
|
|
546
|
+
# Copy package files
|
|
547
|
+
COPY package*.json ./
|
|
548
|
+
|
|
549
|
+
# Install dependencies
|
|
550
|
+
RUN npm ci --only=production
|
|
551
|
+
|
|
552
|
+
# Copy source code
|
|
553
|
+
COPY . .
|
|
554
|
+
|
|
555
|
+
# Build application
|
|
556
|
+
RUN npm run build
|
|
557
|
+
|
|
558
|
+
# Production stage
|
|
559
|
+
FROM node:20-alpine
|
|
560
|
+
|
|
561
|
+
# Install runtime dependencies
|
|
562
|
+
RUN apk add --no-cache sqlite
|
|
563
|
+
|
|
564
|
+
WORKDIR /app
|
|
565
|
+
|
|
566
|
+
# Copy built application
|
|
567
|
+
COPY --from=builder /app/dist ./dist
|
|
568
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
569
|
+
COPY --from=builder /app/package*.json ./
|
|
570
|
+
|
|
571
|
+
# Create data directories
|
|
572
|
+
RUN mkdir -p /data/.claude-flow /data/.swarm /data/memory
|
|
573
|
+
|
|
574
|
+
# Set environment variables
|
|
575
|
+
ENV NODE_ENV=production \
|
|
576
|
+
CLAUDE_FLOW_DATA_DIR=/data/.claude-flow \
|
|
577
|
+
CLAUDE_FLOW_MEMORY_DIR=/data/.swarm \
|
|
578
|
+
PORT=3000
|
|
579
|
+
|
|
580
|
+
# Expose ports
|
|
581
|
+
EXPOSE 3000 8080
|
|
582
|
+
|
|
583
|
+
# Health check
|
|
584
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
585
|
+
CMD node -e "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
|
|
586
|
+
|
|
587
|
+
# Run as non-root user
|
|
588
|
+
USER node
|
|
589
|
+
|
|
590
|
+
# Start application
|
|
591
|
+
CMD ["node", "dist/cli/main.js", "server"]
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### Docker Compose
|
|
595
|
+
|
|
596
|
+
```yaml
|
|
597
|
+
version: '3.8'
|
|
598
|
+
|
|
599
|
+
services:
|
|
600
|
+
claude-flow:
|
|
601
|
+
build: .
|
|
602
|
+
image: claude-flow:latest
|
|
603
|
+
container_name: claude-flow
|
|
604
|
+
restart: unless-stopped
|
|
605
|
+
ports:
|
|
606
|
+
- "3000:3000"
|
|
607
|
+
- "8080:8080"
|
|
608
|
+
environment:
|
|
609
|
+
- NODE_ENV=production
|
|
610
|
+
- CLAUDE_API_KEY=${CLAUDE_API_KEY}
|
|
611
|
+
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
612
|
+
- CLAUDE_FLOW_LOG_LEVEL=info
|
|
613
|
+
volumes:
|
|
614
|
+
- ./data:/data
|
|
615
|
+
- ./config:/app/config
|
|
616
|
+
- ./logs:/app/logs
|
|
617
|
+
networks:
|
|
618
|
+
- claude-flow-network
|
|
619
|
+
depends_on:
|
|
620
|
+
- redis
|
|
621
|
+
- postgres
|
|
622
|
+
|
|
623
|
+
redis:
|
|
624
|
+
image: redis:7-alpine
|
|
625
|
+
container_name: claude-flow-redis
|
|
626
|
+
restart: unless-stopped
|
|
627
|
+
ports:
|
|
628
|
+
- "6379:6379"
|
|
629
|
+
volumes:
|
|
630
|
+
- redis-data:/data
|
|
631
|
+
networks:
|
|
632
|
+
- claude-flow-network
|
|
633
|
+
|
|
634
|
+
postgres:
|
|
635
|
+
image: postgres:15-alpine
|
|
636
|
+
container_name: claude-flow-postgres
|
|
637
|
+
restart: unless-stopped
|
|
638
|
+
environment:
|
|
639
|
+
- POSTGRES_DB=claude_flow
|
|
640
|
+
- POSTGRES_USER=claude_flow
|
|
641
|
+
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
|
642
|
+
ports:
|
|
643
|
+
- "5432:5432"
|
|
644
|
+
volumes:
|
|
645
|
+
- postgres-data:/var/lib/postgresql/data
|
|
646
|
+
networks:
|
|
647
|
+
- claude-flow-network
|
|
648
|
+
|
|
649
|
+
nginx:
|
|
650
|
+
image: nginx:alpine
|
|
651
|
+
container_name: claude-flow-nginx
|
|
652
|
+
restart: unless-stopped
|
|
653
|
+
ports:
|
|
654
|
+
- "80:80"
|
|
655
|
+
- "443:443"
|
|
656
|
+
volumes:
|
|
657
|
+
- ./nginx.conf:/etc/nginx/nginx.conf
|
|
658
|
+
- ./ssl:/etc/nginx/ssl
|
|
659
|
+
depends_on:
|
|
660
|
+
- claude-flow
|
|
661
|
+
networks:
|
|
662
|
+
- claude-flow-network
|
|
663
|
+
|
|
664
|
+
volumes:
|
|
665
|
+
redis-data:
|
|
666
|
+
postgres-data:
|
|
667
|
+
|
|
668
|
+
networks:
|
|
669
|
+
claude-flow-network:
|
|
670
|
+
driver: bridge
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### Building and Running
|
|
674
|
+
|
|
675
|
+
```bash
|
|
676
|
+
# Build Docker image
|
|
677
|
+
docker build -t claude-flow:latest .
|
|
678
|
+
|
|
679
|
+
# Run with Docker
|
|
680
|
+
docker run -d \
|
|
681
|
+
--name claude-flow \
|
|
682
|
+
-p 3000:3000 \
|
|
683
|
+
-e CLAUDE_API_KEY=$CLAUDE_API_KEY \
|
|
684
|
+
-v $(pwd)/data:/data \
|
|
685
|
+
claude-flow:latest
|
|
686
|
+
|
|
687
|
+
# Run with Docker Compose
|
|
688
|
+
docker-compose up -d
|
|
689
|
+
|
|
690
|
+
# View logs
|
|
691
|
+
docker logs -f claude-flow
|
|
692
|
+
|
|
693
|
+
# Stop container
|
|
694
|
+
docker stop claude-flow
|
|
695
|
+
|
|
696
|
+
# Remove container
|
|
697
|
+
docker rm claude-flow
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
#### Services and Ingress
|
|
701
|
+
|
|
702
|
+
```yaml
|
|
703
|
+
# k8s/service.yaml
|
|
704
|
+
apiVersion: v1
|
|
705
|
+
kind: Service
|
|
706
|
+
metadata:
|
|
707
|
+
name: claude-flow-service
|
|
708
|
+
namespace: claude-flow
|
|
709
|
+
labels:
|
|
710
|
+
app: claude-flow
|
|
711
|
+
spec:
|
|
712
|
+
type: ClusterIP
|
|
713
|
+
selector:
|
|
714
|
+
app: claude-flow
|
|
715
|
+
ports:
|
|
716
|
+
- name: http
|
|
717
|
+
port: 80
|
|
718
|
+
targetPort: 3000
|
|
719
|
+
protocol: TCP
|
|
720
|
+
- name: mcp
|
|
721
|
+
port: 8080
|
|
722
|
+
targetPort: 8080
|
|
723
|
+
protocol: TCP
|
|
724
|
+
- name: metrics
|
|
725
|
+
port: 9090
|
|
726
|
+
targetPort: 9090
|
|
727
|
+
protocol: TCP
|
|
728
|
+
---
|
|
729
|
+
# Load Balancer Service
|
|
730
|
+
apiVersion: v1
|
|
731
|
+
kind: Service
|
|
732
|
+
metadata:
|
|
733
|
+
name: claude-flow-lb
|
|
734
|
+
namespace: claude-flow
|
|
735
|
+
annotations:
|
|
736
|
+
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
|
|
737
|
+
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-west-2:123456789:certificate/..."
|
|
738
|
+
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
|
|
739
|
+
spec:
|
|
740
|
+
type: LoadBalancer
|
|
741
|
+
selector:
|
|
742
|
+
app: claude-flow
|
|
743
|
+
ports:
|
|
744
|
+
- name: https
|
|
745
|
+
port: 443
|
|
746
|
+
targetPort: 3000
|
|
747
|
+
protocol: TCP
|
|
748
|
+
- name: http
|
|
749
|
+
port: 80
|
|
750
|
+
targetPort: 3000
|
|
751
|
+
protocol: TCP
|
|
752
|
+
---
|
|
753
|
+
# Ingress for advanced routing
|
|
754
|
+
apiVersion: networking.k8s.io/v1
|
|
755
|
+
kind: Ingress
|
|
756
|
+
metadata:
|
|
757
|
+
name: claude-flow-ingress
|
|
758
|
+
namespace: claude-flow
|
|
759
|
+
annotations:
|
|
760
|
+
kubernetes.io/ingress.class: "nginx"
|
|
761
|
+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
|
762
|
+
nginx.ingress.kubernetes.io/rate-limit: "100"
|
|
763
|
+
nginx.ingress.kubernetes.io/rate-limit-window: "1m"
|
|
764
|
+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
|
765
|
+
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
|
766
|
+
nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
|
|
767
|
+
nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
|
|
768
|
+
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
|
|
769
|
+
spec:
|
|
770
|
+
tls:
|
|
771
|
+
- hosts:
|
|
772
|
+
- api.claude-flow.com
|
|
773
|
+
- mcp.claude-flow.com
|
|
774
|
+
secretName: claude-flow-tls
|
|
775
|
+
rules:
|
|
776
|
+
- host: api.claude-flow.com
|
|
777
|
+
http:
|
|
778
|
+
paths:
|
|
779
|
+
- path: /
|
|
780
|
+
pathType: Prefix
|
|
781
|
+
backend:
|
|
782
|
+
service:
|
|
783
|
+
name: claude-flow-service
|
|
784
|
+
port:
|
|
785
|
+
number: 80
|
|
786
|
+
- host: mcp.claude-flow.com
|
|
787
|
+
http:
|
|
788
|
+
paths:
|
|
789
|
+
- path: /
|
|
790
|
+
pathType: Prefix
|
|
791
|
+
backend:
|
|
792
|
+
service:
|
|
793
|
+
name: claude-flow-service
|
|
794
|
+
port:
|
|
795
|
+
number: 8080
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
#### Persistent Volumes and HPA
|
|
799
|
+
|
|
800
|
+
```yaml
|
|
801
|
+
# k8s/pvc.yaml
|
|
802
|
+
apiVersion: v1
|
|
803
|
+
kind: PersistentVolumeClaim
|
|
804
|
+
metadata:
|
|
805
|
+
name: claude-flow-data-pvc
|
|
806
|
+
namespace: claude-flow
|
|
807
|
+
spec:
|
|
808
|
+
accessModes:
|
|
809
|
+
- ReadWriteOnce
|
|
810
|
+
resources:
|
|
811
|
+
requests:
|
|
812
|
+
storage: 20Gi
|
|
813
|
+
storageClassName: gp3
|
|
814
|
+
---
|
|
815
|
+
apiVersion: v1
|
|
816
|
+
kind: PersistentVolumeClaim
|
|
817
|
+
metadata:
|
|
818
|
+
name: claude-flow-memory-pvc
|
|
819
|
+
namespace: claude-flow
|
|
820
|
+
spec:
|
|
821
|
+
accessModes:
|
|
822
|
+
- ReadWriteOnce
|
|
823
|
+
resources:
|
|
824
|
+
requests:
|
|
825
|
+
storage: 10Gi
|
|
826
|
+
storageClassName: gp3
|
|
827
|
+
---
|
|
828
|
+
# k8s/hpa.yaml
|
|
829
|
+
apiVersion: autoscaling/v2
|
|
830
|
+
kind: HorizontalPodAutoscaler
|
|
831
|
+
metadata:
|
|
832
|
+
name: claude-flow-hpa
|
|
833
|
+
namespace: claude-flow
|
|
834
|
+
spec:
|
|
835
|
+
scaleTargetRef:
|
|
836
|
+
apiVersion: apps/v1
|
|
837
|
+
kind: Deployment
|
|
838
|
+
name: claude-flow
|
|
839
|
+
minReplicas: 3
|
|
840
|
+
maxReplicas: 20
|
|
841
|
+
metrics:
|
|
842
|
+
- type: Resource
|
|
843
|
+
resource:
|
|
844
|
+
name: cpu
|
|
845
|
+
target:
|
|
846
|
+
type: Utilization
|
|
847
|
+
averageUtilization: 70
|
|
848
|
+
- type: Resource
|
|
849
|
+
resource:
|
|
850
|
+
name: memory
|
|
851
|
+
target:
|
|
852
|
+
type: Utilization
|
|
853
|
+
averageUtilization: 80
|
|
854
|
+
- type: Pods
|
|
855
|
+
pods:
|
|
856
|
+
metric:
|
|
857
|
+
name: custom_metric_requests_per_second
|
|
858
|
+
target:
|
|
859
|
+
type: AverageValue
|
|
860
|
+
averageValue: "50"
|
|
861
|
+
behavior:
|
|
862
|
+
scaleUp:
|
|
863
|
+
stabilizationWindowSeconds: 60
|
|
864
|
+
policies:
|
|
865
|
+
- type: Percent
|
|
866
|
+
value: 50
|
|
867
|
+
periodSeconds: 60
|
|
868
|
+
scaleDown:
|
|
869
|
+
stabilizationWindowSeconds: 300
|
|
870
|
+
policies:
|
|
871
|
+
- type: Percent
|
|
872
|
+
value: 10
|
|
873
|
+
periodSeconds: 60
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
#### Kubernetes Deployment Commands
|
|
877
|
+
|
|
878
|
+
```bash
|
|
879
|
+
# Create namespace
|
|
880
|
+
kubectl create namespace claude-flow
|
|
881
|
+
|
|
882
|
+
# Apply RBAC
|
|
883
|
+
kubectl apply -f k8s/namespace.yaml
|
|
884
|
+
|
|
885
|
+
# Create secrets (encode values with base64)
|
|
886
|
+
echo -n "your-claude-api-key" | base64
|
|
887
|
+
kubectl create secret generic claude-flow-secrets \
|
|
888
|
+
--from-literal=claude-api-key="$(echo -n 'your-api-key' | base64)" \
|
|
889
|
+
--from-literal=database-url="$(echo -n 'postgresql://...' | base64)" \
|
|
890
|
+
--from-literal=jwt-secret="$(echo -n 'your-jwt-secret' | base64)" \
|
|
891
|
+
-n claude-flow
|
|
892
|
+
|
|
893
|
+
# Apply configurations
|
|
894
|
+
kubectl apply -f k8s/configmap.yaml
|
|
895
|
+
kubectl apply -f k8s/pvc.yaml
|
|
896
|
+
kubectl apply -f k8s/deployment.yaml
|
|
897
|
+
kubectl apply -f k8s/service.yaml
|
|
898
|
+
kubectl apply -f k8s/ingress.yaml
|
|
899
|
+
kubectl apply -f k8s/hpa.yaml
|
|
900
|
+
|
|
901
|
+
# Check deployment status
|
|
902
|
+
kubectl get pods -n claude-flow -w
|
|
903
|
+
kubectl get svc -n claude-flow
|
|
904
|
+
kubectl get ingress -n claude-flow
|
|
905
|
+
|
|
906
|
+
# View logs
|
|
907
|
+
kubectl logs -f deployment/claude-flow -n claude-flow
|
|
908
|
+
|
|
909
|
+
# Scale deployment manually
|
|
910
|
+
kubectl scale deployment/claude-flow --replicas=5 -n claude-flow
|
|
911
|
+
|
|
912
|
+
# Rolling update
|
|
913
|
+
kubectl set image deployment/claude-flow claude-flow=your-registry.com/claude-flow:2.0.1 -n claude-flow
|
|
914
|
+
kubectl rollout status deployment/claude-flow -n claude-flow
|
|
915
|
+
|
|
916
|
+
# Rollback if needed
|
|
917
|
+
kubectl rollout undo deployment/claude-flow -n claude-flow
|
|
918
|
+
|
|
919
|
+
# Port forward for testing
|
|
920
|
+
kubectl port-forward svc/claude-flow-service 3000:80 -n claude-flow
|
|
921
|
+
|
|
922
|
+
# Delete deployment
|
|
923
|
+
kubectl delete namespace claude-flow
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
---
|
|
927
|
+
|
|
928
|
+
## CI/CD Pipeline
|
|
929
|
+
|
|
930
|
+
### GitHub Actions Workflow
|
|
931
|
+
|
|
932
|
+
```yaml
|
|
933
|
+
# .github/workflows/deploy.yml
|
|
934
|
+
name: Deploy Claude Flow
|
|
935
|
+
|
|
936
|
+
on:
|
|
937
|
+
push:
|
|
938
|
+
branches: [main, staging, production]
|
|
939
|
+
tags: ['v*']
|
|
940
|
+
pull_request:
|
|
941
|
+
branches: [main]
|
|
942
|
+
|
|
943
|
+
env:
|
|
944
|
+
REGISTRY: ghcr.io
|
|
945
|
+
IMAGE_NAME: ${{ github.repository }}
|
|
946
|
+
|
|
947
|
+
jobs:
|
|
948
|
+
test:
|
|
949
|
+
runs-on: ubuntu-latest
|
|
950
|
+
strategy:
|
|
951
|
+
matrix:
|
|
952
|
+
node-version: [20]
|
|
953
|
+
steps:
|
|
954
|
+
- uses: actions/checkout@v4
|
|
955
|
+
|
|
956
|
+
- name: Setup Node.js
|
|
957
|
+
uses: actions/setup-node@v4
|
|
958
|
+
with:
|
|
959
|
+
node-version: ${{ matrix.node-version }}
|
|
960
|
+
cache: 'npm'
|
|
961
|
+
|
|
962
|
+
- name: Install dependencies
|
|
963
|
+
run: npm ci
|
|
964
|
+
|
|
965
|
+
- name: Run linting
|
|
966
|
+
run: npm run lint
|
|
967
|
+
|
|
968
|
+
- name: Run type checking
|
|
969
|
+
run: npm run typecheck
|
|
970
|
+
|
|
971
|
+
- name: Run tests
|
|
972
|
+
run: npm run test:coverage
|
|
973
|
+
env:
|
|
974
|
+
CLAUDE_API_KEY: ${{ secrets.CLAUDE_API_KEY }}
|
|
975
|
+
|
|
976
|
+
- name: Upload coverage
|
|
977
|
+
uses: codecov/codecov-action@v3
|
|
978
|
+
|
|
979
|
+
security-scan:
|
|
980
|
+
runs-on: ubuntu-latest
|
|
981
|
+
steps:
|
|
982
|
+
- uses: actions/checkout@v4
|
|
983
|
+
|
|
984
|
+
- name: Run Snyk to check for vulnerabilities
|
|
985
|
+
uses: snyk/actions/node@master
|
|
986
|
+
env:
|
|
987
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
988
|
+
|
|
989
|
+
- name: Run Trivy vulnerability scanner
|
|
990
|
+
uses: aquasecurity/trivy-action@master
|
|
991
|
+
with:
|
|
992
|
+
scan-type: 'fs'
|
|
993
|
+
scan-ref: '.'
|
|
994
|
+
|
|
995
|
+
build:
|
|
996
|
+
needs: [test, security-scan]
|
|
997
|
+
runs-on: ubuntu-latest
|
|
998
|
+
permissions:
|
|
999
|
+
contents: read
|
|
1000
|
+
packages: write
|
|
1001
|
+
outputs:
|
|
1002
|
+
image: ${{ steps.image.outputs.image }}
|
|
1003
|
+
digest: ${{ steps.build.outputs.digest }}
|
|
1004
|
+
steps:
|
|
1005
|
+
- uses: actions/checkout@v4
|
|
1006
|
+
|
|
1007
|
+
- name: Setup Docker Buildx
|
|
1008
|
+
uses: docker/setup-buildx-action@v3
|
|
1009
|
+
|
|
1010
|
+
- name: Login to Container Registry
|
|
1011
|
+
uses: docker/login-action@v3
|
|
1012
|
+
with:
|
|
1013
|
+
registry: ${{ env.REGISTRY }}
|
|
1014
|
+
username: ${{ github.actor }}
|
|
1015
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
1016
|
+
|
|
1017
|
+
- name: Extract metadata
|
|
1018
|
+
id: meta
|
|
1019
|
+
uses: docker/metadata-action@v5
|
|
1020
|
+
with:
|
|
1021
|
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
1022
|
+
tags: |
|
|
1023
|
+
type=ref,event=branch
|
|
1024
|
+
type=ref,event=pr
|
|
1025
|
+
type=semver,pattern={{version}}
|
|
1026
|
+
type=semver,pattern={{major}}.{{minor}}
|
|
1027
|
+
type=sha,prefix=sha-
|
|
1028
|
+
|
|
1029
|
+
- name: Build and push
|
|
1030
|
+
id: build
|
|
1031
|
+
uses: docker/build-push-action@v5
|
|
1032
|
+
with:
|
|
1033
|
+
context: .
|
|
1034
|
+
file: ./Dockerfile.production
|
|
1035
|
+
push: true
|
|
1036
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
1037
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
1038
|
+
cache-from: type=gha
|
|
1039
|
+
cache-to: type=gha,mode=max
|
|
1040
|
+
platforms: linux/amd64,linux/arm64
|
|
1041
|
+
|
|
1042
|
+
- name: Output image
|
|
1043
|
+
id: image
|
|
1044
|
+
run: |
|
|
1045
|
+
echo "image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
|
|
1046
|
+
|
|
1047
|
+
deploy-staging:
|
|
1048
|
+
needs: build
|
|
1049
|
+
runs-on: ubuntu-latest
|
|
1050
|
+
if: github.ref == 'refs/heads/staging'
|
|
1051
|
+
environment: staging
|
|
1052
|
+
steps:
|
|
1053
|
+
- uses: actions/checkout@v4
|
|
1054
|
+
|
|
1055
|
+
- name: Configure AWS credentials
|
|
1056
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
1057
|
+
with:
|
|
1058
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
1059
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
1060
|
+
aws-region: us-west-2
|
|
1061
|
+
|
|
1062
|
+
- name: Setup kubectl
|
|
1063
|
+
uses: azure/setup-kubectl@v3
|
|
1064
|
+
with:
|
|
1065
|
+
version: 'v1.28.0'
|
|
1066
|
+
|
|
1067
|
+
- name: Update kubeconfig
|
|
1068
|
+
run: aws eks update-kubeconfig --region us-west-2 --name claude-flow-staging
|
|
1069
|
+
|
|
1070
|
+
- name: Deploy to staging
|
|
1071
|
+
run: |
|
|
1072
|
+
kubectl set image deployment/claude-flow claude-flow=${{ needs.build.outputs.image }} -n claude-flow-staging
|
|
1073
|
+
kubectl rollout status deployment/claude-flow -n claude-flow-staging --timeout=300s
|
|
1074
|
+
|
|
1075
|
+
- name: Run smoke tests
|
|
1076
|
+
run: |
|
|
1077
|
+
kubectl port-forward svc/claude-flow-service 3000:80 -n claude-flow-staging &
|
|
1078
|
+
sleep 10
|
|
1079
|
+
curl -f http://localhost:3000/health || exit 1
|
|
1080
|
+
npx claude-flow@alpha swarm "test deployment" --agents 1 || exit 1
|
|
1081
|
+
|
|
1082
|
+
deploy-production:
|
|
1083
|
+
needs: build
|
|
1084
|
+
runs-on: ubuntu-latest
|
|
1085
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
1086
|
+
environment: production
|
|
1087
|
+
steps:
|
|
1088
|
+
- uses: actions/checkout@v4
|
|
1089
|
+
|
|
1090
|
+
- name: Configure AWS credentials
|
|
1091
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
1092
|
+
with:
|
|
1093
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
1094
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
1095
|
+
aws-region: us-west-2
|
|
1096
|
+
|
|
1097
|
+
- name: Setup kubectl
|
|
1098
|
+
uses: azure/setup-kubectl@v3
|
|
1099
|
+
|
|
1100
|
+
- name: Update kubeconfig
|
|
1101
|
+
run: aws eks update-kubeconfig --region us-west-2 --name claude-flow-production
|
|
1102
|
+
|
|
1103
|
+
- name: Deploy to production
|
|
1104
|
+
run: |
|
|
1105
|
+
# Blue-green deployment
|
|
1106
|
+
kubectl patch deployment claude-flow -p '{"spec":{"template":{"spec":{"containers":[{"name":"claude-flow","image":"${{ needs.build.outputs.image }}"}]}}}}' -n claude-flow
|
|
1107
|
+
kubectl rollout status deployment/claude-flow -n claude-flow --timeout=600s
|
|
1108
|
+
|
|
1109
|
+
- name: Run production tests
|
|
1110
|
+
run: |
|
|
1111
|
+
# Wait for deployment to be ready
|
|
1112
|
+
kubectl wait --for=condition=available --timeout=300s deployment/claude-flow -n claude-flow
|
|
1113
|
+
|
|
1114
|
+
# Run health checks
|
|
1115
|
+
EXTERNAL_IP=$(kubectl get svc claude-flow-lb -n claude-flow -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
|
|
1116
|
+
curl -f "https://$EXTERNAL_IP/health" || exit 1
|
|
1117
|
+
|
|
1118
|
+
- name: Notify deployment
|
|
1119
|
+
uses: 8398a7/action-slack@v3
|
|
1120
|
+
with:
|
|
1121
|
+
status: ${{ job.status }}
|
|
1122
|
+
text: "Claude Flow ${{ github.ref_name }} deployed to production"
|
|
1123
|
+
env:
|
|
1124
|
+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
### Terraform Infrastructure
|
|
1128
|
+
|
|
1129
|
+
```hcl
|
|
1130
|
+
# infrastructure/main.tf
|
|
1131
|
+
terraform {
|
|
1132
|
+
required_version = ">= 1.0"
|
|
1133
|
+
required_providers {
|
|
1134
|
+
aws = {
|
|
1135
|
+
source = "hashicorp/aws"
|
|
1136
|
+
version = "~> 5.0"
|
|
1137
|
+
}
|
|
1138
|
+
kubernetes = {
|
|
1139
|
+
source = "hashicorp/kubernetes"
|
|
1140
|
+
version = "~> 2.20"
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
backend "s3" {
|
|
1145
|
+
bucket = "claude-flow-terraform-state"
|
|
1146
|
+
key = "production/terraform.tfstate"
|
|
1147
|
+
region = "us-west-2"
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
# EKS Cluster
|
|
1152
|
+
resource "aws_eks_cluster" "claude_flow" {
|
|
1153
|
+
name = "claude-flow-production"
|
|
1154
|
+
role_arn = aws_iam_role.cluster.arn
|
|
1155
|
+
version = "1.28"
|
|
1156
|
+
|
|
1157
|
+
vpc_config {
|
|
1158
|
+
subnet_ids = aws_subnet.private[*].id
|
|
1159
|
+
endpoint_private_access = true
|
|
1160
|
+
endpoint_public_access = true
|
|
1161
|
+
public_access_cidrs = ["0.0.0.0/0"]
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
enabled_cluster_log_types = ["api", "audit", "authenticator", "controllerManager", "scheduler"]
|
|
1165
|
+
|
|
1166
|
+
depends_on = [
|
|
1167
|
+
aws_iam_role_policy_attachment.cluster_AmazonEKSClusterPolicy,
|
|
1168
|
+
]
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
# Node Group
|
|
1172
|
+
resource "aws_eks_node_group" "claude_flow" {
|
|
1173
|
+
cluster_name = aws_eks_cluster.claude_flow.name
|
|
1174
|
+
node_group_name = "claude-flow-nodes"
|
|
1175
|
+
node_role_arn = aws_iam_role.node_group.arn
|
|
1176
|
+
subnet_ids = aws_subnet.private[*].id
|
|
1177
|
+
instance_types = ["m5.large", "m5.xlarge"]
|
|
1178
|
+
|
|
1179
|
+
scaling_config {
|
|
1180
|
+
desired_size = 3
|
|
1181
|
+
max_size = 20
|
|
1182
|
+
min_size = 3
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
update_config {
|
|
1186
|
+
max_unavailable = 1
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
depends_on = [
|
|
1190
|
+
aws_iam_role_policy_attachment.node_group_AmazonEKSWorkerNodePolicy,
|
|
1191
|
+
aws_iam_role_policy_attachment.node_group_AmazonEKS_CNI_Policy,
|
|
1192
|
+
aws_iam_role_policy_attachment.node_group_AmazonEC2ContainerRegistryReadOnly,
|
|
1193
|
+
]
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
# RDS Instance
|
|
1197
|
+
resource "aws_db_instance" "claude_flow" {
|
|
1198
|
+
identifier = "claude-flow-production"
|
|
1199
|
+
engine = "postgres"
|
|
1200
|
+
engine_version = "15"
|
|
1201
|
+
instance_class = "db.r5.large"
|
|
1202
|
+
allocated_storage = 100
|
|
1203
|
+
max_allocated_storage = 1000
|
|
1204
|
+
|
|
1205
|
+
db_name = "claude_flow"
|
|
1206
|
+
username = "claude_flow"
|
|
1207
|
+
password = var.db_password
|
|
1208
|
+
|
|
1209
|
+
vpc_security_group_ids = [aws_security_group.rds.id]
|
|
1210
|
+
db_subnet_group_name = aws_db_subnet_group.claude_flow.name
|
|
1211
|
+
|
|
1212
|
+
backup_retention_period = 30
|
|
1213
|
+
backup_window = "03:00-04:00"
|
|
1214
|
+
maintenance_window = "sun:04:00-sun:05:00"
|
|
1215
|
+
|
|
1216
|
+
performance_insights_enabled = true
|
|
1217
|
+
monitoring_interval = 60
|
|
1218
|
+
monitoring_role_arn = aws_iam_role.rds_enhanced_monitoring.arn
|
|
1219
|
+
|
|
1220
|
+
deletion_protection = true
|
|
1221
|
+
skip_final_snapshot = false
|
|
1222
|
+
final_snapshot_identifier = "claude-flow-final-snapshot"
|
|
1223
|
+
|
|
1224
|
+
tags = {
|
|
1225
|
+
Environment = "production"
|
|
1226
|
+
Application = "claude-flow"
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
# ElastiCache Redis
|
|
1231
|
+
resource "aws_elasticache_replication_group" "claude_flow" {
|
|
1232
|
+
replication_group_id = "claude-flow-redis"
|
|
1233
|
+
description = "Redis cluster for Claude Flow"
|
|
1234
|
+
|
|
1235
|
+
node_type = "cache.r6g.large"
|
|
1236
|
+
port = 6379
|
|
1237
|
+
parameter_group_name = "default.redis7"
|
|
1238
|
+
|
|
1239
|
+
num_cache_clusters = 3
|
|
1240
|
+
automatic_failover_enabled = true
|
|
1241
|
+
multi_az_enabled = true
|
|
1242
|
+
|
|
1243
|
+
subnet_group_name = aws_elasticache_subnet_group.claude_flow.name
|
|
1244
|
+
security_group_ids = [aws_security_group.redis.id]
|
|
1245
|
+
|
|
1246
|
+
at_rest_encryption_enabled = true
|
|
1247
|
+
transit_encryption_enabled = true
|
|
1248
|
+
auth_token = var.redis_auth_token
|
|
1249
|
+
|
|
1250
|
+
snapshot_retention_limit = 7
|
|
1251
|
+
snapshot_window = "03:00-05:00"
|
|
1252
|
+
|
|
1253
|
+
tags = {
|
|
1254
|
+
Environment = "production"
|
|
1255
|
+
Application = "claude-flow"
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
# Application Load Balancer
|
|
1260
|
+
resource "aws_lb" "claude_flow" {
|
|
1261
|
+
name = "claude-flow-alb"
|
|
1262
|
+
internal = false
|
|
1263
|
+
load_balancer_type = "application"
|
|
1264
|
+
security_groups = [aws_security_group.alb.id]
|
|
1265
|
+
subnets = aws_subnet.public[*].id
|
|
1266
|
+
|
|
1267
|
+
enable_deletion_protection = true
|
|
1268
|
+
enable_http2 = true
|
|
1269
|
+
|
|
1270
|
+
access_logs {
|
|
1271
|
+
bucket = aws_s3_bucket.alb_logs.bucket
|
|
1272
|
+
prefix = "alb-logs"
|
|
1273
|
+
enabled = true
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
```
|
|
1277
|
+
|
|
1278
|
+
---
|
|
1279
|
+
|
|
1280
|
+
## Monitoring & Observability
|
|
1281
|
+
|
|
1282
|
+
### Prometheus Configuration
|
|
1283
|
+
|
|
1284
|
+
```yaml
|
|
1285
|
+
# monitoring/prometheus.yml
|
|
1286
|
+
global:
|
|
1287
|
+
scrape_interval: 15s
|
|
1288
|
+
evaluation_interval: 15s
|
|
1289
|
+
external_labels:
|
|
1290
|
+
cluster: 'claude-flow-production'
|
|
1291
|
+
environment: 'production'
|
|
1292
|
+
|
|
1293
|
+
rule_files:
|
|
1294
|
+
- "rules/*.yml"
|
|
1295
|
+
|
|
1296
|
+
alerting:
|
|
1297
|
+
alertmanagers:
|
|
1298
|
+
- static_configs:
|
|
1299
|
+
- targets: ['alertmanager:9093']
|
|
1300
|
+
|
|
1301
|
+
scrape_configs:
|
|
1302
|
+
# Claude Flow application
|
|
1303
|
+
- job_name: 'claude-flow'
|
|
1304
|
+
kubernetes_sd_configs:
|
|
1305
|
+
- role: pod
|
|
1306
|
+
namespaces:
|
|
1307
|
+
names: ['claude-flow']
|
|
1308
|
+
relabel_configs:
|
|
1309
|
+
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
|
|
1310
|
+
action: keep
|
|
1311
|
+
regex: true
|
|
1312
|
+
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
|
|
1313
|
+
action: replace
|
|
1314
|
+
target_label: __metrics_path__
|
|
1315
|
+
regex: (.+)
|
|
1316
|
+
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
|
|
1317
|
+
action: replace
|
|
1318
|
+
regex: ([^:]+)(?::\d+)?;(\d+)
|
|
1319
|
+
replacement: $1:$2
|
|
1320
|
+
target_label: __address__
|
|
1321
|
+
|
|
1322
|
+
# Node Exporter
|
|
1323
|
+
- job_name: 'node-exporter'
|
|
1324
|
+
kubernetes_sd_configs:
|
|
1325
|
+
- role: node
|
|
1326
|
+
relabel_configs:
|
|
1327
|
+
- source_labels: [__address__]
|
|
1328
|
+
regex: '(.*):10250'
|
|
1329
|
+
replacement: '${1}:9100'
|
|
1330
|
+
target_label: __address__
|
|
1331
|
+
|
|
1332
|
+
# PostgreSQL
|
|
1333
|
+
- job_name: 'postgres'
|
|
1334
|
+
static_configs:
|
|
1335
|
+
- targets: ['postgres-exporter:9187']
|
|
1336
|
+
|
|
1337
|
+
# Redis
|
|
1338
|
+
- job_name: 'redis'
|
|
1339
|
+
static_configs:
|
|
1340
|
+
- targets: ['redis-exporter:9121']
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
### Production Backup Strategy
|
|
1344
|
+
|
|
1345
|
+
```bash
|
|
1346
|
+
#!/bin/bash
|
|
1347
|
+
# scripts/backup.sh - Production backup script
|
|
1348
|
+
|
|
1349
|
+
set -euo pipefail
|
|
1350
|
+
|
|
1351
|
+
BACKUP_DIR="/backups/$(date +%Y/%m/%d)"
|
|
1352
|
+
DATE=$(date +%Y%m%d_%H%M%S)
|
|
1353
|
+
RETENTION_DAYS=30
|
|
1354
|
+
S3_BUCKET="claude-flow-backups"
|
|
1355
|
+
|
|
1356
|
+
# Create backup directory
|
|
1357
|
+
mkdir -p "$BACKUP_DIR"
|
|
1358
|
+
|
|
1359
|
+
# Database backup
|
|
1360
|
+
echo "Starting PostgreSQL backup..."
|
|
1361
|
+
pg_dump "$DATABASE_URL" | gzip > "$BACKUP_DIR/postgres_$DATE.sql.gz"
|
|
1362
|
+
|
|
1363
|
+
# Redis backup
|
|
1364
|
+
echo "Starting Redis backup..."
|
|
1365
|
+
redis-cli -u "$REDIS_URL" --rdb "$BACKUP_DIR/redis_$DATE.rdb"
|
|
1366
|
+
gzip "$BACKUP_DIR/redis_$DATE.rdb"
|
|
1367
|
+
|
|
1368
|
+
# Configuration backup
|
|
1369
|
+
echo "Backing up configurations..."
|
|
1370
|
+
kubectl get secret claude-flow-secrets -n claude-flow -o yaml > "$BACKUP_DIR/secrets_$DATE.yaml"
|
|
1371
|
+
kubectl get configmap claude-flow-config -n claude-flow -o yaml > "$BACKUP_DIR/config_$DATE.yaml"
|
|
1372
|
+
|
|
1373
|
+
# Application data backup
|
|
1374
|
+
echo "Backing up application data..."
|
|
1375
|
+
tar -czf "$BACKUP_DIR/app-data_$DATE.tar.gz" /app/data /app/memory
|
|
1376
|
+
|
|
1377
|
+
# Upload to S3
|
|
1378
|
+
echo "Uploading backups to S3..."
|
|
1379
|
+
aws s3 cp "$BACKUP_DIR/" "s3://$S3_BUCKET/$(date +%Y/%m/%d)/" --recursive
|
|
1380
|
+
|
|
1381
|
+
# Cleanup old backups
|
|
1382
|
+
echo "Cleaning up old backups..."
|
|
1383
|
+
find /backups -type f -mtime +$RETENTION_DAYS -delete
|
|
1384
|
+
aws s3 ls "s3://$S3_BUCKET/" --recursive | while read -r line; do
|
|
1385
|
+
createDate=$(echo $line | awk '{print $1" "$2}')
|
|
1386
|
+
createDate=$(date -d "$createDate" +%s)
|
|
1387
|
+
olderThan=$(date -d "$RETENTION_DAYS days ago" +%s)
|
|
1388
|
+
if [[ $createDate -lt $olderThan ]]; then
|
|
1389
|
+
fileName=$(echo $line | awk '{$1=$2=$3=""; print $0}' | sed 's/^[ \t]*//')
|
|
1390
|
+
aws s3 rm "s3://$S3_BUCKET/$fileName"
|
|
1391
|
+
fi
|
|
1392
|
+
done
|
|
1393
|
+
|
|
1394
|
+
echo "Backup completed successfully!"
|
|
1395
|
+
|
|
1396
|
+
# Send notification
|
|
1397
|
+
curl -X POST -H 'Content-type: application/json' \
|
|
1398
|
+
--data "{\"text\":\"✅ Claude Flow backup completed: $DATE\"}" \
|
|
1399
|
+
"$SLACK_WEBHOOK_URL"
|
|
1400
|
+
```
|
|
1401
|
+
|
|
1402
|
+
---
|
|
1403
|
+
|
|
1404
|
+
## Security Configuration
|
|
1405
|
+
|
|
1406
|
+
### Secrets Management with AWS Secrets Manager
|
|
1407
|
+
|
|
1408
|
+
```bash
|
|
1409
|
+
# Create secrets in AWS Secrets Manager
|
|
1410
|
+
aws secretsmanager create-secret \
|
|
1411
|
+
--name "claude-flow/api-keys" \
|
|
1412
|
+
--description "Claude Flow API keys" \
|
|
1413
|
+
--secret-string '{
|
|
1414
|
+
"claude-api-key": "sk-ant-api03-...",
|
|
1415
|
+
"openai-api-key": "sk-...",
|
|
1416
|
+
"github-token": "ghp_..."
|
|
1417
|
+
}'
|
|
1418
|
+
|
|
1419
|
+
aws secretsmanager create-secret \
|
|
1420
|
+
--name "claude-flow/database" \
|
|
1421
|
+
--description "Database connection details" \
|
|
1422
|
+
--secret-string '{
|
|
1423
|
+
"url": "postgresql://claude_flow:password@hostname:5432/claude_flow",
|
|
1424
|
+
"password": "secure-password"
|
|
1425
|
+
}'
|
|
1426
|
+
|
|
1427
|
+
aws secretsmanager create-secret \
|
|
1428
|
+
--name "claude-flow/jwt" \
|
|
1429
|
+
--description "JWT and encryption secrets" \
|
|
1430
|
+
--secret-string '{
|
|
1431
|
+
"jwt-secret": "your-jwt-secret-256-bits",
|
|
1432
|
+
"encryption-key": "your-encryption-key-256-bits"
|
|
1433
|
+
}'
|
|
1434
|
+
```
|
|
1435
|
+
|
|
1436
|
+
### WAF Configuration
|
|
1437
|
+
|
|
1438
|
+
```json
|
|
1439
|
+
{
|
|
1440
|
+
"Name": "claude-flow-waf",
|
|
1441
|
+
"Scope": "CLOUDFRONT",
|
|
1442
|
+
"DefaultAction": {
|
|
1443
|
+
"Allow": {}
|
|
1444
|
+
},
|
|
1445
|
+
"Rules": [
|
|
1446
|
+
{
|
|
1447
|
+
"Name": "AWSManagedRulesCommonRuleSet",
|
|
1448
|
+
"Priority": 1,
|
|
1449
|
+
"OverrideAction": {
|
|
1450
|
+
"None": {}
|
|
1451
|
+
},
|
|
1452
|
+
"Statement": {
|
|
1453
|
+
"ManagedRuleGroupStatement": {
|
|
1454
|
+
"VendorName": "AWS",
|
|
1455
|
+
"Name": "AWSManagedRulesCommonRuleSet"
|
|
1456
|
+
}
|
|
1457
|
+
},
|
|
1458
|
+
"VisibilityConfig": {
|
|
1459
|
+
"SampledRequestsEnabled": true,
|
|
1460
|
+
"CloudWatchMetricsEnabled": true,
|
|
1461
|
+
"MetricName": "CommonRuleSetMetric"
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
{
|
|
1465
|
+
"Name": "RateLimitRule",
|
|
1466
|
+
"Priority": 2,
|
|
1467
|
+
"Action": {
|
|
1468
|
+
"Block": {}
|
|
1469
|
+
},
|
|
1470
|
+
"Statement": {
|
|
1471
|
+
"RateBasedStatement": {
|
|
1472
|
+
"Limit": 2000,
|
|
1473
|
+
"AggregateKeyType": "IP"
|
|
1474
|
+
}
|
|
1475
|
+
},
|
|
1476
|
+
"VisibilityConfig": {
|
|
1477
|
+
"SampledRequestsEnabled": true,
|
|
1478
|
+
"CloudWatchMetricsEnabled": true,
|
|
1479
|
+
"MetricName": "RateLimitMetric"
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
]
|
|
1483
|
+
}
|
|
1484
|
+
```
|
|
1485
|
+
|
|
1486
|
+
---
|
|
1487
|
+
|
|
1488
|
+
## Load Balancing
|
|
1489
|
+
|
|
1490
|
+
### AWS Application Load Balancer
|
|
1491
|
+
|
|
1492
|
+
```bash
|
|
1493
|
+
# Create ALB
|
|
1494
|
+
aws elbv2 create-load-balancer \
|
|
1495
|
+
--name claude-flow-alb \
|
|
1496
|
+
--subnets subnet-12345 subnet-67890 \
|
|
1497
|
+
--security-groups sg-12345 \
|
|
1498
|
+
--scheme internet-facing \
|
|
1499
|
+
--type application \
|
|
1500
|
+
--ip-address-type ipv4
|
|
1501
|
+
|
|
1502
|
+
# Create target group
|
|
1503
|
+
aws elbv2 create-target-group \
|
|
1504
|
+
--name claude-flow-targets \
|
|
1505
|
+
--protocol HTTP \
|
|
1506
|
+
--port 3000 \
|
|
1507
|
+
--vpc-id vpc-12345 \
|
|
1508
|
+
--target-type ip \
|
|
1509
|
+
--health-check-enabled \
|
|
1510
|
+
--health-check-interval-seconds 30 \
|
|
1511
|
+
--health-check-path /health \
|
|
1512
|
+
--health-check-protocol HTTP \
|
|
1513
|
+
--health-check-timeout-seconds 5 \
|
|
1514
|
+
--healthy-threshold-count 2 \
|
|
1515
|
+
--unhealthy-threshold-count 2
|
|
1516
|
+
|
|
1517
|
+
# Create listener
|
|
1518
|
+
aws elbv2 create-listener \
|
|
1519
|
+
--load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:123456789:loadbalancer/app/claude-flow-alb/1234567890abcdef \
|
|
1520
|
+
--protocol HTTPS \
|
|
1521
|
+
--port 443 \
|
|
1522
|
+
--certificates CertificateArn=arn:aws:acm:us-west-2:123456789:certificate/12345678-1234-1234-1234-123456789012 \
|
|
1523
|
+
--default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-west-2:123456789:targetgroup/claude-flow-targets/1234567890abcdef
|
|
1524
|
+
```
|
|
1525
|
+
|
|
1526
|
+
---
|
|
1527
|
+
|
|
1528
|
+
## Cloud Deployment
|
|
1529
|
+
|
|
1530
|
+
### AWS Production Deployment
|
|
1531
|
+
|
|
1532
|
+
#### EKS Cluster Setup
|
|
1533
|
+
|
|
1534
|
+
```bash
|
|
1535
|
+
#!/bin/bash
|
|
1536
|
+
# Deploy Claude Flow to AWS EKS
|
|
1537
|
+
|
|
1538
|
+
# Variables
|
|
1539
|
+
CLUSTER_NAME="claude-flow-production"
|
|
1540
|
+
REGION="us-west-2"
|
|
1541
|
+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
|
1542
|
+
|
|
1543
|
+
# Create EKS cluster
|
|
1544
|
+
eksctl create cluster \
|
|
1545
|
+
--name $CLUSTER_NAME \
|
|
1546
|
+
--version 1.28 \
|
|
1547
|
+
--region $REGION \
|
|
1548
|
+
--nodegroup-name claude-flow-workers \
|
|
1549
|
+
--node-type m5.large \
|
|
1550
|
+
--nodes 3 \
|
|
1551
|
+
--nodes-min 3 \
|
|
1552
|
+
--nodes-max 20 \
|
|
1553
|
+
--with-oidc \
|
|
1554
|
+
--ssh-access \
|
|
1555
|
+
--ssh-public-key ~/.ssh/id_rsa.pub \
|
|
1556
|
+
--managed
|
|
1557
|
+
|
|
1558
|
+
# Install AWS Load Balancer Controller
|
|
1559
|
+
eksctl create iamserviceaccount \
|
|
1560
|
+
--cluster=$CLUSTER_NAME \
|
|
1561
|
+
--namespace=kube-system \
|
|
1562
|
+
--name=aws-load-balancer-controller \
|
|
1563
|
+
--attach-policy-arn=arn:aws:iam::$ACCOUNT_ID:policy/AWSLoadBalancerControllerIAMPolicy \
|
|
1564
|
+
--override-existing-serviceaccounts \
|
|
1565
|
+
--approve
|
|
1566
|
+
|
|
1567
|
+
helm repo add eks https://aws.github.io/eks-charts
|
|
1568
|
+
helm repo update
|
|
1569
|
+
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
|
|
1570
|
+
-n kube-system \
|
|
1571
|
+
--set clusterName=$CLUSTER_NAME \
|
|
1572
|
+
--set serviceAccount.create=false \
|
|
1573
|
+
--set serviceAccount.name=aws-load-balancer-controller
|
|
1574
|
+
|
|
1575
|
+
# Install EBS CSI driver
|
|
1576
|
+
eksctl create addon \
|
|
1577
|
+
--name aws-ebs-csi-driver \
|
|
1578
|
+
--cluster $CLUSTER_NAME \
|
|
1579
|
+
--service-account-role-arn arn:aws:iam::$ACCOUNT_ID:role/AmazonEKS_EBS_CSI_DriverRole
|
|
1580
|
+
|
|
1581
|
+
echo "EKS cluster $CLUSTER_NAME created successfully!"
|
|
1582
|
+
```
|
|
1583
|
+
|
|
1584
|
+
#### ECS Fargate Deployment
|
|
1585
|
+
|
|
1586
|
+
```json
|
|
1587
|
+
{
|
|
1588
|
+
"family": "claude-flow",
|
|
1589
|
+
"networkMode": "awsvpc",
|
|
1590
|
+
"requiresCompatibilities": ["FARGATE"],
|
|
1591
|
+
"cpu": "2048",
|
|
1592
|
+
"memory": "4096",
|
|
1593
|
+
"executionRoleArn": "arn:aws:iam::ACCOUNT:role/ecsTaskExecutionRole",
|
|
1594
|
+
"taskRoleArn": "arn:aws:iam::ACCOUNT:role/claudeFlowTaskRole",
|
|
1595
|
+
"containerDefinitions": [
|
|
1596
|
+
{
|
|
1597
|
+
"name": "claude-flow",
|
|
1598
|
+
"image": "ACCOUNT.dkr.ecr.us-west-2.amazonaws.com/claude-flow:2.0.0",
|
|
1599
|
+
"portMappings": [
|
|
1600
|
+
{"containerPort": 3000, "protocol": "tcp"},
|
|
1601
|
+
{"containerPort": 8080, "protocol": "tcp"}
|
|
1602
|
+
],
|
|
1603
|
+
"environment": [
|
|
1604
|
+
{"name": "NODE_ENV", "value": "production"},
|
|
1605
|
+
{"name": "CLAUDE_FLOW_MAX_AGENTS", "value": "100"}
|
|
1606
|
+
],
|
|
1607
|
+
"secrets": [
|
|
1608
|
+
{
|
|
1609
|
+
"name": "CLAUDE_API_KEY",
|
|
1610
|
+
"valueFrom": "arn:aws:secretsmanager:us-west-2:ACCOUNT:secret:claude-flow/api-keys:claude-api-key::"
|
|
1611
|
+
}
|
|
1612
|
+
],
|
|
1613
|
+
"logConfiguration": {
|
|
1614
|
+
"logDriver": "awslogs",
|
|
1615
|
+
"options": {
|
|
1616
|
+
"awslogs-group": "/ecs/claude-flow",
|
|
1617
|
+
"awslogs-region": "us-west-2",
|
|
1618
|
+
"awslogs-stream-prefix": "ecs"
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1621
|
+
"healthCheck": {
|
|
1622
|
+
"command": ["CMD-SHELL", "curl -f http://localhost:3000/health || exit 1"],
|
|
1623
|
+
"interval": 30,
|
|
1624
|
+
"timeout": 5,
|
|
1625
|
+
"retries": 3,
|
|
1626
|
+
"startPeriod": 60
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
]
|
|
1630
|
+
}
|
|
1631
|
+
```
|
|
1632
|
+
|
|
1633
|
+
```bash
|
|
1634
|
+
# Deploy ECS service
|
|
1635
|
+
aws ecs create-cluster --cluster-name claude-flow-production
|
|
1636
|
+
|
|
1637
|
+
aws ecs register-task-definition --cli-input-json file://task-definition.json
|
|
1638
|
+
|
|
1639
|
+
aws ecs create-service \
|
|
1640
|
+
--cluster claude-flow-production \
|
|
1641
|
+
--service-name claude-flow \
|
|
1642
|
+
--task-definition claude-flow:1 \
|
|
1643
|
+
--desired-count 3 \
|
|
1644
|
+
--launch-type FARGATE \
|
|
1645
|
+
--network-configuration "awsvpcConfiguration={subnets=[subnet-12345,subnet-67890],securityGroups=[sg-12345],assignPublicIp=DISABLED}" \
|
|
1646
|
+
--load-balancers "targetGroupArn=arn:aws:elasticloadbalancing:us-west-2:ACCOUNT:targetgroup/claude-flow/12345,containerName=claude-flow,containerPort=3000" \
|
|
1647
|
+
--enable-logging
|
|
1648
|
+
```
|
|
1649
|
+
|
|
1650
|
+
### Google Cloud Platform Production
|
|
1651
|
+
|
|
1652
|
+
#### GKE Deployment
|
|
1653
|
+
|
|
1654
|
+
```bash
|
|
1655
|
+
#!/bin/bash
|
|
1656
|
+
# Deploy to Google Kubernetes Engine
|
|
1657
|
+
|
|
1658
|
+
PROJECT_ID="your-project-id"
|
|
1659
|
+
CLUSTER_NAME="claude-flow-production"
|
|
1660
|
+
REGION="us-central1"
|
|
1661
|
+
|
|
1662
|
+
# Create GKE cluster
|
|
1663
|
+
gcloud container clusters create $CLUSTER_NAME \
|
|
1664
|
+
--project=$PROJECT_ID \
|
|
1665
|
+
--region=$REGION \
|
|
1666
|
+
--machine-type=e2-standard-4 \
|
|
1667
|
+
--num-nodes=3 \
|
|
1668
|
+
--min-nodes=3 \
|
|
1669
|
+
--max-nodes=20 \
|
|
1670
|
+
--enable-autoscaling \
|
|
1671
|
+
--enable-autorepair \
|
|
1672
|
+
--enable-autoupgrade \
|
|
1673
|
+
--enable-network-policy \
|
|
1674
|
+
--enable-ip-alias \
|
|
1675
|
+
--disk-size=50GB \
|
|
1676
|
+
--disk-type=pd-ssd \
|
|
1677
|
+
--release-channel=stable
|
|
1678
|
+
|
|
1679
|
+
# Get credentials
|
|
1680
|
+
gcloud container clusters get-credentials $CLUSTER_NAME --region=$REGION --project=$PROJECT_ID
|
|
1681
|
+
|
|
1682
|
+
# Install ingress controller
|
|
1683
|
+
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml
|
|
1684
|
+
|
|
1685
|
+
# Deploy application
|
|
1686
|
+
kubectl create namespace claude-flow
|
|
1687
|
+
kubectl apply -f k8s/ -n claude-flow
|
|
1688
|
+
|
|
1689
|
+
echo "GKE deployment completed!"
|
|
1690
|
+
```
|
|
1691
|
+
|
|
1692
|
+
#### Cloud Run Deployment
|
|
1693
|
+
|
|
1694
|
+
```yaml
|
|
1695
|
+
# cloud-run.yaml
|
|
1696
|
+
apiVersion: serving.knative.dev/v1
|
|
1697
|
+
kind: Service
|
|
1698
|
+
metadata:
|
|
1699
|
+
name: claude-flow
|
|
1700
|
+
annotations:
|
|
1701
|
+
run.googleapis.com/ingress: all
|
|
1702
|
+
run.googleapis.com/execution-environment: gen2
|
|
1703
|
+
spec:
|
|
1704
|
+
template:
|
|
1705
|
+
metadata:
|
|
1706
|
+
annotations:
|
|
1707
|
+
autoscaling.knative.dev/minScale: "3"
|
|
1708
|
+
autoscaling.knative.dev/maxScale: "100"
|
|
1709
|
+
run.googleapis.com/cpu-throttling: "false"
|
|
1710
|
+
run.googleapis.com/memory: "4Gi"
|
|
1711
|
+
run.googleapis.com/cpu: "2"
|
|
1712
|
+
spec:
|
|
1713
|
+
containerConcurrency: 100
|
|
1714
|
+
containers:
|
|
1715
|
+
- image: gcr.io/PROJECT_ID/claude-flow:2.0.0
|
|
1716
|
+
ports:
|
|
1717
|
+
- containerPort: 3000
|
|
1718
|
+
env:
|
|
1719
|
+
- name: NODE_ENV
|
|
1720
|
+
value: "production"
|
|
1721
|
+
- name: CLAUDE_API_KEY
|
|
1722
|
+
valueFrom:
|
|
1723
|
+
secretKeyRef:
|
|
1724
|
+
name: claude-flow-secrets
|
|
1725
|
+
key: claude-api-key
|
|
1726
|
+
resources:
|
|
1727
|
+
limits:
|
|
1728
|
+
cpu: "2"
|
|
1729
|
+
memory: "4Gi"
|
|
1730
|
+
livenessProbe:
|
|
1731
|
+
httpGet:
|
|
1732
|
+
path: /health
|
|
1733
|
+
port: 3000
|
|
1734
|
+
initialDelaySeconds: 60
|
|
1735
|
+
periodSeconds: 30
|
|
1736
|
+
startupProbe:
|
|
1737
|
+
httpGet:
|
|
1738
|
+
path: /ready
|
|
1739
|
+
port: 3000
|
|
1740
|
+
initialDelaySeconds: 10
|
|
1741
|
+
periodSeconds: 10
|
|
1742
|
+
failureThreshold: 30
|
|
1743
|
+
```
|
|
1744
|
+
|
|
1745
|
+
```bash
|
|
1746
|
+
# Deploy to Cloud Run
|
|
1747
|
+
gcloud run services replace cloud-run.yaml \
|
|
1748
|
+
--region=us-central1 \
|
|
1749
|
+
--project=your-project-id
|
|
1750
|
+
```
|
|
1751
|
+
|
|
1752
|
+
### Azure Deployment
|
|
1753
|
+
|
|
1754
|
+
```bash
|
|
1755
|
+
# Deploy to Azure Container Instances
|
|
1756
|
+
az container create \
|
|
1757
|
+
--resource-group claude-flow-rg \
|
|
1758
|
+
--name claude-flow \
|
|
1759
|
+
--image claudeflow/claude-flow:latest \
|
|
1760
|
+
--dns-name-label claude-flow \
|
|
1761
|
+
--ports 3000 \
|
|
1762
|
+
--environment-variables CLAUDE_API_KEY=$CLAUDE_API_KEY
|
|
1763
|
+
|
|
1764
|
+
# Deploy to Azure App Service
|
|
1765
|
+
az webapp create \
|
|
1766
|
+
--resource-group claude-flow-rg \
|
|
1767
|
+
--plan claude-flow-plan \
|
|
1768
|
+
--name claude-flow \
|
|
1769
|
+
--deployment-container-image-name claudeflow/claude-flow:latest
|
|
1770
|
+
```
|
|
1771
|
+
|
|
1772
|
+
### Heroku Deployment
|
|
1773
|
+
|
|
1774
|
+
```bash
|
|
1775
|
+
# Create Heroku app
|
|
1776
|
+
heroku create claude-flow
|
|
1777
|
+
|
|
1778
|
+
# Set environment variables
|
|
1779
|
+
heroku config:set CLAUDE_API_KEY=$CLAUDE_API_KEY
|
|
1780
|
+
heroku config:set NODE_ENV=production
|
|
1781
|
+
|
|
1782
|
+
# Deploy
|
|
1783
|
+
git push heroku main
|
|
1784
|
+
|
|
1785
|
+
# Scale dynos
|
|
1786
|
+
heroku ps:scale web=3
|
|
1787
|
+
|
|
1788
|
+
# View logs
|
|
1789
|
+
heroku logs --tail
|
|
1790
|
+
```
|
|
1791
|
+
|
|
1792
|
+
---
|
|
1793
|
+
|
|
1794
|
+
## Production Setup
|
|
1795
|
+
|
|
1796
|
+
### SSL/TLS Configuration
|
|
1797
|
+
|
|
1798
|
+
```nginx
|
|
1799
|
+
# nginx.conf
|
|
1800
|
+
server {
|
|
1801
|
+
listen 80;
|
|
1802
|
+
server_name claude-flow.example.com;
|
|
1803
|
+
return 301 https://$server_name$request_uri;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
server {
|
|
1807
|
+
listen 443 ssl http2;
|
|
1808
|
+
server_name claude-flow.example.com;
|
|
1809
|
+
|
|
1810
|
+
ssl_certificate /etc/nginx/ssl/cert.pem;
|
|
1811
|
+
ssl_certificate_key /etc/nginx/ssl/key.pem;
|
|
1812
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
1813
|
+
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
1814
|
+
|
|
1815
|
+
location / {
|
|
1816
|
+
proxy_pass http://claude-flow:3000;
|
|
1817
|
+
proxy_http_version 1.1;
|
|
1818
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
1819
|
+
proxy_set_header Connection 'upgrade';
|
|
1820
|
+
proxy_set_header Host $host;
|
|
1821
|
+
proxy_cache_bypass $http_upgrade;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
```
|
|
1825
|
+
|
|
1826
|
+
### Database Setup
|
|
1827
|
+
|
|
1828
|
+
#### PostgreSQL
|
|
1829
|
+
|
|
1830
|
+
```sql
|
|
1831
|
+
-- Create database
|
|
1832
|
+
CREATE DATABASE claude_flow;
|
|
1833
|
+
|
|
1834
|
+
-- Create user
|
|
1835
|
+
CREATE USER claude_flow WITH ENCRYPTED PASSWORD 'secure_password';
|
|
1836
|
+
|
|
1837
|
+
-- Grant privileges
|
|
1838
|
+
GRANT ALL PRIVILEGES ON DATABASE claude_flow TO claude_flow;
|
|
1839
|
+
|
|
1840
|
+
-- Create tables
|
|
1841
|
+
\c claude_flow;
|
|
1842
|
+
|
|
1843
|
+
CREATE TABLE agents (
|
|
1844
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
1845
|
+
name VARCHAR(255) NOT NULL,
|
|
1846
|
+
type VARCHAR(50) NOT NULL,
|
|
1847
|
+
status VARCHAR(50) NOT NULL,
|
|
1848
|
+
config JSONB,
|
|
1849
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
1850
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
1851
|
+
);
|
|
1852
|
+
|
|
1853
|
+
CREATE TABLE tasks (
|
|
1854
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
1855
|
+
type VARCHAR(50) NOT NULL,
|
|
1856
|
+
description TEXT,
|
|
1857
|
+
status VARCHAR(50) NOT NULL,
|
|
1858
|
+
priority INTEGER DEFAULT 0,
|
|
1859
|
+
assigned_agent UUID REFERENCES agents(id),
|
|
1860
|
+
result JSONB,
|
|
1861
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
1862
|
+
completed_at TIMESTAMP
|
|
1863
|
+
);
|
|
1864
|
+
|
|
1865
|
+
-- Create indexes
|
|
1866
|
+
CREATE INDEX idx_agents_type ON agents(type);
|
|
1867
|
+
CREATE INDEX idx_agents_status ON agents(status);
|
|
1868
|
+
CREATE INDEX idx_tasks_status ON tasks(status);
|
|
1869
|
+
CREATE INDEX idx_tasks_assigned ON tasks(assigned_agent);
|
|
1870
|
+
```
|
|
1871
|
+
|
|
1872
|
+
### Backup Strategy
|
|
1873
|
+
|
|
1874
|
+
```bash
|
|
1875
|
+
#!/bin/bash
|
|
1876
|
+
# backup.sh
|
|
1877
|
+
|
|
1878
|
+
# Configuration
|
|
1879
|
+
BACKUP_DIR="/backups"
|
|
1880
|
+
DATE=$(date +%Y%m%d_%H%M%S)
|
|
1881
|
+
DB_NAME="claude_flow"
|
|
1882
|
+
|
|
1883
|
+
# Create backup directory
|
|
1884
|
+
mkdir -p $BACKUP_DIR
|
|
1885
|
+
|
|
1886
|
+
# Backup SQLite database
|
|
1887
|
+
sqlite3 .swarm/memory.db ".backup '$BACKUP_DIR/memory_$DATE.db'"
|
|
1888
|
+
|
|
1889
|
+
# Backup PostgreSQL (if used)
|
|
1890
|
+
pg_dump $DB_NAME > $BACKUP_DIR/postgres_$DATE.sql
|
|
1891
|
+
|
|
1892
|
+
# Backup configuration files
|
|
1893
|
+
tar -czf $BACKUP_DIR/config_$DATE.tar.gz .claude-flow/
|
|
1894
|
+
|
|
1895
|
+
# Backup logs
|
|
1896
|
+
tar -czf $BACKUP_DIR/logs_$DATE.tar.gz logs/
|
|
1897
|
+
|
|
1898
|
+
# Upload to S3
|
|
1899
|
+
aws s3 cp $BACKUP_DIR/ s3://claude-flow-backups/ --recursive
|
|
1900
|
+
|
|
1901
|
+
# Clean old backups (keep last 30 days)
|
|
1902
|
+
find $BACKUP_DIR -type f -mtime +30 -delete
|
|
1903
|
+
|
|
1904
|
+
echo "Backup completed: $DATE"
|
|
1905
|
+
```
|
|
1906
|
+
|
|
1907
|
+
### Monitoring Script
|
|
1908
|
+
|
|
1909
|
+
```bash
|
|
1910
|
+
#!/bin/bash
|
|
1911
|
+
# monitor.sh
|
|
1912
|
+
|
|
1913
|
+
# Check service health
|
|
1914
|
+
health_check() {
|
|
1915
|
+
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/health)
|
|
1916
|
+
if [ $response -eq 200 ]; then
|
|
1917
|
+
echo "✅ Service is healthy"
|
|
1918
|
+
else
|
|
1919
|
+
echo "❌ Service is unhealthy (HTTP $response)"
|
|
1920
|
+
# Send alert
|
|
1921
|
+
send_alert "Claude Flow service is down"
|
|
1922
|
+
fi
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
# Check memory usage
|
|
1926
|
+
check_memory() {
|
|
1927
|
+
memory=$(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2}')
|
|
1928
|
+
echo "📊 Memory usage: $memory"
|
|
1929
|
+
|
|
1930
|
+
if [ ${memory%.*} -gt 90 ]; then
|
|
1931
|
+
send_alert "High memory usage: $memory"
|
|
1932
|
+
fi
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
# Check disk usage
|
|
1936
|
+
check_disk() {
|
|
1937
|
+
disk=$(df -h / | awk 'NR==2{print $5}')
|
|
1938
|
+
echo "💾 Disk usage: $disk"
|
|
1939
|
+
|
|
1940
|
+
if [ ${disk%?} -gt 90 ]; then
|
|
1941
|
+
send_alert "High disk usage: $disk"
|
|
1942
|
+
fi
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
# Send alert function
|
|
1946
|
+
send_alert() {
|
|
1947
|
+
message=$1
|
|
1948
|
+
# Send to Slack
|
|
1949
|
+
curl -X POST -H 'Content-type: application/json' \
|
|
1950
|
+
--data "{\"text\":\"Alert: $message\"}" \
|
|
1951
|
+
$SLACK_WEBHOOK_URL
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
# Run checks
|
|
1955
|
+
while true; do
|
|
1956
|
+
clear
|
|
1957
|
+
echo "Claude Flow Monitoring - $(date)"
|
|
1958
|
+
echo "================================"
|
|
1959
|
+
health_check
|
|
1960
|
+
check_memory
|
|
1961
|
+
check_disk
|
|
1962
|
+
sleep 60
|
|
1963
|
+
done
|
|
1964
|
+
```
|
|
1965
|
+
|
|
1966
|
+
---
|
|
1967
|
+
|
|
1968
|
+
## Monitoring & Maintenance
|
|
1969
|
+
|
|
1970
|
+
### Health Checks
|
|
1971
|
+
|
|
1972
|
+
```javascript
|
|
1973
|
+
// health-check.js
|
|
1974
|
+
const healthCheck = {
|
|
1975
|
+
service: async () => {
|
|
1976
|
+
try {
|
|
1977
|
+
const response = await fetch('http://localhost:3000/health');
|
|
1978
|
+
return response.ok;
|
|
1979
|
+
} catch (error) {
|
|
1980
|
+
return false;
|
|
1981
|
+
}
|
|
1982
|
+
},
|
|
1983
|
+
|
|
1984
|
+
database: async () => {
|
|
1985
|
+
try {
|
|
1986
|
+
const db = new Database('.swarm/memory.db');
|
|
1987
|
+
const result = db.prepare('SELECT 1').get();
|
|
1988
|
+
return result !== undefined;
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
return false;
|
|
1991
|
+
}
|
|
1992
|
+
},
|
|
1993
|
+
|
|
1994
|
+
memory: () => {
|
|
1995
|
+
const used = process.memoryUsage();
|
|
1996
|
+
const limit = 2 * 1024 * 1024 * 1024; // 2GB
|
|
1997
|
+
return used.heapUsed < limit;
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
|
|
2001
|
+
// Run health checks
|
|
2002
|
+
setInterval(async () => {
|
|
2003
|
+
const results = {
|
|
2004
|
+
service: await healthCheck.service(),
|
|
2005
|
+
database: await healthCheck.database(),
|
|
2006
|
+
memory: healthCheck.memory()
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
console.log('Health Check Results:', results);
|
|
2010
|
+
|
|
2011
|
+
if (!Object.values(results).every(v => v)) {
|
|
2012
|
+
console.error('Health check failed!');
|
|
2013
|
+
// Send alert
|
|
2014
|
+
}
|
|
2015
|
+
}, 60000); // Every minute
|
|
2016
|
+
```
|
|
2017
|
+
|
|
2018
|
+
### Log Rotation
|
|
2019
|
+
|
|
2020
|
+
```bash
|
|
2021
|
+
# /etc/logrotate.d/claude-flow
|
|
2022
|
+
/var/log/claude-flow/*.log {
|
|
2023
|
+
daily
|
|
2024
|
+
rotate 14
|
|
2025
|
+
compress
|
|
2026
|
+
delaycompress
|
|
2027
|
+
notifempty
|
|
2028
|
+
create 0640 node node
|
|
2029
|
+
sharedscripts
|
|
2030
|
+
postrotate
|
|
2031
|
+
/usr/bin/killall -SIGUSR1 node
|
|
2032
|
+
endscript
|
|
2033
|
+
}
|
|
2034
|
+
```
|
|
2035
|
+
|
|
2036
|
+
### Performance Tuning
|
|
2037
|
+
|
|
2038
|
+
```bash
|
|
2039
|
+
# System limits configuration
|
|
2040
|
+
# /etc/security/limits.conf
|
|
2041
|
+
node soft nofile 65536
|
|
2042
|
+
node hard nofile 65536
|
|
2043
|
+
node soft nproc 32768
|
|
2044
|
+
node hard nproc 32768
|
|
2045
|
+
|
|
2046
|
+
# Sysctl optimization
|
|
2047
|
+
# /etc/sysctl.conf
|
|
2048
|
+
net.core.somaxconn = 65535
|
|
2049
|
+
net.ipv4.tcp_max_syn_backlog = 65535
|
|
2050
|
+
net.ipv4.tcp_tw_reuse = 1
|
|
2051
|
+
net.ipv4.tcp_fin_timeout = 30
|
|
2052
|
+
```
|
|
2053
|
+
|
|
2054
|
+
---
|
|
2055
|
+
|
|
2056
|
+
## Troubleshooting
|
|
2057
|
+
|
|
2058
|
+
### Production Issues
|
|
2059
|
+
|
|
2060
|
+
#### Issue: Pod Crashes with OOMKilled
|
|
2061
|
+
|
|
2062
|
+
```bash
|
|
2063
|
+
# Check memory usage
|
|
2064
|
+
kubectl top pods -n claude-flow
|
|
2065
|
+
|
|
2066
|
+
# Increase memory limits
|
|
2067
|
+
kubectl patch deployment claude-flow -n claude-flow -p='{"spec":{"template":{"spec":{"containers":[{"name":"claude-flow","resources":{"limits":{"memory":"8Gi"}}}]}}}}'
|
|
2068
|
+
|
|
2069
|
+
# Enable memory profiling
|
|
2070
|
+
kubectl set env deployment/claude-flow NODE_OPTIONS="--max-old-space-size=6144" -n claude-flow
|
|
2071
|
+
```
|
|
2072
|
+
|
|
2073
|
+
#### Issue: High Response Times
|
|
2074
|
+
|
|
2075
|
+
```bash
|
|
2076
|
+
# Check pod resource usage
|
|
2077
|
+
kubectl describe pod -l app=claude-flow -n claude-flow
|
|
2078
|
+
|
|
2079
|
+
# Scale up replicas
|
|
2080
|
+
kubectl scale deployment claude-flow --replicas=5 -n claude-flow
|
|
2081
|
+
|
|
2082
|
+
# Check database connections
|
|
2083
|
+
kubectl exec deployment/claude-flow -n claude-flow -- psql $DATABASE_URL -c "SELECT count(*) FROM pg_stat_activity;"
|
|
2084
|
+
|
|
2085
|
+
# Optimize database queries
|
|
2086
|
+
kubectl exec deployment/claude-flow -n claude-flow -- npx claude-flow@alpha db optimize
|
|
2087
|
+
```
|
|
2088
|
+
|
|
2089
|
+
#### Issue: Database Connection Pool Exhaustion
|
|
2090
|
+
|
|
2091
|
+
```bash
|
|
2092
|
+
# Check current connections
|
|
2093
|
+
psql $DATABASE_URL -c "
|
|
2094
|
+
SELECT
|
|
2095
|
+
state,
|
|
2096
|
+
count(*) as connections
|
|
2097
|
+
FROM pg_stat_activity
|
|
2098
|
+
GROUP BY state;"
|
|
2099
|
+
|
|
2100
|
+
# Increase connection limits
|
|
2101
|
+
kubectl patch configmap claude-flow-config -n claude-flow -p='{"data":{"config.json":"{\"database\":{\"pool\":{\"max\":50,\"min\":10}}}"}}'
|
|
2102
|
+
|
|
2103
|
+
# Restart deployment
|
|
2104
|
+
kubectl rollout restart deployment/claude-flow -n claude-flow
|
|
2105
|
+
```
|
|
2106
|
+
|
|
2107
|
+
#### Issue: Load Balancer Health Check Failures
|
|
2108
|
+
|
|
2109
|
+
```bash
|
|
2110
|
+
# Check health endpoint
|
|
2111
|
+
kubectl exec deployment/claude-flow -n claude-flow -- curl -f http://localhost:3000/health
|
|
2112
|
+
|
|
2113
|
+
# View detailed health status
|
|
2114
|
+
kubectl exec deployment/claude-flow -n claude-flow -- npx claude-flow@alpha diagnostics --health
|
|
2115
|
+
|
|
2116
|
+
# Check ingress configuration
|
|
2117
|
+
kubectl describe ingress claude-flow-ingress -n claude-flow
|
|
2118
|
+
|
|
2119
|
+
# Test from outside cluster
|
|
2120
|
+
curl -H "Host: api.claude-flow.com" http://$(kubectl get svc ingress-nginx-controller -n ingress-nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')/health
|
|
2121
|
+
```
|
|
2122
|
+
|
|
2123
|
+
#### Issue: SSL Certificate Errors
|
|
2124
|
+
|
|
2125
|
+
```bash
|
|
2126
|
+
# Check certificate status
|
|
2127
|
+
kubectl get certificate claude-flow-tls -n claude-flow
|
|
2128
|
+
|
|
2129
|
+
# Describe certificate for details
|
|
2130
|
+
kubectl describe certificate claude-flow-tls -n claude-flow
|
|
2131
|
+
|
|
2132
|
+
# Check cert-manager logs
|
|
2133
|
+
kubectl logs deployment/cert-manager -n cert-manager
|
|
2134
|
+
|
|
2135
|
+
# Force certificate renewal
|
|
2136
|
+
kubectl delete certificate claude-flow-tls -n claude-flow
|
|
2137
|
+
kubectl apply -f k8s/cert-issuer.yaml
|
|
2138
|
+
```
|
|
2139
|
+
|
|
2140
|
+
#### Issue: High CPU Usage
|
|
2141
|
+
|
|
2142
|
+
```bash
|
|
2143
|
+
# Check CPU metrics
|
|
2144
|
+
kubectl top pods -n claude-flow
|
|
2145
|
+
|
|
2146
|
+
# Profile application
|
|
2147
|
+
kubectl exec deployment/claude-flow -n claude-flow -- node --prof /app/dist/index.js &
|
|
2148
|
+
# Let it run for a few minutes, then:
|
|
2149
|
+
kubectl exec deployment/claude-flow -n claude-flow -- node --prof-process isolate-*.log > profile.txt
|
|
2150
|
+
|
|
2151
|
+
# Scale horizontally
|
|
2152
|
+
kubectl patch hpa claude-flow-hpa -n claude-flow -p='{"spec":{"minReplicas":5,"maxReplicas":30}}'
|
|
2153
|
+
```
|
|
2154
|
+
|
|
2155
|
+
### Debug Mode & Diagnostics
|
|
2156
|
+
|
|
2157
|
+
```bash
|
|
2158
|
+
# Enable production debugging (use cautiously)
|
|
2159
|
+
kubectl set env deployment/claude-flow -n claude-flow \
|
|
2160
|
+
CLAUDE_FLOW_DEBUG=true \
|
|
2161
|
+
CLAUDE_FLOW_LOG_LEVEL=debug
|
|
2162
|
+
|
|
2163
|
+
# Get comprehensive diagnostics
|
|
2164
|
+
kubectl exec deployment/claude-flow -n claude-flow -- npx claude-flow@alpha diagnostics --full > diagnostic-report.txt
|
|
2165
|
+
|
|
2166
|
+
# Monitor real-time logs
|
|
2167
|
+
kubectl logs -f deployment/claude-flow -n claude-flow --tail=100
|
|
2168
|
+
|
|
2169
|
+
# Export cluster information
|
|
2170
|
+
kubectl cluster-info dump > cluster-dump.txt
|
|
2171
|
+
|
|
2172
|
+
# Check resource quotas
|
|
2173
|
+
kubectl describe quota -n claude-flow
|
|
2174
|
+
|
|
2175
|
+
# View events
|
|
2176
|
+
kubectl get events -n claude-flow --sort-by='.metadata.creationTimestamp'
|
|
2177
|
+
```
|
|
2178
|
+
|
|
2179
|
+
### Emergency Procedures
|
|
2180
|
+
|
|
2181
|
+
#### Emergency Shutdown
|
|
2182
|
+
|
|
2183
|
+
```bash
|
|
2184
|
+
#!/bin/bash
|
|
2185
|
+
# emergency-shutdown.sh
|
|
2186
|
+
|
|
2187
|
+
echo "🚨 EMERGENCY: Shutting down Claude Flow..."
|
|
2188
|
+
|
|
2189
|
+
# Scale down to zero
|
|
2190
|
+
kubectl scale deployment claude-flow --replicas=0 -n claude-flow
|
|
2191
|
+
|
|
2192
|
+
# Stop autoscaling
|
|
2193
|
+
kubectl patch hpa claude-flow-hpa -n claude-flow -p='{"spec":{"minReplicas":0,"maxReplicas":0}}'
|
|
2194
|
+
|
|
2195
|
+
# Cordon nodes (if necessary)
|
|
2196
|
+
# kubectl cordon <node-name>
|
|
2197
|
+
|
|
2198
|
+
# Send alert
|
|
2199
|
+
curl -X POST -H 'Content-type: application/json' \
|
|
2200
|
+
--data '{"text":"🚨 EMERGENCY: Claude Flow has been shut down!"}' \
|
|
2201
|
+
"$SLACK_WEBHOOK_URL"
|
|
2202
|
+
|
|
2203
|
+
echo "✅ Emergency shutdown complete"
|
|
2204
|
+
```
|
|
2205
|
+
|
|
2206
|
+
#### Circuit Breaker Response
|
|
2207
|
+
|
|
2208
|
+
```bash
|
|
2209
|
+
# Implement circuit breaker for external APIs
|
|
2210
|
+
kubectl patch configmap claude-flow-config -n claude-flow -p='{
|
|
2211
|
+
"data": {
|
|
2212
|
+
"config.json": "{\"circuitBreaker\":{\"enabled\":true,\"threshold\":10,\"timeout\":60000}}"
|
|
2213
|
+
}
|
|
2214
|
+
}'
|
|
2215
|
+
|
|
2216
|
+
# Restart to apply changes
|
|
2217
|
+
kubectl rollout restart deployment/claude-flow -n claude-flow
|
|
2218
|
+
```
|
|
2219
|
+
|
|
2220
|
+
### Performance Debugging
|
|
2221
|
+
|
|
2222
|
+
```bash
|
|
2223
|
+
# Memory leak detection
|
|
2224
|
+
kubectl exec deployment/claude-flow -n claude-flow -- node --trace-gc --expose-gc /app/dist/index.js
|
|
2225
|
+
|
|
2226
|
+
# CPU profiling in production
|
|
2227
|
+
kubectl exec deployment/claude-flow -n claude-flow -- node --prof-process /tmp/isolate-*.log > cpu-profile.txt
|
|
2228
|
+
|
|
2229
|
+
# Network debugging
|
|
2230
|
+
kubectl exec deployment/claude-flow -n claude-flow -- netstat -tupln
|
|
2231
|
+
kubectl exec deployment/claude-flow -n claude-flow -- ss -tulpn
|
|
2232
|
+
|
|
2233
|
+
# Database query analysis
|
|
2234
|
+
kubectl exec deployment/claude-flow -n claude-flow -- psql $DATABASE_URL -c "
|
|
2235
|
+
SELECT query, calls, total_time, mean_time
|
|
2236
|
+
FROM pg_stat_statements
|
|
2237
|
+
ORDER BY total_time DESC
|
|
2238
|
+
LIMIT 10;"
|
|
2239
|
+
```
|
|
2240
|
+
|
|
2241
|
+
---
|
|
2242
|
+
|
|
2243
|
+
## Support & Resources
|
|
2244
|
+
|
|
2245
|
+
### Production Support Runbook
|
|
2246
|
+
|
|
2247
|
+
```bash
|
|
2248
|
+
#!/bin/bash
|
|
2249
|
+
# support-runbook.sh - Quick diagnostic commands
|
|
2250
|
+
|
|
2251
|
+
echo "🔍 Claude Flow Production Diagnostics"
|
|
2252
|
+
echo "======================================"
|
|
2253
|
+
|
|
2254
|
+
echo "📊 Cluster Status:"
|
|
2255
|
+
kubectl get nodes -o wide
|
|
2256
|
+
kubectl get pods -n claude-flow
|
|
2257
|
+
kubectl top pods -n claude-flow
|
|
2258
|
+
|
|
2259
|
+
echo "📈 Application Health:"
|
|
2260
|
+
curl -s https://api.claude-flow.com/health | jq '.'
|
|
2261
|
+
|
|
2262
|
+
echo "🐘 Database Status:"
|
|
2263
|
+
psql $DATABASE_URL -c "SELECT version();" -t
|
|
2264
|
+
psql $DATABASE_URL -c "SELECT count(*) as active_connections FROM pg_stat_activity WHERE state = 'active';" -t
|
|
2265
|
+
|
|
2266
|
+
echo "📦 Redis Status:"
|
|
2267
|
+
redis-cli -u $REDIS_URL info memory | grep used_memory_human
|
|
2268
|
+
redis-cli -u $REDIS_URL ping
|
|
2269
|
+
|
|
2270
|
+
echo "🔧 Recent Logs:"
|
|
2271
|
+
kubectl logs deployment/claude-flow -n claude-flow --tail=50 --timestamps
|
|
2272
|
+
|
|
2273
|
+
echo "⚠️ Recent Alerts:"
|
|
2274
|
+
curl -s http://alertmanager:9093/api/v1/alerts | jq '.data[] | select(.state=="firing") | .labels.alertname'
|
|
2275
|
+
|
|
2276
|
+
echo "📋 Resource Usage:"
|
|
2277
|
+
kubectl describe nodes | grep -A 5 "Allocated resources"
|
|
2278
|
+
```
|
|
2279
|
+
|
|
2280
|
+
### Monitoring Dashboards
|
|
2281
|
+
|
|
2282
|
+
- **Production Dashboard**: https://grafana.claude-flow.com/d/claude-flow-prod
|
|
2283
|
+
- **Infrastructure Dashboard**: https://grafana.claude-flow.com/d/infrastructure
|
|
2284
|
+
- **Application Metrics**: https://grafana.claude-flow.com/d/app-metrics
|
|
2285
|
+
- **Database Performance**: https://grafana.claude-flow.com/d/database
|
|
2286
|
+
- **Alert Manager**: https://alertmanager.claude-flow.com
|
|
2287
|
+
|
|
2288
|
+
### Emergency Contacts
|
|
2289
|
+
|
|
2290
|
+
```yaml
|
|
2291
|
+
# On-Call Escalation
|
|
2292
|
+
Level 1: DevOps Team
|
|
2293
|
+
- Slack: #devops-alerts
|
|
2294
|
+
- PagerDuty: claude-flow-devops
|
|
2295
|
+
|
|
2296
|
+
Level 2: Engineering Team
|
|
2297
|
+
- Slack: #engineering-oncall
|
|
2298
|
+
- Email: engineering-oncall@claude-flow.com
|
|
2299
|
+
|
|
2300
|
+
Level 3: Leadership
|
|
2301
|
+
- Slack: #leadership-alerts
|
|
2302
|
+
- Phone: Emergency hotline
|
|
2303
|
+
```
|
|
2304
|
+
|
|
2305
|
+
### Documentation Links
|
|
2306
|
+
|
|
2307
|
+
- **Architecture Guide**: [ARCHITECTURE.md](./ARCHITECTURE.md)
|
|
2308
|
+
- **API Documentation**: [API_DOCUMENTATION.md](./API_DOCUMENTATION.md)
|
|
2309
|
+
- **Development Workflow**: [DEVELOPMENT_WORKFLOW.md](./DEVELOPMENT_WORKFLOW.md)
|
|
2310
|
+
- **Main Documentation**: [INDEX.md](./INDEX.md)
|
|
2311
|
+
- **Repository**: https://github.com/ruvnet/claude-flow
|
|
2312
|
+
- **Issues**: https://github.com/ruvnet/claude-flow/issues
|
|
2313
|
+
|
|
2314
|
+
### Quick Commands Reference
|
|
2315
|
+
|
|
2316
|
+
```bash
|
|
2317
|
+
# Essential production commands
|
|
2318
|
+
npx claude-flow@alpha --version # Check version
|
|
2319
|
+
npx claude-flow@alpha diagnostics --full # Full system check
|
|
2320
|
+
npx claude-flow@alpha swarm "test" --agents 3 # Quick functionality test
|
|
2321
|
+
npx claude-flow@alpha config validate # Validate configuration
|
|
2322
|
+
|
|
2323
|
+
# Kubernetes shortcuts
|
|
2324
|
+
alias kgp="kubectl get pods -n claude-flow"
|
|
2325
|
+
alias kgs="kubectl get svc -n claude-flow"
|
|
2326
|
+
alias kgi="kubectl get ingress -n claude-flow"
|
|
2327
|
+
alias kl="kubectl logs -f deployment/claude-flow -n claude-flow"
|
|
2328
|
+
alias kdp="kubectl describe pod -l app=claude-flow -n claude-flow"
|
|
2329
|
+
|
|
2330
|
+
# Emergency commands
|
|
2331
|
+
kubectl scale deployment claude-flow --replicas=0 -n claude-flow # Emergency stop
|
|
2332
|
+
kubectl rollout undo deployment/claude-flow -n claude-flow # Rollback
|
|
2333
|
+
kubectl get events --sort-by='.metadata.creationTimestamp' -n claude-flow # Recent events
|
|
2334
|
+
```
|
|
2335
|
+
|
|
2336
|
+
---
|
|
2337
|
+
|
|
2338
|
+
<div align="center">
|
|
2339
|
+
|
|
2340
|
+
## 🚀 **Claude-Flow Production Deployment Guide v2.0.0**
|
|
2341
|
+
|
|
2342
|
+
**Ready for Enterprise Scale • Production Tested • Fully Documented**
|
|
2343
|
+
|
|
2344
|
+
[📚 Documentation Home](./INDEX.md) | [🏗️ Architecture](./ARCHITECTURE.md) | [📖 API Reference](./API_DOCUMENTATION.md) | [⚡ Development](./DEVELOPMENT_WORKFLOW.md)
|
|
2345
|
+
|
|
2346
|
+
[🐙 GitHub Repository](https://github.com/ruvnet/claude-flow) | [🐛 Report Issues](https://github.com/ruvnet/claude-flow/issues) | [💬 Community Support](https://discord.gg/claude-flow)
|
|
2347
|
+
|
|
2348
|
+
</div>
|