Add forecasting service

This commit is contained in:
Urtzi Alfaro
2025-07-21 19:48:56 +02:00
parent 2d85dd3e9e
commit 0e7ca10a29
24 changed files with 2937 additions and 179 deletions

View File

@@ -0,0 +1,78 @@
# ================================================================
# Kubernetes Deployment: infrastructure/kubernetes/base/forecasting-service.yaml
# ================================================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: forecasting-service
labels:
app: forecasting-service
spec:
replicas: 2
selector:
matchLabels:
app: forecasting-service
template:
metadata:
labels:
app: forecasting-service
spec:
containers:
- name: forecasting-service
image: bakery-forecasting/forecasting-service:latest
ports:
- containerPort: 8000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: forecasting-db-secret
key: database-url
- name: RABBITMQ_URL
valueFrom:
secretKeyRef:
name: rabbitmq-secret
key: url
- name: REDIS_URL
valueFrom:
secretKeyRef:
name: redis-secret
key: url
- name: TRAINING_SERVICE_URL
value: "http://training-service:8000"
- name: DATA_SERVICE_URL
value: "http://data-service:8000"
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: forecasting-service
labels:
app: forecasting-service
spec:
selector:
app: forecasting-service
ports:
- port: 8000
targetPort: 8000
type: ClusterIP

View File

@@ -0,0 +1,42 @@
# ================================================================
# Monitoring Configuration: infrastructure/monitoring/prometheus/forecasting-service.yml
# ================================================================
groups:
- name: forecasting-service
rules:
- alert: ForecastingServiceDown
expr: up{job="forecasting-service"} == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Forecasting service is down"
description: "Forecasting service has been down for more than 1 minute"
- alert: HighForecastingLatency
expr: histogram_quantile(0.95, forecast_processing_time_seconds) > 10
for: 5m
labels:
severity: warning
annotations:
summary: "High forecasting latency"
description: "95th percentile forecasting latency is {{ $value }}s"
- alert: ForecastingErrorRate
expr: rate(forecasting_errors_total[5m]) > 0.1
for: 5m
labels:
severity: critical
annotations:
summary: "High forecasting error rate"
description: "Forecasting error rate is {{ $value }} errors/sec"
- alert: LowModelAccuracy
expr: avg(model_accuracy_score) < 0.7
for: 10m
labels:
severity: warning
annotations:
summary: "Low model accuracy detected"
description: "Average model accuracy is {{ $value }}"