Skip to main content

kubeswarm Event Triggers - Automate Agent Execution on Kubernetes

SwarmEvent fires kubeswarm agent runs automatically in response to cron schedules, webhook HTTP calls, or upstream pipeline completion on Kubernetes.

Source Types

Cron

apiVersion: kubeswarm.io/v1alpha1
kind: SwarmEvent
metadata:
name: daily-review
spec:
source:
type: cron
cron: "0 8 * * 1-5" # weekdays at 8am UTC
targets:
- agent: ops-agent
input:
prompt: "Review all open PRs."
concurrencyPolicy: Forbid

Webhook

apiVersion: kubeswarm.io/v1alpha1
kind: SwarmEvent
metadata:
name: ci-hook
spec:
source:
type: webhook
targets:
- agent: reviewer
input:
prompt: "{{ .body.message }}"
concurrencyPolicy: Allow

Trigger via HTTP:

WEBHOOK_URL=$(kubectl get swevt ci-hook -o jsonpath='{.status.webhookURL}')
TOKEN=$(kubectl get swevt ci-hook -o jsonpath='{.status.webhookToken}')
curl -X POST "$WEBHOOK_URL" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Review PR #42"}'

Team-output (chaining)

Fire when another pipeline completes:

spec:
source:
type: team-output
teamOutput:
teamRef: upstream-pipeline
targets:
- team: downstream-pipeline
input:
data: "{{ .output }}"

Concurrency Policy

PolicyBehavior
AllowMultiple runs can execute simultaneously
ForbidSkip if a previous run is still active
ReplaceCancel active run, start new one

Targets

Events can target either an agent or a team:

targets:
- agent: my-agent # creates SwarmRun with spec.agent
input:
prompt: "..."
- team: my-team # creates SwarmRun with spec.teamRef
input:
topic: "..."