All checks were successful
scrum-manager/pipeline/head This commit looks good
Root cause: backend deployment.yaml referenced secretKeyRef key: DB_USER and key: DB_PASSWORD, but the live secret only has MYSQL_USER and MYSQL_PASSWORD. kubectl apply reported secret/mysql-secret as "unchanged" (last-applied matched desired) so the drift was never caught — new pods got CreateContainerConfigError. Changes: - backend/deployment.yaml: DB_USER → key: MYSQL_USER, DB_PASSWORD → key: MYSQL_PASSWORD - mysql/deployment.yaml: add MYSQL_USER/MYSQL_PASSWORD env vars so the app user (scrumapp) is created if MySQL ever reinitializes from a fresh PVC - mysql/secret.yaml: remove stale commented-out block with old key names Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
94 lines
2.9 KiB
YAML
94 lines
2.9 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: mysql
|
|
labels:
|
|
app.kubernetes.io/name: mysql
|
|
app.kubernetes.io/component: database
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: Recreate # MySQL requires Recreate since PVC is ReadWriteOnce
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: mysql
|
|
app.kubernetes.io/component: database
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: mysql
|
|
app.kubernetes.io/component: database
|
|
spec:
|
|
# fsGroup 999 = mysql group in the container image.
|
|
# Without this, the hostPath volume is owned by root and MySQL
|
|
# cannot write to /var/lib/mysql → pod CrashLoops immediately.
|
|
securityContext:
|
|
fsGroup: 999
|
|
containers:
|
|
- name: mysql
|
|
image: mysql:8.0
|
|
ports:
|
|
- containerPort: 3306
|
|
name: mysql
|
|
env:
|
|
- name: MYSQL_ROOT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: MYSQL_ROOT_PASSWORD
|
|
- name: MYSQL_DATABASE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: DB_NAME
|
|
# Allow root to connect from backend pods (any host), not just localhost.
|
|
- name: MYSQL_ROOT_HOST
|
|
value: "%"
|
|
# Create the app user on first init. Required if PVC is ever wiped and
|
|
# MySQL reinitializes — otherwise scrumapp user won't exist and backend fails.
|
|
- name: MYSQL_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: MYSQL_USER
|
|
- name: MYSQL_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: mysql-secret
|
|
key: MYSQL_PASSWORD
|
|
volumeMounts:
|
|
- name: mysql-data
|
|
mountPath: /var/lib/mysql
|
|
resources:
|
|
requests:
|
|
cpu: 250m
|
|
memory: 512Mi
|
|
limits:
|
|
cpu: "1"
|
|
memory: 1Gi
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- sh
|
|
- -c
|
|
- mysqladmin ping -h 127.0.0.1 -u root -p"$MYSQL_ROOT_PASSWORD" --silent
|
|
initialDelaySeconds: 60
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- sh
|
|
- -c
|
|
- mysqladmin ping -h 127.0.0.1 -u root -p"$MYSQL_ROOT_PASSWORD" --silent
|
|
# MySQL 8.0 first-run initialization takes 30-60s on slow disks.
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 5
|
|
timeoutSeconds: 3
|
|
failureThreshold: 10
|
|
volumes:
|
|
- name: mysql-data
|
|
persistentVolumeClaim:
|
|
claimName: mysql-data-pvc
|