Files
apps-registry/workloads/ecommerce/commerce/medusa.yaml
T
devops 7a83ed61b9 fix(medusa): forzar podAffinity con commerce-postgres para evitar blackhole MTU cross-node
Diagnostico: pg_isready y el cliente pg de Medusa fallan de forma
consistente (100%, 186/186 intentos) cuando el pod queda agendado en un
nodo distinto al de commerce-postgres-0. TCP handshake (nc/ping) funciona
cruzando nodos, pero el primer paquete de datos real de la sesion nunca
llega - blackhole de PMTU Discovery entre los nodos del cluster k3d
(flannel VXLAN / MTU del bridge Docker subyacente).

Se agrega podAffinity requiredDuringSchedulingIgnoredDuringExecution
(no nodeSelector fijo, mantiene portabilidad) para que medusa-deploy
siempre comparta nodo con commerce-postgres-0 y evite cruzar el
blackhole. Es un workaround, no el fix de raiz: documentado en
docs/known-issues.md junto con el TODO de ajustar el MTU del cluster
a 1400.
2026-08-09 02:34:15 -05:00

121 lines
2.9 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: medusa-deploy
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: medusa
template:
metadata:
labels:
app: medusa
spec:
imagePullSecrets:
- name: gitea-registry-secret
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: commerce-postgres
topologyKey: kubernetes.io/hostname
initContainers:
- name: wait-for-postgres
image: postgres:17-alpine
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
until pg_isready -d "$DATABASE_URL" -t 5; do
echo "postgres no disponible aun, reintentando..."
sleep 2
done
envFrom:
- secretRef:
name: commerce-secrets
resources:
requests:
cpu: 25m
memory: 32Mi
limits:
cpu: 100m
memory: 64Mi
- name: migrations
image: gitea.cruzcloud.net/devops/ecommerce-medusa:v1.0.85
imagePullPolicy: IfNotPresent
command:
- npx
- medusa
- db:migrate
envFrom:
- configMapRef:
name: commerce-config
- secretRef:
name: commerce-secrets
resources:
requests:
cpu: 50m
memory: 256Mi
limits:
cpu: 500m
memory: 768Mi
containers:
- name: medusa
image: gitea.cruzcloud.net/devops/ecommerce-medusa:v1.0.85
imagePullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: commerce-config
- secretRef:
name: commerce-secrets
ports:
- name: http
containerPort: 9000
readinessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 20
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 18
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 60
periodSeconds: 20
timeoutSeconds: 5
failureThreshold: 6
resources:
requests:
cpu: 150m
memory: 384Mi
limits:
cpu: 750m
memory: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: medusa-svc
spec:
selector:
app: medusa
ports:
- name: http
port: 9000
targetPort: 9000