Skip to content

Commit 6d34c36

Browse files
committed
feat: adjust EventListener to integrate with new MLOps pipeline
Update EventListener configuration and parameters to align with the refactored MLOps pipeline that uses DVC version parameters
1 parent 6dd304f commit 6d34c36

File tree

10 files changed

+674
-271
lines changed

10 files changed

+674
-271
lines changed

deploy/Makefile

Lines changed: 79 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ NAMESPACE ?= $(shell oc config view --minify --output 'jsonpath={..namespace}')
1010
CO := oc --context $(CONTEXT)
1111

1212
# Pipeline parameters (overrideable on the CLI):
13-
REPO_REMOTE_URL ?= source/code/url
1413
HUMAN_VERIFIED_FILE_PATH ?= ""
1514

1615
LLM_URL ?= http://<<please-set-llm-url>>
@@ -22,7 +21,7 @@ PROJECT_NAME ?= project-name
2221
PROJECT_VERSION ?= project-version
2322

2423
DOWNLOAD_REPO ?= false
25-
REPO_REMOTE_URL ?= ""
24+
REPO_REMOTE_URL ?= source/code/url
2625
REPO_LOCAL_PATH ?= /path/to/repo
2726

2827
INPUT_REPORT_FILE_PATH ?= http://<<please-set-google-spreadsheet-url>>
@@ -58,6 +57,7 @@ ARGOCD_NAMESPACE ?= sast-ai
5857

5958
# EventListener Configuration
6059
ORCHESTRATOR_API_URL ?=
60+
MLOPS_ORCHESTRATOR_API_URL ?=
6161

6262
# Secret configuration (loaded from .env file)
6363
GITLAB_TOKEN ?= ""
@@ -67,21 +67,34 @@ GOOGLE_SERVICE_ACCOUNT_JSON_PATH ?= ./service_account.json
6767
GCS_SERVICE_ACCOUNT_JSON_PATH ?= ./gcs_service_account.json
6868
DOCKER_CONFIG_PATH ?= $(HOME)/.config/containers/auth.json
6969

70+
7071
# S3/Minio Configuration
7172
S3_OUTPUT_BUCKET_NAME ?= ""
7273
AWS_ACCESS_KEY_ID ?= ""
7374
AWS_SECRET_ACCESS_KEY ?= ""
7475
S3_ENDPOINT_URL ?= ""
75-
76-
.PHONY: deploy setup tasks secrets pipeline scripts configmaps run clean generate-prompts prompts argocd-deploy-mlops argocd-deploy-prod argocd-clean
76+
.PHONY: deploy deploy-dev deploy-prod deploy-mlops setup tasks-dev tasks-prod tasks-mlops secrets pipeline scripts configmaps run clean generate-prompts prompts argocd-deploy-dev argocd-deploy-prod argocd-clean eventlistener eventlistener-clean
7777

