---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: katib-mysql
  namespace: kubeflow
  labels:
    katib.kubeflow.org/component: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      katib.kubeflow.org/component: mysql
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        katib.kubeflow.org/component: mysql
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      containers:
        - name: katib-mysql
          image: mysql:8.0.29
          args:
            - --datadir
            - /var/lib/mysql/datadir
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: katib-mysql-secrets
                  key: MYSQL_ROOT_PASSWORD
            - name: MYSQL_ALLOW_EMPTY_PASSWORD
              value: "true"
            - name: MYSQL_DATABASE
              value: "katib"
          ports:
            - name: dbapi
              containerPort: 3306
          readinessProbe:
            exec:
              command:
                - "/bin/bash"
                - "-c"
                - "mysql -D ${MYSQL_DATABASE} -u root -p${MYSQL_ROOT_PASSWORD} -e 'SELECT 1'"
            initialDelaySeconds: 10
            periodSeconds: 5
            failureThreshold: 10
          livenessProbe:
            exec:
              command:
                - "/bin/bash"
                - "-c"
                - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
            initialDelaySeconds: 10
            periodSeconds: 5
            failureThreshold: 10
          startupProbe:
            exec:
              command:
                - "/bin/bash"
                - "-c"
                - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
            periodSeconds: 15
            failureThreshold: 60
          volumeMounts:
            - name: katib-mysql
              mountPath: /var/lib/mysql
      volumes:
        - name: katib-mysql
          persistentVolumeClaim:
            claimName: katib-mysql
