|
| 1 | +# Demo Workflow - Build Up & Tear Down |
| 2 | + |
| 3 | +Perfect for demos that get built up and torn down frequently! |
| 4 | + |
| 5 | +## 🚀 Deploy (One Command) |
| 6 | + |
| 7 | +```bash |
| 8 | +cd /Users/phagen/GIT/opentelemetry-demo-Splunk |
| 9 | +kubectl apply -f kubernetes/opentelemetry-demo.yaml |
| 10 | +``` |
| 11 | + |
| 12 | +Wait ~3 minutes for everything to initialize. |
| 13 | + |
| 14 | +## 🧹 Tear Down (One Command) |
| 15 | + |
| 16 | +```bash |
| 17 | +./cleanup.sh |
| 18 | +``` |
| 19 | + |
| 20 | +This script: |
| 21 | +- ✅ Deletes all deployments, services, statefulsets |
| 22 | +- ✅ Cleans up all PVCs (prevents corrupted data) |
| 23 | +- ✅ Ensures fresh start on next deploy |
| 24 | + |
| 25 | +## What's Configured for Easy Demos |
| 26 | + |
| 27 | +### SQL Server StatefulSet |
| 28 | +**Added automatic PVC cleanup:** |
| 29 | +```yaml |
| 30 | +persistentVolumeClaimRetentionPolicy: |
| 31 | + whenDeleted: Delete # Auto-delete PVC when StatefulSet deleted |
| 32 | + whenScaled: Delete # Auto-delete PVC when scaled down |
| 33 | +``` |
| 34 | +
|
| 35 | +This means: |
| 36 | +- `kubectl delete` will automatically remove the PVC |
| 37 | +- No corrupted SQL Server data on next deploy |
| 38 | +- Clean slate every time |
| 39 | + |
| 40 | +### Fraud Detection Service |
| 41 | +**Auto-initializes everything:** |
| 42 | +- Creates `FraudDetection` database if missing |
| 43 | +- Creates `OrderLogs` table if missing |
| 44 | +- Logs every Kafka order message |
| 45 | + |
| 46 | +## Complete Demo Cycle |
| 47 | + |
| 48 | +### 1. Deploy |
| 49 | +```bash |
| 50 | +kubectl apply -f kubernetes/opentelemetry-demo.yaml |
| 51 | +``` |
| 52 | + |
| 53 | +### 2. Verify |
| 54 | +```bash |
| 55 | +# Check pods are running |
| 56 | +kubectl get pods -n otel-demo |
| 57 | +kubectl get pods -n sql |
| 58 | +
|
| 59 | +# Watch fraud-detection logs |
| 60 | +kubectl logs -f -n otel-demo -l app.kubernetes.io/component=fraud-detection |
| 61 | +``` |
| 62 | + |
| 63 | +### 3. Use the Demo |
| 64 | +```bash |
| 65 | +# Access frontend |
| 66 | +kubectl port-forward -n otel-demo svc/frontend 8080:8080 |
| 67 | +# Browse to http://localhost:8080 and place orders |
| 68 | +
|
| 69 | +# Access SQL Server |
| 70 | +kubectl port-forward -n sql svc/sql-express 1433:1433 |
| 71 | +# Connect to localhost:1433 with sa/ChangeMe_SuperStrong123! |
| 72 | +``` |
| 73 | + |
| 74 | +### 4. Query Data |
| 75 | +```bash |
| 76 | +kubectl exec -it sql-express-0 -n sql -- /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'ChangeMe_SuperStrong123!' -Q "SELECT COUNT(*) FROM FraudDetection.dbo.OrderLogs" |
| 77 | +``` |
| 78 | + |
| 79 | +### 5. Tear Down |
| 80 | +```bash |
| 81 | +./cleanup.sh |
| 82 | +``` |
| 83 | + |
| 84 | +## Troubleshooting |
| 85 | + |
| 86 | +### SQL Server in CrashLoopBackOff |
| 87 | + |
| 88 | +**Cause:** Corrupted PVC from previous deployment |
| 89 | + |
| 90 | +**Fix:** |
| 91 | +```bash |
| 92 | +kubectl delete statefulset sql-express -n sql |
| 93 | +kubectl delete pvc data-sql-express-0 -n sql |
| 94 | +kubectl apply -f kubernetes/opentelemetry-demo.yaml |
| 95 | +``` |
| 96 | + |
| 97 | +### Fraud Detection Stuck "waiting for sql-express" |
| 98 | + |
| 99 | +**Cause:** SQL Server not ready |
| 100 | + |
| 101 | +**Fix:** |
| 102 | +```bash |
| 103 | +# Check SQL Server status |
| 104 | +kubectl get pods -n sql |
| 105 | +kubectl logs sql-express-0 -n sql |
| 106 | +
|
| 107 | +# If SQL Server is crashing, clean and redeploy |
| 108 | +./cleanup.sh |
| 109 | +kubectl apply -f kubernetes/opentelemetry-demo.yaml |
| 110 | +``` |
| 111 | + |
| 112 | +## Files Modified for Demo Workflow |
| 113 | + |
| 114 | +### Changed |
| 115 | +- `kubernetes/opentelemetry-demo.yaml` |
| 116 | + - Line 343-345: Added `persistentVolumeClaimRetentionPolicy` to sql-express StatefulSet |
| 117 | + - Line 1372: Updated fraud-detection image to `2.1.3-sql.1` |
| 118 | + - Line 1402-1411: Added SQL Server environment variables |
| 119 | + - Line 1423-1428: Added wait-for-sqlserver init container |
| 120 | + |
| 121 | +### Added |
| 122 | +- `cleanup.sh` - Automated cleanup script |
| 123 | +- `src/fraud-detection/build-fraud-detection.sh` - Build script |
| 124 | +- All fraud-detection code for SQL Server logging |
| 125 | + |
| 126 | +## Quick Reference |
| 127 | + |
| 128 | +| Action | Command | |
| 129 | +|--------|---------| |
| 130 | +| Deploy | `kubectl apply -f kubernetes/opentelemetry-demo.yaml` | |
| 131 | +| Tear Down | `./cleanup.sh` | |
| 132 | +| Watch Logs | `kubectl logs -f -n otel-demo -l app.kubernetes.io/component=fraud-detection` | |
| 133 | +| SQL Status | `kubectl get pods -n sql` | |
| 134 | +| Access Frontend | `kubectl port-forward -n otel-demo svc/frontend 8080:8080` | |
| 135 | +| Access SQL Server | `kubectl port-forward -n sql svc/sql-express 1433:1433` | |
| 136 | +| Query Database | See "Query Data" section above | |
| 137 | + |
| 138 | +## Expected Timeline |
| 139 | + |
| 140 | +- **Deploy:** 3 minutes |
| 141 | +- **Tear Down:** 30 seconds |
| 142 | +- **Redeploy:** 2 minutes (with cleanup) |
| 143 | + |
| 144 | +Perfect for rapid demo cycles! 🎯 |
0 commit comments