apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  namespace: food-ai
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: food-ai-mysql:latest
        env:
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: food-ai-secrets
              key: MYSQL_ROOT_PASSWORD
        - name: MYSQL_DATABASE
          value: "food_db"
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql
        - name: my-cnf
          mountPath: /etc/mysql/conf.d
        - name: logs
          mountPath: /logs
        resources:
          limits:
            cpu: "1"
            memory: "1Gi"
          requests:
            cpu: "500m"
            memory: "512Mi"
      volumes:
      - name: mysql-data
        persistentVolumeClaim:
          claimName: mysql-data-pvc
      - name: my-cnf
        configMap:
          name: food-ai-config
          items:
          - key: my.cnf
            path: my.cnf
      - name: logs
        persistentVolumeClaim:
          claimName: logs-pvc