7878
# Unified deploy command
7979
# Usage:
8080
# make deploy # Deploy base (Google Drive, :latest)
8181
# make deploy ENV=mlops # Deploy MLOps (S3/Minio, :latest)
8282
# make deploy ENV=prod IMAGE_VERSION=1.2.3 # Deploy prod (Google Drive, versioned)
83-
deploy:
84-
@if [ "$(ENV)" = "prod" ] && [ -z "$(IMAGE_VERSION)" ]; then \
83+
deploy: deploy-$(ENV)
84+
85+
deploy-dev: CONTAINER_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_NAME):latest
86+
deploy-dev: setup-common tasks-dev argocd-deploy-dev
87+
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
88+
@echo "🚀 SAST AI Workflow - Development Deployment"
89+
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
90+
@echo " Environment: Development"
91+
@echo " Container Image: $(CONTAINER_IMAGE)"
92+
@echo ""
93+
@echo "✅ Development deployment completed successfully!"
94+
95+
deploy-prod: CONTAINER_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)
96+
deploy-prod: setup tasks-prod argocd-deploy-prod
97+
@if [ -z "$(IMAGE_VERSION)" ]; then \
8598
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; \
8699
echo "❌ ERROR: IMAGE_VERSION is required for production deployment"; \
87100
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; \
@@ -90,55 +103,58 @@ deploy:
90103
echo ""; \
91104
echo "Available versions can be found at:"; \
92105
echo "https://quay.io/repository/ecosystem-appeng/sast-ai-workflow?tab=tags"; \
106+
exit 1; \
107+
fi
108+
109+
deploy-mlops: CONTAINER_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_NAME):latest
110+
deploy-mlops: setup tasks-mlops argocd-deploy-mlops
111+
@if [ -z "$(MLOPS_ORCHESTRATOR_API_URL)" ]; then \
112+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; \
113+
echo "❌ ERROR: MLOPS_ORCHESTRATOR_API_URL is required for MLOps deployment"; \
114+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"; \
93115
echo ""; \
116+
echo "Usage: make deploy-mlops MLOPS_ORCHESTRATOR_API_URL=<url>"; \
117+
echo ""; \
118+
echo "Example:"; \
119+
echo " make deploy-mlops MLOPS_ORCHESTRATOR_API_URL=http://orchestrator.sast-ai.svc.cluster.local:8080"; \
94120
exit 1; \
95121
fi
96122
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
97-
@echo "🚀 SAST AI Workflow - Deployment"
123+
@echo "🤖 SAST AI Workflow - MLOps Benchmarking Deployment"
98124
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
99-
@if [ "$(ENV)" = "mlops" ]; then \
100-
echo " Environment: MLOps"; \
101-
echo " Storage: S3/Minio output upload"; \
102-
echo " Container Image: $(IMAGE_REGISTRY)/$(IMAGE_NAME):latest"; \
103-
elif [ "$(ENV)" = "prod" ]; then \
104-
echo " Environment: Production"; \
105-
echo " Storage: Google Drive upload"; \
106-
echo " Container Image: $(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)"; \
107-
else \
108-
echo " Environment: Base"; \
109-
echo " Storage: Google Drive upload"; \
110-
echo " Container Image: $(IMAGE_REGISTRY)/$(IMAGE_NAME):latest"; \
111-
fi
125+
@echo " Environment: MLOps (Benchmarking)"
126+
@echo " Container Image: $(CONTAINER_IMAGE)"
127+
@echo " Orchestrator URL: $(MLOPS_ORCHESTRATOR_API_URL)"
112128
@echo ""
113-
@if [ "$(ENV)" = "mlops" ]; then \
114-
$(MAKE) --no-print-directory ENV=mlops setup scripts tasks prompts configmaps argocd-deploy-mlops; \
115-
elif [ "$(ENV)" = "prod" ]; then \
116-
$(MAKE) --no-print-directory ENV=prod CONTAINER_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION) setup scripts tasks prompts configmaps argocd-deploy-prod; \
117-
else \
118-
$(MAKE) --no-print-directory setup scripts tasks prompts configmaps; \
119-
fi
129+
@echo "🎯 Deploying EventListener..."
130+
@sed -e 's|ORCHESTRATOR_API_URL_PLACEHOLDER|$(MLOPS_ORCHESTRATOR_API_URL)|g' \
131+
tekton/eventlistener/benchmark-config.yaml.example > tekton/eventlistener/benchmark-config.yaml
132+
@$(CO) apply -k tekton/eventlistener/ -n $(NAMESPACE) || \
133+
{ echo " ❌ Failed to deploy EventListener resources"; exit 1; }
134+
@echo " ✓ EventListener deployed"
135+
@echo ""
136+
@echo "✅ MLOps deployment completed successfully!"
120137

121-
setup:
122-
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
123-
@echo "🚀 SAST AI Workflow - Infrastructure Setup"
138+
setup: secrets scripts prompts configmaps
124139
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
140+
@echo "🚀 Common Infrastructure Ready"
125141
@echo " Context: $(CONTEXT)"
126142
@echo " Namespace: $(NAMESPACE)"
127-
@echo ""
128-
@$(MAKE) --no-print-directory secrets
129143

