144 lines
4.0 KiB
YAML
144 lines
4.0 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: alert-processor
|
|
namespace: bakery-ia
|
|
labels:
|
|
app.kubernetes.io/name: alert-processor
|
|
app.kubernetes.io/component: service
|
|
app.kubernetes.io/part-of: bakery-ia
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: alert-processor
|
|
app.kubernetes.io/component: service
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: alert-processor
|
|
app.kubernetes.io/component: service
|
|
spec:
|
|
initContainers:
|
|
# Wait for RabbitMQ to be ready
|
|
- name: wait-for-rabbitmq
|
|
image: curlimages/curl:latest
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Waiting for RabbitMQ to be ready..."
|
|
until curl -f -u "$RABBITMQ_USER:$RABBITMQ_PASSWORD" http://$RABBITMQ_HOST:15672/api/healthchecks/node > /dev/null 2>&1; do
|
|
echo "RabbitMQ not ready yet, waiting..."
|
|
sleep 2
|
|
done
|
|
echo "RabbitMQ is ready!"
|
|
env:
|
|
- name: RABBITMQ_HOST
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: RABBITMQ_HOST
|
|
- name: RABBITMQ_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: rabbitmq-secrets
|
|
key: RABBITMQ_USER
|
|
- name: RABBITMQ_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: rabbitmq-secrets
|
|
key: RABBITMQ_PASSWORD
|
|
- name: wait-for-migration
|
|
image: postgres:17-alpine
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Waiting for alert-processor database and migrations to be ready..."
|
|
until pg_isready -h $ALERT_PROCESSOR_DB_HOST -p $ALERT_PROCESSOR_DB_PORT -U $ALERT_PROCESSOR_DB_USER; do
|
|
echo "Database not ready yet, waiting..."
|
|
sleep 2
|
|
done
|
|
echo "Database is ready!"
|
|
echo "Waiting for migrations to complete..."
|
|
sleep 10
|
|
echo "Ready to start service"
|
|
env:
|
|
- name: ALERT_PROCESSOR_DB_HOST
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: ALERT_PROCESSOR_DB_HOST
|
|
- name: ALERT_PROCESSOR_DB_PORT
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: DB_PORT
|
|
- name: ALERT_PROCESSOR_DB_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: database-secrets
|
|
key: ALERT_PROCESSOR_DB_USER
|
|
containers:
|
|
- name: alert-processor
|
|
image: bakery/alert-processor:latest
|
|
command: ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
ports:
|
|
- containerPort: 8000
|
|
name: http
|
|
envFrom:
|
|
- configMapRef:
|
|
name: bakery-config
|
|
- secretRef:
|
|
name: database-secrets
|
|
- secretRef:
|
|
name: redis-secrets
|
|
- secretRef:
|
|
name: rabbitmq-secrets
|
|
- secretRef:
|
|
name: jwt-secrets
|
|
resources:
|
|
requests:
|
|
memory: "256Mi"
|
|
cpu: "100m"
|
|
limits:
|
|
memory: "512Mi"
|
|
cpu: "500m"
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8000
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8000
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: alert-processor
|
|
namespace: bakery-ia
|
|
labels:
|
|
app.kubernetes.io/name: alert-processor
|
|
app.kubernetes.io/component: service
|
|
app.kubernetes.io/part-of: bakery-ia
|
|
spec:
|
|
selector:
|
|
app.kubernetes.io/name: alert-processor
|
|
app.kubernetes.io/component: service
|
|
ports:
|
|
- name: http
|
|
port: 8000
|
|
targetPort: 8000
|
|
protocol: TCP
|
|
type: ClusterIP
|