-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
670 lines (567 loc) · 31.6 KB
/
Taskfile.yaml
File metadata and controls
670 lines (567 loc) · 31.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
version: '3'
vars:
TOOL_DIR: "{{.USER_WORKING_DIR}}/bin"
# Container image configuration
ACTIVITY_IMAGE_NAME: "ghcr.io/datum-cloud/activity"
ACTIVITY_UI_IMAGE_NAME: "ghcr.io/datum-cloud/activity-ui"
ACTIVITY_IMAGE_TAG: "dev"
TEST_INFRA_CLUSTER_NAME: "test-infra"
# Test infra repository configuration - can be overridden with environment variable
TEST_INFRA_REPO_REF: 'v0.6.0'
# ClickHouse configuration for testing
CLICKHOUSE_DATABASE: "audit"
CLICKHOUSE_USERNAME: "default"
CLICKHOUSE_PASSWORD: ""
includes:
# Must set TASK_X_REMOTE_TASKFILES=1 to use this feature.
#
# See: https://taskfile.dev/experiments/remote-taskfiles
test-infra:
taskfile: https://raw.githubusercontent.com/datum-cloud/test-infra/{{.TEST_INFRA_REPO_REF}}/Taskfile.yml
checksum: a1cf6063def6ee21ba42f8a0818127c92a9a5c313c293387f2294e42480dd3d5
vars:
REPO_REF: "{{.TEST_INFRA_REPO_REF}}"
# Database migrations
migrations:
taskfile: ./migrations/Taskfile.yaml
dir: ./migrations
vars:
CLICKHOUSE_DATABASE: "{{.CLICKHOUSE_DATABASE}}"
CLICKHOUSE_USERNAME: "{{.CLICKHOUSE_USERNAME}}"
CLICKHOUSE_PASSWORD: "{{.CLICKHOUSE_PASSWORD}}"
ROOT_DIR: "{{.USER_WORKING_DIR}}"
observability:
taskfile: ./observability/Taskfile.yaml
dir: ./observability
vars:
ROOT_DIR: "{{.USER_WORKING_DIR}}"
# Performance testing with k6
load:
taskfile: ./test/load/Taskfile.yaml
dir: ./test/load
vars:
ROOT_DIR: "{{.USER_WORKING_DIR}}"
# Documentation (diagrams, etc.)
docs:
taskfile: ./docs/Taskfile.yaml
dir: ./docs
tasks:
default:
desc: List all available tasks
cmds:
- task --list
silent: true
# Build tasks
build:
desc: Build the activity binary
cmds:
- |
set -e
echo "Building activity..."
mkdir -p {{.TOOL_DIR}}
# Get git information for version injection
GIT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
VERSION="v0.0.0-dev+${GIT_COMMIT:0:7}"
GIT_TREE_STATE="clean"
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
GIT_TREE_STATE="dirty"
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || echo "unknown")
echo "Version: ${VERSION}, Commit: ${GIT_COMMIT:0:7}, Tree: ${GIT_TREE_STATE}"
go build \
-ldflags="-X 'go.miloapis.com/activity/internal/version.Version=${VERSION}' \
-X 'go.miloapis.com/activity/internal/version.GitCommit=${GIT_COMMIT}' \
-X 'go.miloapis.com/activity/internal/version.GitTreeState=${GIT_TREE_STATE}' \
-X 'go.miloapis.com/activity/internal/version.BuildDate=${BUILD_DATE}'" \
-o {{.TOOL_DIR}}/activity ./cmd/activity
echo "✅ Binary built: {{.TOOL_DIR}}/activity"
silent: true
# Development tasks
dev:build:
desc: Build the Activity server container image for development
silent: true
cmds:
- |
set -e
echo "Building Activity server container image: {{.ACTIVITY_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}"
# Get git information for version injection
GIT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
VERSION="v0.0.0-dev+${GIT_COMMIT:0:7}"
GIT_TREE_STATE="clean"
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
GIT_TREE_STATE="dirty"
fi
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ' 2>/dev/null || echo "unknown")
echo "Version info: ${VERSION}, commit: ${GIT_COMMIT:0:7}, tree: ${GIT_TREE_STATE}"
# Build using a simple Dockerfile (to be created)
if [ ! -f "Dockerfile" ]; then
echo "⚠️ Warning: Dockerfile not found - skipping container build"
echo "Please create a Dockerfile to enable container builds"
exit 1
fi
docker build \
--build-arg VERSION="${VERSION}" \
--build-arg GIT_COMMIT="${GIT_COMMIT}" \
--build-arg GIT_TREE_STATE="${GIT_TREE_STATE}" \
--build-arg BUILD_DATE="${BUILD_DATE}" \
-t "{{.ACTIVITY_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}" .
echo "Successfully built {{.ACTIVITY_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}"
dev:load:
desc: Load the Activity server container image into the kind cluster
silent: true
cmds:
- |
set -e
echo "Loading image {{.ACTIVITY_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}} into kind cluster '{{.TEST_INFRA_CLUSTER_NAME}}'..."
kind load docker-image "{{.ACTIVITY_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}" --name "{{.TEST_INFRA_CLUSTER_NAME}}"
echo "Successfully loaded image into kind cluster"
dev:build-ui:
desc: Build the Activity UI container image for development
silent: true
cmds:
- |
set -e
echo "Building Activity UI container image: {{.ACTIVITY_UI_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}"
if [ ! -f "ui/Dockerfile" ]; then
echo "⚠️ Warning: ui/Dockerfile not found - skipping UI container build"
exit 1
fi
docker build \
-t "{{.ACTIVITY_UI_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}" \
-f ui/Dockerfile \
ui/
echo "Successfully built {{.ACTIVITY_UI_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}"
dev:load-ui:
desc: Load the Activity UI container image into the kind cluster
silent: true
cmds:
- |
set -e
echo "Loading image {{.ACTIVITY_UI_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}} into kind cluster '{{.TEST_INFRA_CLUSTER_NAME}}'..."
kind load docker-image "{{.ACTIVITY_UI_IMAGE_NAME}}:{{.ACTIVITY_IMAGE_TAG}}" --name "{{.TEST_INFRA_CLUSTER_NAME}}"
echo "Successfully loaded UI image into kind cluster"
# ============================================================
# Lightweight Dev Environment (single-replica, minimal resources)
# ============================================================
dev:setup:
desc: Setup lightweight dev environment (single-replica ClickHouse, minimal resources)
silent: true
cmds:
- task: test-infra:cluster-up
- task: test-infra:install-observability
- task: dev:install-dependencies-minimal
- task: dev:build
- task: dev:load
- task: dev:build-ui
- task: dev:load-ui
- task: dev:deploy
- task: observability:deploy
dev:install-dependencies-minimal:
desc: Install minimal infrastructure dependencies for dev (no RustFS)
silent: true
cmds:
- |
set -e
echo "📦 Installing minimal infrastructure dependencies for dev..."
echo ""
# ============================================================
# Install ClickHouse Operator
# ============================================================
echo "📦 Installing ClickHouse operator via Flux HelmRelease..."
echo "Applying Flux HelmRelease for ClickHouse operator..."
task test-infra:kubectl -- apply -k config/dependencies/clickhouse-operator
echo "Waiting for operator HelmRelease to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/clickhouse-operator -n clickhouse-system --timeout=300s 2>/dev/null || echo "⚠️ HelmRelease not ready yet (may need Flux installed)"
echo "Waiting for operator deployment to be ready..."
task test-infra:kubectl -- wait --for=condition=available deployment/clickhouse-operator -n clickhouse-system --timeout=120s 2>/dev/null || echo "⚠️ Operator deployment not ready yet"
echo "✅ ClickHouse operator installed"
echo ""
# ============================================================
# Install NATS
# ============================================================
echo "📦 Installing NATS for event streaming..."
echo "Applying NATS resources..."
task test-infra:kubectl -- apply -k config/dependencies/nats
echo "Waiting for NATS namespace to be created..."
task test-infra:kubectl -- wait --for=jsonpath='{.status.phase}'=Active namespace/nats-system --timeout=30s 2>/dev/null || echo "⚠️ Namespace not ready yet"
echo "Waiting for NATS HelmRelease to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/nats -n nats-system --timeout=300s 2>/dev/null || echo "⚠️ NATS HelmRelease not ready yet (may need Flux installed)"
echo "Waiting for NATS pods to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l app.kubernetes.io/name=nats -n nats-system --timeout=120s 2>/dev/null || echo "⚠️ NATS pods not ready yet"
echo "✅ NATS installed"
echo ""
# Note: RustFS is NOT installed for dev - we use local disk for storage
# Note: etcd is deployed as part of the dev overlay (not as a dependency)
echo "ℹ️ Skipping RustFS (dev uses local disk for ClickHouse storage)"
echo ""
echo "✅ Minimal infrastructure dependencies installed!"
echo ""
dev:deploy:
desc: Deploy Activity server using dev overlay (lightweight, non-HA)
silent: true
cmds:
- |
set -e
echo "🚀 Deploying Activity server (dev overlay - lightweight)..."
# Check if deployment manifests exist
if [ ! -d "config" ]; then
echo "⚠️ Warning: config directory not found"
exit 1
fi
echo "📋 Deploying Activity server (dev overlay)..."
task test-infra:kubectl -- apply -k config/overlays/dev
echo "⏳ Waiting for etcd to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/etcd -n activity-system --timeout=300s 2>/dev/null || echo "⚠️ etcd HelmRelease not ready yet"
task test-infra:kubectl -- wait --for=condition=ready pod -l app.kubernetes.io/name=etcd -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ etcd pods not ready yet"
echo "⏳ Waiting for NATS streams to be ready..."
task test-infra:kubectl -- wait --for=condition=ready stream/audit-events -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ audit-events stream not ready yet"
task test-infra:kubectl -- wait --for=condition=ready stream/activities -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ activities stream not ready yet"
task test-infra:kubectl -- wait --for=condition=ready stream/events -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ events stream not ready yet (needed for Watch API)"
echo ""
echo "⏳ Waiting for ClickHouse Keeper to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l clickhouse-keeper.altinity.com/chk=activity-keeper -n activity-system --timeout=180s || echo "⚠️ ClickHouse Keeper pods not ready yet"
echo "⏳ Waiting for ClickHouse to be ready..."
task test-infra:kubectl -- wait --for=jsonpath='{.status.status}'=Completed clickhouseinstallation -n activity-system activity-clickhouse --timeout=180s 2>/dev/null || echo "⚠️ ClickHouse Installation not completed"
task test-infra:kubectl -- wait --for=condition=ready pod -l clickhouse.altinity.com/chi=activity-clickhouse -n activity-system --timeout=180s || echo "⚠️ ClickHouse pods not ready yet"
echo "⏳ Waiting for ClickHouse migrations to complete..."
task test-infra:kubectl -- wait --for=condition=complete job/clickhouse-migrate -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ Migration job not complete yet"
echo "⏳ Waiting for Activity server to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l app=activity-apiserver -n activity-system --timeout=120s || echo "⚠️ API server pods not ready yet"
echo "⏳ Waiting for Activity APIService to be available..."
task test-infra:kubectl -- wait --for=condition=Available apiservice/v1alpha1.activity.miloapis.com --timeout=120s || echo "⚠️ APIService not available yet"
echo "⏳ Waiting for Vector aggregator to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l app.kubernetes.io/instance=vector-aggregator -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ Vector aggregator pods not ready yet"
echo ""
echo "📋 Installing example ActivityPolicies for basic Kubernetes resources..."
task test-infra:kubectl -- apply -k examples/basic-kubernetes/
echo ""
echo "✅ Activity server deployed (dev overlay)!"
echo ""
echo "📊 Check status:"
echo " All resources: task test-infra:kubectl -- get all -n activity-system"
echo " API server pods: task test-infra:kubectl -- get pods -l app=activity-apiserver -n activity-system"
echo " ClickHouse pods: task test-infra:kubectl -- get pods -l clickhouse.altinity.com/chi=activity-clickhouse -n activity-system"
echo " ActivityPolicies: task test-infra:kubectl -- get activitypolicies"
echo ""
echo "📋 View logs:"
echo " API server: task test-infra:kubectl -- logs -l app=activity-apiserver -n activity-system -f"
echo " ClickHouse: task test-infra:kubectl -- logs -l clickhouse.altinity.com/chi=activity-clickhouse -n activity-system -f"
echo ""
dev:redeploy:
desc: Quick rebuild and redeploy for dev environment
deps:
- dev:build
- dev:load
- dev:build-ui
- dev:load-ui
cmds:
- |
set -e
echo "Redeploying Activity server and UI (dev)..."
# Restart all activity deployments to pick up new image
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-apiserver || echo "⚠️ Deployment not found, run 'task dev:deploy' first"
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-processor || echo "⚠️ activity-processor deployment not found"
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-controller-manager || echo "⚠️ activity-controller-manager deployment not found"
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-ui || echo "⚠️ activity-ui deployment not found"
# Wait for rollouts to complete
echo "Waiting for rollouts to complete..."
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-apiserver --timeout=120s || true
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-processor --timeout=120s || true
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-controller-manager --timeout=120s || true
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-ui --timeout=120s || true
echo "✅ Redeployment complete!"
echo "Check logs with: task test-infra:kubectl -- logs -l app=activity-apiserver -n activity-system -f"
silent: true
# ============================================================
# Test Environment (full HA setup with RustFS)
# ============================================================
test:setup:
desc: Setup full test environment with HA ClickHouse (3 replicas), S3 storage, and all components
silent: true
cmds:
- task: test-infra:cluster-up
- task: test-infra:install-observability
- task: test:install-dependencies
- task: dev:build
- task: dev:load
- task: dev:build-ui
- task: dev:load-ui
- task: test:deploy
- task: observability:deploy
test:install-dependencies:
desc: Install all infrastructure dependencies for test environment (includes RustFS)
silent: true
cmds:
- |
set -e
echo "📦 Installing infrastructure dependencies..."
echo ""
# ============================================================
# Install ClickHouse Operator
# ============================================================
echo "📦 Installing ClickHouse operator via Flux HelmRelease..."
echo "Applying Flux HelmRelease for ClickHouse operator..."
task test-infra:kubectl -- apply -k config/dependencies/clickhouse-operator
echo "Waiting for operator HelmRelease to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/clickhouse-operator -n clickhouse-system --timeout=300s 2>/dev/null || echo "⚠️ HelmRelease not ready yet (may need Flux installed)"
echo "Waiting for operator deployment to be ready..."
task test-infra:kubectl -- wait --for=condition=available deployment/clickhouse-operator -n clickhouse-system --timeout=120s 2>/dev/null || echo "⚠️ Operator deployment not ready yet"
echo "✅ ClickHouse operator installed"
echo ""
# ============================================================
# Install NATS
# ============================================================
echo "📦 Installing NATS for event streaming..."
echo "Applying NATS resources..."
task test-infra:kubectl -- apply -k config/dependencies/nats
echo "Waiting for NATS namespace to be created..."
task test-infra:kubectl -- wait --for=jsonpath='{.status.phase}'=Active namespace/nats-system --timeout=30s 2>/dev/null || echo "⚠️ Namespace not ready yet"
echo "Waiting for NATS HelmRelease to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/nats -n nats-system --timeout=300s 2>/dev/null || echo "⚠️ NATS HelmRelease not ready yet (may need Flux installed)"
echo "Waiting for NATS pods to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l app.kubernetes.io/name=nats -n nats-system --timeout=120s 2>/dev/null || echo "⚠️ NATS pods not ready yet"
echo "✅ NATS installed"
echo ""
# Note: NACK controller is now installed as part of NATS dependencies kustomization above
# Stream configurations will be deployed as part of test:deploy step
# ============================================================
# Install RustFS for S3-compatible object storage
# ============================================================
echo "📦 Installing RustFS for S3-compatible object storage..."
echo "Applying RustFS resources..."
task test-infra:kubectl -- apply -k config/dependencies/rustfs
echo "Waiting for rustfs-system namespace to be created..."
task test-infra:kubectl -- wait --for=jsonpath='{.status.phase}'=Active namespace/rustfs-system --timeout=30s 2>/dev/null || echo "⚠️ Namespace not ready yet"
echo "Waiting for RustFS HelmRelease to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/rustfs -n rustfs-system --timeout=300s 2>/dev/null || echo "⚠️ RustFS HelmRelease not ready yet (may need Flux installed)"
echo "Waiting for RustFS deployment to be ready..."
task test-infra:kubectl -- wait --for=condition=available deployment/rustfs -n rustfs-system --timeout=180s 2>/dev/null || echo "⚠️ RustFS deployment not ready yet"
echo "✅ RustFS storage installed"
echo ""
# ============================================================
# Summary
# ============================================================
echo "✅ All infrastructure dependencies installed successfully!"
echo ""
echo "📊 Check status:"
echo " ClickHouse operator: task test-infra:kubectl -- get pods -n clickhouse-system"
echo " NATS: task test-infra:kubectl -- get pods -n nats-system"
echo " NACK controller: task test-infra:kubectl -- get pods -n nats-system -l app.kubernetes.io/name=nack"
echo " RustFS: task test-infra:kubectl -- get pods -n rustfs-system"
echo ""
echo "📋 HelmRelease status:"
echo " task test-infra:kubectl -- get helmrelease -n clickhouse-system"
echo " task test-infra:kubectl -- get helmrelease -n nats-system"
echo " task test-infra:kubectl -- get helmrelease -n rustfs-system"
echo ""
echo "Note: JetStream stream configurations and S3 bucket will be deployed with the Activity server."
echo ""
test:deploy:
desc: Deploy Activity server using test-infra overlay (full HA with 3 replicas)
silent: true
cmds:
- |
set -e
echo "🚀 Deploying Activity server (test-infra overlay - full HA)..."
# Check if deployment manifests exist
if [ ! -d "config" ]; then
echo "⚠️ Warning: config directory not found"
exit 1
fi
echo "📋 Deploying Activity server and components (test-infra overlay)..."
task test-infra:kubectl -- apply -k config/overlays/test-infra
echo "⏳ Waiting for etcd to be ready..."
task test-infra:kubectl -- wait --for=condition=ready helmrelease/etcd -n activity-system --timeout=300s 2>/dev/null || echo "⚠️ etcd HelmRelease not ready yet"
task test-infra:kubectl -- wait --for=condition=ready pod -l app.kubernetes.io/name=etcd -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ etcd pods not ready yet"
echo "⏳ Waiting for NATS streams to be ready..."
task test-infra:kubectl -- wait --for=condition=ready stream/audit-events -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ audit-events stream not ready yet"
task test-infra:kubectl -- wait --for=condition=ready stream/activities -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ activities stream not ready yet"
task test-infra:kubectl -- wait --for=condition=ready stream/events -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ events stream not ready yet (needed for Watch API)"
echo ""
echo "⏳ Waiting for RustFS bucket initialization..."
task test-infra:kubectl -- wait --for=condition=complete job/rustfs-bucket-init -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ Bucket initialization not complete yet"
echo "⏳ Waiting for ClickHouse Keeper to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l clickhouse-keeper.altinity.com/chk=activity-keeper -n activity-system --timeout=180s || echo "⚠️ ClickHouse Keeper pods not ready yet"
echo "⏳ Waiting for ClickHouse to be ready..."
task test-infra:kubectl -- wait --for=jsonpath='{.status.status}'=Completed clickhouseinstallation -n activity-system activity-clickhouse --timeout=180s 2>/dev/null || echo "⚠️ ClickHouse Installation not completed"
task test-infra:kubectl -- wait --for=condition=ready pod -l clickhouse.altinity.com/chi=activity-clickhouse -n activity-system --timeout=180s || echo "⚠️ ClickHouse pods not ready yet"
echo "⏳ Waiting for ClickHouse migrations to complete..."
task test-infra:kubectl -- wait --for=condition=complete job/clickhouse-migrate -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ Migration job not complete yet"
echo "⏳ Waiting for Activity server to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l app=activity-apiserver -n activity-system --timeout=120s || echo "⚠️ API server pods not ready yet"
echo "⏳ Waiting for Vector aggregator to be ready..."
task test-infra:kubectl -- wait --for=condition=ready pod -l app.kubernetes.io/instance=vector-aggregator -n activity-system --timeout=120s 2>/dev/null || echo "⚠️ Vector aggregator pods not ready yet"
echo ""
echo "⏳ Waiting for Grafana ClickHouse datasource to be synced..."
sleep 5
task test-infra:kubectl -- wait --for=condition=DatasourceSynchronized grafanadatasource/clickhouse-datasource -n activity-system --timeout=60s 2>/dev/null || echo "⚠️ Datasource not synced yet (may need to restart Grafana pod for plugin to load)"
echo ""
echo "📋 Installing example ActivityPolicies for basic Kubernetes resources..."
task test-infra:kubectl -- apply -k examples/basic-kubernetes/
echo ""
echo "✅ Activity server deployed (test-infra overlay - full HA)!"
echo ""
echo "📊 Check status:"
echo " All resources: task test-infra:kubectl -- get all -n activity-system"
echo " API server pods: task test-infra:kubectl -- get pods -l app=activity-apiserver -n activity-system"
echo " ClickHouse pods: task test-infra:kubectl -- get pods -l clickhouse.altinity.com/chi=activity-clickhouse -n activity-system"
echo " Vector pods: task test-infra:kubectl -- get pods -l app.kubernetes.io/instance=vector-aggregator -n activity-system"
echo " NATS pods: task test-infra:kubectl -- get pods -n nats-system"
echo " NATS streams: task test-infra:kubectl -- get streams -n activity-system"
echo " S3 bucket: task test-infra:kubectl -- get objectbucketclaim -n activity-system"
echo " API service: kubectl get apiservice v1alpha1.activity.miloapis.com"
echo " Grafana datasrc: task test-infra:kubectl -- get grafanadatasource clickhouse-datasource -n activity-system"
echo " ActivityPolicies: task test-infra:kubectl -- get activitypolicies"
echo ""
echo "📋 View logs:"
echo " API server: task test-infra:kubectl -- logs -l app=activity-apiserver -n activity-system -f"
echo " ClickHouse: task test-infra:kubectl -- logs -l clickhouse.altinity.com/chi=activity-clickhouse -n activity-system -f"
echo " Vector: task test-infra:kubectl -- logs -l app.kubernetes.io/instance=vector-aggregator -n activity-system -f"
echo " NATS: task test-infra:kubectl -- logs -l app.kubernetes.io/name=nats -n nats-system -f"
echo ""
echo "📊 Observability:"
echo " Access Grafana: task test-infra:kubectl -- port-forward -n telemetry-system svc/grafana-service 3000:3000"
echo " Grafana URL: http://localhost:3000 (admin / datum123)"
echo " Verify datasource: task test-infra:kubectl -- get grafanadatasource -n activity-system"
echo ""
test:redeploy:
desc: Quick rebuild and redeploy for test environment
deps:
- dev:build
- dev:load
cmds:
- |
set -e
echo "Redeploying Activity server (test)..."
# Restart all activity deployments to pick up new image
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-apiserver || echo "⚠️ Deployment not found, run 'task test:deploy' first"
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-processor || echo "⚠️ activity-processor deployment not found"
task test-infra:kubectl -- rollout restart -n activity-system deployment/activity-controller-manager || echo "⚠️ activity-controller-manager deployment not found"
# Wait for rollouts to complete
echo "Waiting for rollouts to complete..."
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-apiserver --timeout=120s || true
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-processor --timeout=120s || true
task test-infra:kubectl -- rollout status -n activity-system deployment/activity-controller-manager --timeout=120s || true
echo "✅ Redeployment complete!"
echo "Check logs with: task test-infra:kubectl -- logs -l app=activity-apiserver -n activity-system -f"
silent: true
# ============================================================
# Telepresence for remote debugging
# ============================================================
# Telepresence tasks are now provided by test-infra:
# task test-infra:telepresence:install - Install CLI
# task test-infra:telepresence:connect - Connect to cluster
# task test-infra:telepresence:intercept - Intercept service (SERVICE=name NAMESPACE=ns PORT=port)
# task test-infra:telepresence:status - Show status
# task test-infra:telepresence:quit - Disconnect
# ============================================================
# UI Development
# ============================================================
ui:dev:
desc: Run the Activity UI example app locally with hot-reload
dir: ui/example
cmds:
- |
set -e
echo "🚀 Starting Activity UI dev server..."
echo ""
echo "The example app imports directly from ui/src/ for hot-reload."
echo "Changes to ui/src/ will automatically update in the browser."
echo ""
npm run dev
ui:build:
desc: Build the Activity UI component library
dir: ui
cmds:
- |
set -e
echo "📦 Building Activity UI component library..."
npm run build
echo "✅ Library built to ui/dist/"
ui:type-check:
desc: Type-check the Activity UI component library
dir: ui
cmds:
- npm run type-check
ui:lint:
desc: Lint the Activity UI component library
dir: ui
cmds:
- npm run lint
# OpenAPI code generation
generate:openapi:
desc: Generate Kubernetes OpenAPI definitions
cmds:
- |
set -e
echo "🔄 Generating Kubernetes OpenAPI definitions..."
./hack/update-codegen.sh
echo "✅ OpenAPI generation complete"
silent: true
# RBAC generation from kubebuilder annotations
generate:rbac:
desc: Generate RBAC manifests from kubebuilder annotations
cmds:
- |
set -e
echo "🔄 Generating RBAC manifests from kubebuilder annotations..."
./hack/generate-rbac.sh
echo "✅ RBAC generation complete"
silent: true
# API documentation generation
generate:docs:
desc: Generate API reference documentation
cmds:
- |
set -e
echo "🔄 Generating API reference documentation..."
chmod +x ./hack/generate-api-docs.sh
./hack/generate-api-docs.sh
echo "✅ API documentation generation complete"
silent: true
# Architecture diagram tasks
diagrams:
desc: Generate architecture diagrams from PlantUML
cmds:
- task: docs:diagrams
silent: true
# Unified code generation task - composes all generate:* subtasks
generate:
desc: Run all code generation tasks (OpenAPI, RBAC, migrations ConfigMap, API docs, diagrams, k6 tests, etc.)
deps:
- generate:openapi
- generate:rbac
- migrations:generate
- load:generate
- observability:build-mixin
- generate:docs
- docs:generate
cmds:
- |
echo ""
echo "🎉 All code generation complete!"
echo ""
echo "Generated files:"
echo " - pkg/generated/openapi/zz_generated.openapi.go"
echo " - config/base/generated/controller-manager-rbac.yaml"
echo " - config/components/clickhouse-migrations/configmap.yaml"
echo " - config/components/k6-performance-tests/generated/query-load-test.js"
echo " - docs/api.md"
echo ""
echo "Next steps:"
echo " - Review generated files"
echo " - Commit: git add pkg/ config/ docs/ && git commit -m 'chore: regenerate code and docs'"
silent: true
# ============================================================
# E2E Testing with Chainsaw
# ============================================================
e2e:
desc: Run chainsaw e2e tests
cmds:
- chainsaw test test/e2e/ --config test/e2e/chainsaw-test.yaml
silent: false
e2e:named-rules:
desc: Run named rules e2e tests only
cmds:
- chainsaw test test/e2e/activitypolicy/named-rules/
silent: false