Files
bakery-ia/infrastructure/kubernetes/base/cronjobs/alert-priority-recalculation-cronjob.yaml
2025-11-27 15:52:40 +01:00

121 lines
2.9 KiB
YAML

apiVersion: batch/v1
kind: CronJob
metadata:
name: alert-priority-recalculation
namespace: bakery-ia
labels:
app: alert-priority-recalculation
component: cron
service: alert-processor
spec:
# Schedule: Every hour at minute 15
schedule: "15 * * * *"
# Keep last 3 successful jobs and 1 failed job for debugging
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
# Don't start new job if previous one is still running
concurrencyPolicy: Forbid
# Job must complete within 10 minutes
startingDeadlineSeconds: 600
jobTemplate:
spec:
# Retry up to 2 times if job fails
backoffLimit: 2
# Job must complete within 30 minutes
activeDeadlineSeconds: 1800
template:
metadata:
labels:
app: alert-priority-recalculation
component: cron
spec:
restartPolicy: OnFailure
# Use alert-processor service image
containers:
- name: priority-recalc
image: bakery/alert-processor:latest
imagePullPolicy: Always
command:
- python3
- -m
- app.jobs.priority_recalculation
env:
# Database connection
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: database-secrets
key: ALERT_PROCESSOR_DATABASE_URL
# Redis connection
- name: REDIS_URL
value: rediss://redis-service:6379/0?ssl_cert_reqs=none
# Alert processor settings
- name: BUSINESS_IMPACT_WEIGHT
value: "0.40"
- name: URGENCY_WEIGHT
value: "0.30"
- name: USER_AGENCY_WEIGHT
value: "0.20"
- name: CONFIDENCE_WEIGHT
value: "0.10"
- name: CRITICAL_THRESHOLD
value: "90"
- name: IMPORTANT_THRESHOLD
value: "70"
- name: STANDARD_THRESHOLD
value: "50"
# Escalation thresholds (hours)
- name: ESCALATION_THRESHOLD_48H
value: "48"
- name: ESCALATION_THRESHOLD_72H
value: "72"
# Service settings
- name: LOG_LEVEL
value: "INFO"
- name: PYTHONUNBUFFERED
value: "1"
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: alert-priority-recalculation-config
namespace: bakery-ia
data:
schedule: "Hourly at minute 15"
description: "Recalculates alert priorities with time-based escalation"
escalation_48h_boost: "10"
escalation_72h_boost: "20"
deadline_24h_boost: "15"
deadline_6h_boost: "30"
max_boost: "30"