130-
tasks:
131-
@echo "📋 Setting up Tekton Resources..."
132-
@if [ "$(ENV)" = "prod" ]; then \
133-
$(CO) apply -k tekton/overlays/prod -n $(NAMESPACE) && \
134-
echo " ✓ Tekton resources deployed (production overlay)"; \
135-
elif [ "$(ENV)" = "mlops" ]; then \
136-
$(CO) apply -k tekton/overlays/mlops -n $(NAMESPACE) && \
137-
echo " ✓ Tekton resources deployed (mlops overlay - S3 output storage)"; \
138-
else \
139-
$(CO) apply -k tekton/base -n $(NAMESPACE) && \
140-
echo " ✓ Tekton resources deployed (base - Google Drive storage)"; \
141-
fi
144+
tasks-dev:
145+
@echo "📋 Deploying Tekton resources (dev)..."
146+
@$(CO) apply -k tekton/base -n $(NAMESPACE)
147+
@echo " ✓ Base Tekton resources (base - Google Drive storage)"
148+
149+
tasks-prod:
150+
@echo "📋 Deploying Tekton resources (prod)..."
151+
@$(CO) apply -k tekton/overlays/prod -n $(NAMESPACE)
152+
@echo " ✓ Production Tekton resources (versioned)"
153+
154+
tasks-mlops:
155+
@echo "📋 Deploying Tekton resources (mlops)..."
156+
@$(CO) apply -k tekton/overlays/mlops -n $(NAMESPACE)
157+
@echo " ✓ MLOps Tekton resources (MinIO/S3)"
142158

143159
secrets:
144160
@echo "🔐 Configuring Secrets..."
@@ -251,10 +267,6 @@ secrets:
251267
{ echo " ❌ Failed to patch pipeline service account"; exit 1; }
252268
@echo " ✓ Service account configured"
253269

254-
pipeline:
255-
@echo "🔧 Pipeline..."
256-
@echo " ✓ Pipeline deployed with Tekton resources (via kustomize)"
257-
258270
scripts:
259271
@echo "📜 Setting up Scripts..."
260272
@$(CO) apply -n $(NAMESPACE) -f tekton/scripts/upload_to_drive_cm.yaml || \
@@ -367,68 +379,41 @@ argocd-clean:
367379

