Deploy MLflow server in Kubernetes with MySQL and S3/MinIO

Deploy MLflow server in Kubernetes with MySQL and S3/MinIO

Welcome to my ultimate guide for deploying the MLflow server in Kubernetes. Follow along as I outline the step-by-step process, including setting up MySQL and MinIO services in Kubernetes for database and artifact storage. If you're eager to launch an MLFlow server in Kubernetes with ease, you've landed in the perfect spot. I'll show you how to effortlessly configure an MLflow server within your Kubernetes environment, complete with MySQL for efficient data management and S3/MinIO for optimal storage solutions. Let's dive in and get your MLflow journey started!

Step 1: Create and Push Docker Image

Create your docker image using the Dockerfile provided in the link. Alternatively, you can pull the image directly from my dockerhub repository.

  • Build Docker image
docker build -t shettymanish01/mlflow:0.0.1 MLFlow/.
  • Push image to registry
docker push shettymanish01/mlflow:0.0.1

Step 2: Create PVC

Create PVCs for MySQL and Minio deployments using the pvc.yaml file. You can adjust the storage requirements based on your needs.

kubectl apply -f k8s/pvc.yaml

Step 3: Create and Apply Secrets

secret.yaml is an example file with base64-encoded values for Minio and MySQL. Replace the placeholder values with your actual secrets.

You can use online tools or command-line utilities to base64 encode your secrets. For example, to encode a string in Linux or macOS, you can use the echo command:

echo -n "mysecret" | base64

After modifying the secret.yaml file, you can apply it to your Kubernetes cluster using the kubectl apply command:

kubectl apply -f k8s/secret.yaml

Step 4: Deploying MySQL database in Kubernetes

mysql.yaml is a basic example YAML file for deploying MySQL in a Kubernetes cluster. Ensure you have already created the PVC (Persistent Volume Claim) for MySQL, as mentioned in step 2.

To deploy MySQL to your Kubernetes cluster, use the following command:

kubectl apply -f k8s/mysql.yaml

This will create a MySQL deployment with one replica, using the specified image and environment variables. Adjust the configuration based on your specific needs and security requirements.

Step 5: Deploying MinIO in Kubernetes

Use the file minio.yaml to deploy a minio server which works similar to s3. The MinIO deployment is configured with persistent storage and secured using base64-encoded secrets. It has two services, one for the MinIO Console and another for the MinIO API. Additionally, ingress resources enable access to the MinIO Console at minioconsole.com and the MinIO API at minioapi.com.

To deploy MinIO to your Kubernetes cluster, use the following command:

kubectl apply -f k8s/minio.yaml

Step 6: Deploying MLflow in Kubernetes

Here is a simplified mlflow.yaml file for deploying MLflow in a Kubernetes cluster. Note that you might need to adjust configurations based on your specific environment and requirements. The deployment is configured to use MySQL as the backend store and MinIO (S3-compatible) as the artifact store. The setup is fine-tuned for accessibility and security, with CORS support and proxy timeout settings. The MLflow service is exposed via an Ingress resource, allowing seamless integration into your machine learning workflows. This comprehensive deployment ensures a streamlined and efficient environment for managing end-to-end machine learning processes.

To deploy MLflow to your Kubernetes cluster, use the following command:

kubectl apply -f k8s/mlflow.yaml

If you've followed the steps outlined above, congratulations! You should now have a fully deployed MLflow server accessible on the host you've configured. Additionally, you can view the MinIO server console by navigating to the URL specified in the MinIO Ingress resource for the console.

Your MLflow server is now ready to streamline your machine learning workflows, providing a centralized platform for managing the end-to-end machine learning lifecycle. Feel free to explore and interact with MLflow's features on your configured host.

For easy access, you can also check the MinIO server console using the URL defined in the MinIO Ingress resource for the console. This provides visibility into your object storage settings and enables further management of your MLflow artifacts.

Please feel free to comment if you have any questions or if there's anything specific you'd like assistance with. Your feedback is valuable, and I'm here to help!

With everything set up, you're now equipped to efficiently manage your machine learning experiments and data within your Kubernetes environment. Happy experimenting!