apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  selector:
    matchLabels:
      app: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mysql
    spec:
      serviceAccountName: mysql
      containers:
      # https://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_ignore-db-dir
      # Ext4, Btrfs etc. volumes root directories have a lost+found directory that should not be treated as a database.
      - args:
        - --ignore-db-dir=lost+found
        - --datadir
        - /var/lib/mysql
        env:
        - name: MYSQL_ALLOW_EMPTY_PASSWORD
          value: "true"
        image: registry.cn-zhangjiakou.aliyuncs.com/kubeflow-zhentian/mysql:5.7
        name: mysql
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: mysql-persistent-storage
        resources:
            requests:
              cpu: 100m
              memory: 800Mi
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