368380
eventlistener:
369381
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
370-
@echo "🎯 SAST AI Workflow - EventListener for MLOps Benchmarking"
382+
@echo "🎯 EventListener Standalone Update"
371383
@echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
372-
@echo " Context: $(CONTEXT)"
373-
@echo " Namespace: $(NAMESPACE)"
384+
@echo " ⚠️ Use 'make deploy-mlops' for full deployment"
374385
@echo ""
375-
@echo "📋 Validating EventListener configuration..."
376386
@if [ -z "$(ORCHESTRATOR_API_URL)" ]; then \
377-
echo " ORCHESTRATOR_API_URL is required"; \
387+
echo "❌ ERROR: ORCHESTRATOR_API_URL is required"; \
378388
echo ""; \
379389
echo "Usage:"; \
380-
echo " make eventlistener ORCHESTRATOR_API_URL=<url> NAMESPACE=<namespace>"; \
390+
echo " make eventlistener ORCHESTRATOR_API_URL=<url>"; \
381391
echo ""; \
382392
echo "Example:"; \
383-
echo " make eventlistener \\"; \
384-
echo " ORCHESTRATOR_API_URL=http://sast-ai-orchestrator.sast-ai.svc.cluster.local:8080 \\"; \
385-
echo " NAMESPACE=sast-ai"; \
386-
echo ""; \
387-
echo "Tip: Find your orchestrator URL with:"; \
388-
echo " oc get svc -l app=sast-ai-orchestrator"; \
389-
echo ""; \
393+
echo " make eventlistener ORCHESTRATOR_API_URL=http://orchestrator.sast-ai.svc.cluster.local:8080"; \
390394
exit 1; \
391395
fi
392-
@echo " ✓ Configuration validated"
393-
@echo " • Orchestrator URL: $(ORCHESTRATOR_API_URL)"
394-
@echo ""
395-
@echo "🔧 Generating benchmark-config.yaml..."
396-
@cat > tekton/eventlistener/benchmark-config.yaml <<EOF
397-
# EventListener Configuration for MLOps Benchmarking
398-
# Generated by: make eventlistener
399-
# Timestamp: $$(date -u +"%Y-%m-%d %H:%M:%S UTC")
400-
apiVersion: v1
401-
kind: ConfigMap
402-
metadata:
403-
name: benchmark-config
404-
labels:
405-
app.kubernetes.io/name: sast-ai-workflow
406-
app.kubernetes.io/component: benchmark-mlop
407-
data:
408-
# Orchestrator API base URL (cluster-internal service)
409-
orchestrator-api-url: "$(ORCHESTRATOR_API_URL)"
410-
411-
# API endpoint path for MLOps batches
412-
api-batch-endpoint: "/api/v1/mlops-batches"
413-
EOF
414-
@echo " ✓ Configuration file generated"
415-
@echo ""
416-
@echo "🚀 Deploying EventListener resources..."
396+
@echo "🎯 Deploying EventListener..."
397+
@sed -e 's|ORCHESTRATOR_API_URL_PLACEHOLDER|$(ORCHESTRATOR_API_URL)|g' \
398+
tekton/eventlistener/benchmark-config.yaml.example > tekton/eventlistener/benchmark-config.yaml
417399
@$(CO) apply -k tekton/eventlistener/ -n $(NAMESPACE) || \
418400
{ echo " ❌ Failed to deploy EventListener resources"; exit 1; }
419-
@echo " ✓ EventListener deployed"
420-
@echo ""
421-
@echo "✅ EventListener deployment completed!"
422401
@echo ""
423-
@echo "📊 Verify deployment:"
424-
@echo " oc get eventlistener,task,pipeline,cm -l app.kubernetes.io/component=benchmark-mlop -n $(NAMESPACE)"
402+
@echo "✅ EventListener updated"
425403
@echo ""
426-
@echo "🧪 Test EventListener:"
427-
@echo " cd tekton/eventlistener && ./test-eventlistener.sh"
404+
@echo "📊 Verify: oc get eventlistener,task,pipeline -l app.kubernetes.io/component=benchmark-mlop -n $(NAMESPACE)"
405+
@echo "🧪 Test: cd tekton/eventlistener && ./test-eventlistener.sh"
428406
@echo ""
429407

430408
eventlistener-clean:
431409
@echo "🧹 Removing EventListener resources..."
410+
@echo " 🏃 Cleaning benchmark PipelineRuns..."
411+
@$(CO) delete pipelinerun -l app.kubernetes.io/component=benchmark-mlop -n $(NAMESPACE) --ignore-not-found > /dev/null 2>&1 || true
412+
@echo " ✓ Benchmark PipelineRuns removed"
413+
@echo " 📋 Cleaning benchmark TaskRuns..."
414+
@$(CO) delete taskrun -l app.kubernetes.io/component=benchmark-mlop -n $(NAMESPACE) --ignore-not-found > /dev/null 2>&1 || true
415+
@echo " ✓ Benchmark TaskRuns removed"
416+
@echo " 🗑️ Removing EventListener infrastructure..."
432417
@$(CO) delete -k tekton/eventlistener/ -n $(NAMESPACE) --ignore-not-found > /dev/null 2>&1 || true
433418
@echo " ✓ EventListener resources removed"
434419

@@ -516,7 +501,7 @@ clean:
516501
@echo "🔐 Removing Secrets..."
517502
@$(CO) delete secret sast-ai-gitlab-token \
518503
sast-ai-default-llm-creds \
519-
sast-ai-google-drive-service-account \
504+
sast-ai-google-service-account \
520505
sast-ai-gcs-service-account \
521506
sast-ai-s3-output-credentials \
522507
sast-ai-quay-registry-config \

