- Updated all OpenTelemetry packages to latest versions: - opentelemetry-api: 1.27.0 → 1.39.1 - opentelemetry-sdk: 1.27.0 → 1.39.1 - opentelemetry-exporter-otlp-proto-grpc: 1.27.0 → 1.39.1 - opentelemetry-exporter-otlp-proto-http: 1.27.0 → 1.39.1 - opentelemetry-instrumentation-fastapi: 0.48b0 → 0.60b1 - opentelemetry-instrumentation-httpx: 0.48b0 → 0.60b1 - opentelemetry-instrumentation-redis: 0.48b0 → 0.60b1 - opentelemetry-instrumentation-sqlalchemy: 0.48b0 → 0.60b1 - Removed prometheus-client==0.23.1 from all services - Unified all services to use the same monitoring package versions Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
181 lines
5.2 KiB
YAML
181 lines
5.2 KiB
YAML
# infrastructure/kubernetes/base/components/external/external-service.yaml
|
|
# External Data Service v2.0 - Optimized city-based architecture
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: external-service
|
|
namespace: bakery-ia
|
|
labels:
|
|
app.kubernetes.io/name: external-service
|
|
app.kubernetes.io/component: microservice
|
|
app.kubernetes.io/part-of: bakery-ia
|
|
version: "2.0"
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: external-service
|
|
app.kubernetes.io/component: microservice
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: external-service
|
|
app.kubernetes.io/component: microservice
|
|
version: "2.0"
|
|
spec:
|
|
imagePullSecrets:
|
|
- name: dockerhub-creds
|
|
initContainers:
|
|
# Wait for Redis to be ready
|
|
- name: wait-for-redis
|
|
image: redis:7.4-alpine
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Waiting for Redis to be ready..."
|
|
until redis-cli -h $REDIS_HOST -p $REDIS_PORT --tls --cert /tls/redis-cert.pem --key /tls/redis-key.pem --cacert /tls/ca-cert.pem -a "$REDIS_PASSWORD" ping | grep -q PONG; do
|
|
echo "Redis not ready yet, waiting..."
|
|
sleep 2
|
|
done
|
|
echo "Redis is ready!"
|
|
env:
|
|
- name: REDIS_HOST
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: REDIS_HOST
|
|
- name: REDIS_PORT
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: REDIS_PORT
|
|
- name: REDIS_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: redis-secrets
|
|
key: REDIS_PASSWORD
|
|
volumeMounts:
|
|
- name: redis-tls
|
|
mountPath: /tls
|
|
readOnly: true
|
|
# Check if external data is initialized
|
|
- name: check-data-initialized
|
|
image: postgres:17-alpine
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Checking if data initialization is complete..."
|
|
# Convert asyncpg URL to psql-compatible format
|
|
DB_URL=$(echo "$DATABASE_URL" | sed 's/postgresql+asyncpg:/postgresql:/')
|
|
until psql "$DB_URL" -c "SELECT COUNT(*) FROM city_weather_data LIMIT 1;" > /dev/null 2>&1; do
|
|
echo "Waiting for initial data load..."
|
|
sleep 10
|
|
done
|
|
echo "Data is initialized"
|
|
env:
|
|
- name: DATABASE_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: database-secrets
|
|
key: EXTERNAL_DATABASE_URL
|
|
|
|
containers:
|
|
- name: external-service
|
|
image: bakery/external-service:latest
|
|
ports:
|
|
- containerPort: 8000
|
|
name: http
|
|
env:
|
|
# OpenTelemetry Configuration
|
|
- name: OTEL_COLLECTOR_ENDPOINT
|
|
value: "http://signoz-otel-collector.signoz.svc.cluster.local:4318"
|
|
- name: OTEL_EXPORTER_OTLP_ENDPOINT
|
|
value: "http://signoz-otel-collector.signoz.svc.cluster.local:4318"
|
|
- name: OTEL_SERVICE_NAME
|
|
value: "external-service"
|
|
- name: ENABLE_TRACING
|
|
value: "true"
|
|
# Logging Configuration
|
|
- name: OTEL_LOGS_EXPORTER
|
|
value: "otlp"
|
|
- name: OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED
|
|
value: "true"
|
|
# Metrics Configuration
|
|
- name: ENABLE_OTEL_METRICS
|
|
value: "true"
|
|
- name: ENABLE_SYSTEM_METRICS
|
|
value: "true"
|
|
envFrom:
|
|
- configMapRef:
|
|
name: bakery-config
|
|
- secretRef:
|
|
name: database-secrets
|
|
- secretRef:
|
|
name: redis-secrets
|
|
- secretRef:
|
|
name: rabbitmq-secrets
|
|
- secretRef:
|
|
name: jwt-secrets
|
|
- secretRef:
|
|
name: external-api-secrets
|
|
- secretRef:
|
|
name: payment-secrets
|
|
- secretRef:
|
|
name: email-secrets
|
|
- secretRef:
|
|
name: monitoring-secrets
|
|
- secretRef:
|
|
name: pos-integration-secrets
|
|
- secretRef:
|
|
name: whatsapp-secrets
|
|
resources:
|
|
requests:
|
|
memory: "256Mi"
|
|
cpu: "100m"
|
|
limits:
|
|
memory: "512Mi"
|
|
cpu: "500m"
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health/live
|
|
port: 8000
|
|
initialDelaySeconds: 30
|
|
timeoutSeconds: 5
|
|
periodSeconds: 10
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health/ready
|
|
port: 8000
|
|
initialDelaySeconds: 15
|
|
timeoutSeconds: 3
|
|
periodSeconds: 5
|
|
failureThreshold: 5
|
|
volumes:
|
|
- name: redis-tls
|
|
secret:
|
|
secretName: redis-tls-secret
|
|
defaultMode: 0400
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: external-service
|
|
namespace: bakery-ia
|
|
labels:
|
|
app.kubernetes.io/name: external-service
|
|
app.kubernetes.io/component: microservice
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- port: 8000
|
|
targetPort: 8000
|
|
protocol: TCP
|
|
name: http
|
|
selector:
|
|
app.kubernetes.io/name: external-service
|
|
app.kubernetes.io/component: microservice
|