Increasing the request to 256Mi caused backend pods to be Pending with no node assignment — the scheduler couldn't fit them alongside MySQL (512Mi request) and existing pods on the on-premise nodes. Memory REQUEST drives scheduling (how much the node reserves). Memory LIMIT drives OOMKill (the actual cap at runtime). Keep request at 128Mi so pods schedule, limit at 512Mi so Node.js + Socket.io + MySQL pool don't get OOMKilled on startup. Also add terminationGracePeriodSeconds: 15 so pods from failed/previous builds release their node slot quickly instead of blocking new pod scheduling. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
88 lines
2.5 KiB
YAML
88 lines
2.5 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: backend
|
|
labels:
|
|
app.kubernetes.io/name: backend
|
|
app.kubernetes.io/component: api
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: backend
|
|
app.kubernetes.io/component: api
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: backend
|
|
app.kubernetes.io/component: api
|
|
spec:
|
|
terminationGracePeriodSeconds: 15
|
|
initContainers:
|
|
- name: wait-for-mysql
|
|
image: busybox:1.36
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
echo "Waiting for MySQL TCP to be available..."
|
|
until nc -z mysql 3306; do
|
|
echo "MySQL not reachable yet, retrying in 3s..."
|
|
sleep 3
|
|
done
|
|
echo "MySQL TCP is up. Waiting 15s for full initialization..."
|
|
sleep 15
|
|
echo "Proceeding to start backend."
|
|
containers:
|
|
- name: backend
|
|
image: scrum-backend:latest
|
|
imagePullPolicy: IfNotPresent
|
|
ports:
|
|
- containerPort: 3001
|
|
name: http
|
|
env:
|
|
- name: DB_HOST
|
|
value: mysql
|
|
- name: DB_PORT
|
|
value: "3306"
|
|
- name: DB_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: DB_USER
|
|
- name: DB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: DB_PASSWORD
|
|
- name: DB_NAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: DB_NAME
|
|
- name: PORT
|
|
value: "3001"
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 128Mi # Request drives scheduling — keep low so pods fit on nodes
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi # Limit prevents OOMKill during startup spikes
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 5
|
|
timeoutSeconds: 3
|
|
failureThreshold: 5
|