This guide provides step-by-step instructions for deploying and configuring the Slaking service in your Kubernetes cluster.
- Kubernetes cluster (1.19+)
- kubectl configured and connected to your cluster
- Docker installed and running
- Slack workspace with API access
- Slack bot token with appropriate permissions
- Go to api.slack.com/apps
- Click "Create New App" → "From an app manifest"
- Copy and paste the contents of
slack-app-manifest.jsoninto the manifest field - Click "Create"
- Go to "Install App" in the sidebar
- Click "Install to Workspace"
- Authorize the app
- Copy the "Bot User OAuth Token" (starts with
xoxb-)
- Go to api.slack.com/apps
- Click "Create New App" → "From scratch"
- Enter app name (e.g., "Slaking") and select your workspace
- Click "Create App"
In your Slack app settings, go to "OAuth & Permissions" and add these scopes:
Bot Token Scopes:
channels:read- Read public channelschat:write- Send messagesgroups:read- Read private channelsim:read- Read direct messagesmpim:read- Read group direct messages
- Go to "Install App" in the sidebar
- Click "Install to Workspace"
- Authorize the app
- Copy the "Bot User OAuth Token" (starts with
xoxb-)
cd slack-o-tron
npm installcp env.example .envEdit .env with your Slack token:
SLACK_TOKEN=xoxb-your-actual-token-here
SLACK_DEFAULT_CHANNEL=#alerts
LOG_LEVEL=debugnpm run devThe service will start on http://localhost:3000
Use the automated deployment script:
./deploy.shThis script will:
- Build the Docker image
- Create the namespace and RBAC resources
- Deploy the service
- Wait for the deployment to be ready
If you prefer manual deployment:
docker build -t slaking:latest .kubectl create namespace slakingkubectl create secret generic slaking-secrets \
--namespace=slaking \
--from-literal=slack-token="xoxb-your-token-here"kubectl apply -f k8s/# Check pods
kubectl get pods -n slaking
# Check services
kubectl get svc -n slaking
# Check logs
kubectl logs -n slaking -l app=slaking
# Test health endpoint
kubectl port-forward -n slaking svc/slaking 3000:3000
curl http://localhost:3000/health| Variable | Description | Default |
|---|---|---|
SLACK_TOKEN |
Slack bot token | Required |
SLACK_DEFAULT_CHANNEL |
Default Slack channel | #general |
SLACK_RATE_LIMIT |
Rate limit in ms | 1000 |
K8S_WATCH_ALL_NAMESPACES |
Watch all namespaces (true/false) | true |
K8S_NAMESPACES |
Comma-separated namespaces to watch | All namespaces (when K8S_WATCH_ALL_NAMESPACES=true) |
LOG_LEVEL |
Logging level | info |
PORT |
HTTP server port | 3000 |
Slaking supports two modes for watching Kubernetes namespaces:
By default, Slaking watches all namespaces in your cluster. This is the recommended configuration for most use cases.
# Environment configuration
K8S_WATCH_ALL_NAMESPACES=true
# K8S_NAMESPACES can be left empty or unsetBenefits:
- Automatically picks up new namespaces
- No need to maintain a list of namespaces
- Works with any workload regardless of namespace
- Simpler configuration
For environments where you want to limit Slaking's scope to specific namespaces.
# Environment configuration
K8S_WATCH_ALL_NAMESPACES=false
K8S_NAMESPACES=production,staging,monitoringUse Cases:
- Multi-tenant clusters with namespace isolation
- Performance optimization for large clusters
- Security requirements limiting cross-namespace access
- Testing in specific environments only
Add these annotations to your Kubernetes workloads:
metadata:
annotations:
slaking.enabled: "true"
slaking.channel: "#alerts"
slaking.filters: "error|exception|fatal"
slaking.level: "error"
slaking.include-labels: "app=myapp,environment=prod"
slaking.exclude-labels: "component=monitoring"
slaking.max-lines: "10"
slaking.cooldown: "60"| Annotation | Type | Description | Default |
|---|---|---|---|
slaking.enabled |
string | Enable log forwarding | false |
slaking.channel |
string | Slack channel (must start with #) | #general |
slaking.filters |
string | Regex pattern to filter logs | .* |
slaking.level |
string | Minimum log level (debug, info, warn, error) | info |
slaking.include-labels |
string | Comma-separated key=value pairs to include | "" |
slaking.exclude-labels |
string | Comma-separated key=value pairs to exclude | "" |
slaking.max-lines |
string | Maximum lines per message | 10 |
slaking.cooldown |
string | Cooldown period in seconds | 60 |
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
template:
metadata:
annotations:
slaking.enabled: "true"
slaking.channel: "#errors"
slaking.filters: "ERROR|FATAL|Exception"
slaking.level: "error"apiVersion: apps/v1
kind: Deployment
metadata:
name: production-api
spec:
template:
metadata:
labels:
environment: production
app: api
annotations:
slaking.enabled: "true"
slaking.channel: "#prod-alerts"
slaking.filters: "error|exception|timeout|deadline"
slaking.level: "warn"
slaking.include-labels: "environment=production"
slaking.max-lines: "5"
slaking.cooldown: "30"apiVersion: apps/v1
kind: Deployment
metadata:
name: dev-app
spec:
template:
metadata:
labels:
environment: development
annotations:
slaking.enabled: "true"
slaking.channel: "#dev-logs"
slaking.filters: ".*"
slaking.level: "debug"
slaking.max-lines: "20"
slaking.cooldown: "10"# Health endpoint
curl http://localhost:3000/health
# Status endpoint
curl http://localhost:3000/status
# Metrics endpoint (Prometheus format)
curl http://localhost:3000/metricsAdd this to your Prometheus configuration:
scrape_configs:
- job_name: 'slaking'
static_configs:
- targets: ['slaking.slaking.svc.cluster.local:9090']Create a Grafana dashboard with these metrics:
slaking_logs_processed_totalslaking_logs_filtered_totalslaking_slack_messages_sent_totalslaking_errors_totalslaking_active_streams
Check:
- Pod annotations are correctly set
- Slack token is valid and has proper permissions
- Service logs for errors
kubectl logs -n slaking -l app=slakingCheck:
- Service account has proper RBAC permissions
- Namespace access
kubectl auth can-i get pods --as=system:serviceaccount:slaking:slakingSolutions:
- Increase cooldown period
- Refine filter patterns
- Set appropriate log levels
Check:
- ConfigMap and Secret are properly created
- Resource limits are appropriate
- Health check configuration
kubectl describe pod -n slaking -l app=slakingEnable debug logging:
kubectl patch deployment slaking -n slaking -p '{"spec":{"template":{"spec":{"containers":[{"name":"slaking","env":[{"name":"LOG_LEVEL","value":"debug"}]}]}}}}'Test your Slack integration:
# Port forward to service
kubectl port-forward -n slaking svc/slaking 3000:3000
# Send test message
curl -X POST http://localhost:3000/test-slack \
-H "Content-Type: application/json" \
-d '{"channel": "#your-channel"}'The service requires minimal permissions:
- Read access to pods and their logs
- Watch access to deployments, statefulsets, daemonsets
- Read access to namespaces
- Service runs on ClusterIP by default
- Metrics endpoint is separate for Prometheus scraping
- No external access required
- Slack token is stored in Kubernetes Secret
- Consider using external secret management (HashiCorp Vault, AWS Secrets Manager, etc.)
kubectl scale deployment slaking -n slaking --replicas=3Note: Multiple replicas will watch the same resources, but only one will process each log stream.
Adjust resource limits in k8s/deployment.yaml:
resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "1Gi"
cpu: "1000m"# Backup ConfigMap
kubectl get configmap slaking-config -n slaking -o yaml > slaking-config-backup.yaml
# Backup Secret
kubectl get secret slaking-secrets -n slaking -o yaml > slaking-secrets-backup.yamlkubectl apply -f slaking-config-backup.yaml
kubectl apply -f slaking-secrets-backup.yamlFor issues and questions:
- Check the logs:
kubectl logs -n slaking -l app=slaking - Verify configuration:
kubectl get configmap slaking-config -n slaking -o yaml - Test Slack connectivity: Use the health check endpoint
- Review RBAC permissions:
kubectl auth can-i --as=system:serviceaccount:slaking:slaking