128 lines
3.4 KiB
YAML
128 lines
3.4 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: notification-service
|
|
namespace: bakery-ia
|
|
labels:
|
|
app.kubernetes.io/name: notification-service
|
|
app.kubernetes.io/component: microservice
|
|
app.kubernetes.io/part-of: bakery-ia
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: notification-service
|
|
app.kubernetes.io/component: microservice
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: notification-service
|
|
app.kubernetes.io/component: microservice
|
|
spec:
|
|
initContainers:
|
|
- name: wait-for-migration
|
|
image: postgres:15-alpine
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Waiting for notification database and migrations to be ready..."
|
|
# Wait for database to be accessible
|
|
until pg_isready -h $NOTIFICATION_DB_HOST -p $NOTIFICATION_DB_PORT -U $NOTIFICATION_DB_USER; do
|
|
echo "Database not ready yet, waiting..."
|
|
sleep 2
|
|
done
|
|
echo "Database is ready!"
|
|
# Give migrations extra time to complete after DB is ready
|
|
echo "Waiting for migrations to complete..."
|
|
sleep 10
|
|
echo "Ready to start service"
|
|
env:
|
|
- name: NOTIFICATION_DB_HOST
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: NOTIFICATION_DB_HOST
|
|
- name: NOTIFICATION_DB_PORT
|
|
valueFrom:
|
|
configMapKeyRef:
|
|
name: bakery-config
|
|
key: DB_PORT
|
|
- name: NOTIFICATION_DB_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: database-secrets
|
|
key: NOTIFICATION_DB_USER
|
|
containers:
|
|
- name: notification-service
|
|
image: bakery/notification-service:latest
|
|
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
|
|
- 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
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: notification-service
|
|
namespace: bakery-ia
|
|
labels:
|
|
app.kubernetes.io/name: notification-service
|
|
app.kubernetes.io/component: microservice
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- port: 8000
|
|
targetPort: 8000
|
|
protocol: TCP
|
|
name: http
|
|
selector:
|
|
app.kubernetes.io/name: notification-service
|
|
app.kubernetes.io/component: microservice
|