This repository contains officially supported Reaction Actions for Karo (Kubernetes Alert Reaction Operator).
Karo allows you to define automated responses to Kubernetes alerts using custom resources called AlertReaction. Each AlertReaction can contain multiple actions that are executed as Kubernetes pods when an alert is triggered.
karo-reactions/
βββ .github/
β βββ workflows/ # CI/CD pipelines for building Docker images
βββ actions/ # Directory containing all available actions
β βββ echo/ # Simple echo action (shell-based)
β β βββ README.md # Action documentation
β β βββ action.yaml # Action definition
β βββ webhook-sender/ # Compiled Go action (Docker-based)
β β βββ README.md # Action documentation
β β βββ Dockerfile # Docker build configuration
β β βββ .dockerignore # Docker ignore patterns
β β βββ src/ # Source code
β β βββ main.go # Go application
β β βββ go.mod # Go dependencies
β βββ [action-name]/ # Each action has its own directory
βββ CONTRIBUTING.md # Contribution guidelines
βββ DOCKER_ACTIONS.md # Docker-based action development guide
βββ README.md # This file
Actions are essentially Pod specifications that get executed when an alert is triggered. Each action defines:
- Container Image: The Docker image to run
- Command & Arguments: What the container should execute
- Environment Variables: Data from the alert and external sources
- Resource Limits: CPU and memory constraints
Here's an example of how actions are used in an AlertReaction:
apiVersion: karo.io/v1alpha1
kind: AlertReaction
metadata:
name: high-cpu-alert-reaction
namespace: default
spec:
alertName: HighCPUUsage
actions:
- name: notify-slack
image: curlimages/curl:latest
command: ["curl"]
args:
- "-X"
- "POST"
- "-H"
- "Content-type: application/json"
- "--data"
- '{"text":"High CPU alert triggered on instance: $INSTANCE"}'
env:
- name: INSTANCE
valueFrom:
alertRef:
fieldPath: "labels.instance"
- name: SLACK_WEBHOOK_URL
valueFrom:
secretKeyRef:
name: slack-webhook
key: url
- name: scale-deployment
image: bitnami/kubectl:latest
command: ["kubectl"]
args:
- "scale"
- "deployment"
- "my-app"
- "--replicas=5"
env:
- name: KUBECONFIG
value: "/etc/kubeconfig/config"
resources:
requests:
cpu: "100m"
memory: "64Mi"
limits:
cpu: "200m"
memory: "128Mi"Simple actions that use existing container images (like Alpine, curl, kubectl) with shell commands. These are defined directly in YAML and don't require compilation.
Example: Echo Action (actions/echo/)
Complex actions with custom code that require compilation into Docker images. These actions are automatically built and published to Docker Hub with semantic versioning.
Examples:
- Webhook Sender (
actions/webhook-sender/) - HTTP webhooks with authentication - GCP Pub/Sub (
actions/gcp-pubsub/) - Google Cloud Pub/Sub publishing - Image Pattern:
dudizimber/karo-reactions-<action-name>:<version> - Language: Go (with support for other languages)
- Features: Production-ready with security hardening and error handling
A simple debugging action that prints out alert information. Useful for testing and understanding what data is available from alerts.
Location: actions/echo/
A robust HTTP webhook sender that posts alert data to external endpoints in JSON format.
Location: actions/webhook-sender/
Image: dudizimber/karo-reactions-webhook-sender:latest
Publishes alert data to Google Cloud Pub/Sub topics for event-driven architectures and downstream processing.
Location: actions/gcp-pubsub/
Image: dudizimber/karo-reactions-gcp-pubsub:latest
To use a shell-based action:
- Browse the
actions/directory to find the action you need - Read the action's README.md for specific usage instructions
- Copy the action configuration from the action's
action.yamlfile - Paste it into your AlertReaction's
spec.actionsarray - Customize environment variables and parameters as needed
To use a Docker-based action:
- Browse the
actions/directory to find the action you need - Read the action's README.md for complete configuration examples
- Use the published Docker image:
dudizimber/karo-reactions-<action-name>:<version> - Configure required environment variables (usually from secrets)
- Set appropriate resource limits
Recommended: Always use specific version tags (e.g., v1.0.0) instead of latest for production deployments.
All Docker-based actions are automatically built and published when:
- Code is pushed to the
mainbranch (development images) - Tags are created (release images with semantic versioning)
- Pull requests are opened (test builds)
To build and test an action locally:
# Navigate to the action directory
cd actions/webhook-sender
# Build the Docker image
docker build -t karo-reactions-webhook-sender:dev .
# Test with sample data
docker run --rm \
-e WEBHOOK_URL="https://httpbin.org/post" \
-e ALERT_JSON='{"labels":{"alertname":"TestAlert"}}' \
karo-reactions-webhook-sender:devEach action is versioned independently using semantic versioning. Images are published to Docker Hub when release tags are created:
- Repository Pattern:
dudizimber/karo-reactions-<action-name> - Release Tag Format:
release/<action-name>/<version> - Docker Tag Pattern: Multiple tags are created for each release:
v1.0.0(exact version)v1.0(minor version)v1(major version)latest(latest stable release)
Examples:
# Webhook Sender v1.2.0
dudizimber/karo-reactions-webhook-sender:v1.2.0
dudizimber/karo-reactions-webhook-sender:v1.2
dudizimber/karo-reactions-webhook-sender:v1
dudizimber/karo-reactions-webhook-sender:latest
# GCP Pub/Sub v2.1.0
dudizimber/karo-reactions-gcp-pubsub:v2.1.0
dudizimber/karo-reactions-gcp-pubsub:v2.1
dudizimber/karo-reactions-gcp-pubsub:v2Creating Releases: Maintainers create releases by tagging:
git tag -a release/webhook-sender/v1.2.0 -m "Release webhook-sender v1.2.0"
git push origin release/webhook-sender/v1.2.0We welcome contributions of new actions! Please see our contribution guidelines for details on how to submit new actions.
Use our structured prompts to quickly create new actions with GitHub Copilot:
.copilot/- Complete prompt templates for:- Docker Actions: Go, Python, Node.js implementations
- Shell Actions: Simple container-based actions
- Test Scripts: Comprehensive testing approaches
- Documentation: README and changelog templates
Quick start: Copy a prompt from .copilot/ β Paste into Copilot Chat β Follow the interactive guidance!
See CONTRIBUTING.md for templates and guidelines.
See DOCKER_ACTIONS.md for comprehensive development guidelines including:
- Directory structure requirements
- Dockerfile best practices
- Build and testing procedures
- Security considerations
- Documentation standards
- Create a new directory under
actions/with your action name - Add a
README.mdexplaining what the action does and how to use it - Add an
action.yamlwith the complete action specification (optional) - Test your action thoroughly
- Submit a pull request
- Create a new directory under
actions/with your action name - Add source code in the
src/directory - Create a
Dockerfilefollowing security best practices - Create a
test.shscript that defines how to test your action - Add comprehensive
README.mdwith usage examples - Test locally using
./test.sh your-image:dev - Submit a pull request (images will be built and tested automatically)
Karo provides access to alert data through environment variables:
- Use
alertRef.fieldPathto extract specific fields from the alert - Common paths include:
labels.instance- The instance that triggered the alertlabels.job- The job nameannotations.summary- Alert summaryannotations.description- Alert description
- Always use specific image tags instead of
latestin production - Set appropriate resource limits for all actions
- Use Kubernetes secrets for sensitive data like API keys and webhooks
- Review action code before using in production environments
This project is licensed under the MIT License - see the LICENSE file for details.