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: initContainers: - name: wait-for-mysql image: busybox:1.36 command: - sh - -c - | echo "Waiting for MySQL port to open..." until nc -z mysql 3306; do echo "MySQL not ready yet, retrying in 5s..." sleep 5 done echo "Port open — waiting 15s for MySQL to finish initializing..." sleep 15 echo "MySQL is ready!" 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: MYSQL_USER # matches new secret key - name: DB_PASSWORD valueFrom: secretKeyRef: name: mysql-secret key: MYSQL_PASSWORD # matches new secret key - name: DB_NAME valueFrom: secretKeyRef: name: mysql-secret key: DB_NAME - name: PORT value: "3001" resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 256Mi livenessProbe: httpGet: path: /api/health port: http initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 3 failureThreshold: 3 readinessProbe: httpGet: path: /api/health port: http initialDelaySeconds: 15 periodSeconds: 5 timeoutSeconds: 3 failureThreshold: 5