deploy/README.md

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,94 @@ For VPN-protected clusters, use GitOps to automatically sync Tekton resources fr
179179
- Repository access from within the cluster
180180

181181
#### 8.2. Deploy GitOps
182+
183+
**Development Environment:**
184+
```bash
185+
# Deploy ArgoCD Application (dev)
186+
make deploy-dev
187+
```
188+
189+
**Production Environment:**
182190
```bash
183-
# Deploy ArgoCD Application
184-
make argocd-deploy
191+
# Deploy ArgoCD Application (prod) with specific version
192+
make deploy-prod IMAGE_VERSION=1.2.3
185193
```
186194

187195
#### 8.3. How It Works
188196
- **Auto-sync**: Changes to `main` branch deploy automatically (~3 min)
189-
- **Self-healing**: Manual changes are automatically reverted
197+
- **Self-healing**: Manual changes are automatically reverted (dev only)
190198
- **Pruning**: Deleted files are removed from cluster
191-
- **Path**: Only syncs `deploy/tekton/` directory
199+
- **Path**:
200+
- Dev: Syncs `deploy/tekton/base` (uses latest tag)
201+
- Prod: Syncs `deploy/tekton/overlays/prod` (uses release versions)
192202

193203
#### 8.4. Configuration
194204
Set in `.env` file (optional):
195205
```env
196206
GITHUB_REPO_URL=https://github.com/your-org/sast-ai-workflow.git
197207
ARGOCD_NAMESPACE=sast-ai
208+
209+
# Orchestrator Configuration (for hooks)
210+
ORCHESTRATOR_API_URL=http://sast-ai-orchestrator.sast-ai.svc.cluster.local:8080
211+
BATCH_PACKAGES_SHEET_URL=https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID
212+
BASE_GDRIVE_FOLDER_ID=your-parent-folder-id
213+
```
214+
215+
#### 8.5. ArgoCD Hooks - Automated Batch Triggering
216+
217+
**What are hooks?**
218+
219+
ArgoCD PostSync hooks automatically trigger batch SAST analysis via the sast-ai-orchestrator when a new release is deployed to production.
220+
221+
**How it works:**
222+
223+
1. New sast-ai-workflow version deployed via ArgoCD
224+
2. PostSync hook runs after successful sync
225+
3. Hook generates unique RUN_ID: `v1.2.3-20251021-143055-a3f2b9`
226+
4. Calls orchestrator batch API with package list
227+
5. Orchestrator creates Tekton PipelineRuns for each package
228+
6. All reports organized under the same RUN_ID
229+
230+
**Configuration:**
231+
232+
```bash
233+
# Set in .env file
234+
ORCHESTRATOR_API_URL=http://sast-ai-orchestrator.sast-ai.svc.cluster.local:8080
235+
BATCH_PACKAGES_SHEET_URL=https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID
236+
237+
# Deploy with hooks
238+
make deploy-prod IMAGE_VERSION=1.2.3
198239
```
199240

200-
#### 8.5. Prompt Changes with GitOps
241+
**Manual hook deployment:**
242+
243+
```bash
244+
make argocd-hooks
245+
```
246+
247+
**Disable hooks temporarily:**
248+
249+
```bash
250+
# Update ConfigMap
251+
oc edit configmap sast-ai-hook-config -n sast-ai
252+
# Change: enable-hook: "false"
253+
```
254+
255+
**Monitor hook execution:**
256+
257+
```bash
258+
# View hook jobs
259+
oc get jobs -l app.kubernetes.io/component=argocd-hook -n sast-ai
260+
261+
# View logs
262+
oc logs -l app.kubernetes.io/component=argocd-hook -n sast-ai --tail=100
263+
```
264+
265+
**Troubleshooting:**
266+
267+
See detailed troubleshooting guide in `argocd/hooks/README.md`
268+
269+
#### 8.6. Prompt Changes with GitOps
201270
When modifying prompts in `src/templates/prompts/`, you must regenerate the ConfigMap:
202271

203272
```bash

0 commit comments

Comments
 (0)