Skip to content

Almarch/mini-mlflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini-MLflow

A Minikube-based MLflow stack.

Set-up

Access the repo:

git clone https://github.com/almarch/mini-mlflow.git
cd mini-mlflow

The following toolbox is needed:

brew install minikube kubectl k9s helm
sudo apt-get update && sudo apt-get install -y docker.io

The k8s instance may then be turned on and off:

minikube start -p my-mlflow \
    --driver=docker \
    --memory=6144 \
    --cpus=4 \
    --disk-size=50g \
    --mount \
    --mount-string="$(pwd)/notebook:/mnt/data/notebook"

minikube stop -p my-mlflow
minikube start -p my-mlflow

Generate all secrets:

echo "POSTGRES_MLFLOW_PASSWORD=$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c 16)" > .env
echo "MINIO_ROOT_PASSWORD=$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c 16)" >> .env
echo "MINIO_MLFLOW_PASSWORD=$(openssl rand -base64 24 | tr -dc 'A-Za-z0-9' | head -c 16)" >> .env

And forward them to k8s:

kubectl create secret generic mlflow-secrets \
  --from-env-file=.env \
  --dry-run=client -o yaml > k8s/secrets.yaml
kubectl apply -f k8s/secrets.yaml

Ingress needs to be activated:

minikube addons enable ingress -p my-mlflow

MLflow is light enough and can be built locally then pushed to the cluster:

docker build -t mlflow:latest -f Dockerfile.mlflow .
minikube image load mlflow:latest -p my-mlflow

The notebook is too heavy and must be built from within the cluster:

eval $(minikube -p my-mlflow docker-env)
docker build -t notebook:latest -f Dockerfile.notebook .
eval $(minikube docker-env -u)

Load and deploy all services:

kubectl apply -f k8s/minio
kubectl apply -f k8s/postgres
kubectl apply -f k8s/mlflow
kubectl apply -f k8s/notebook

The host must allow access to the dedicated services:

IP=$(minikube ip -p my-mlflow)
echo $IP
sudo sh -c "echo \"$IP mlflow.local notebook.local\" >> /etc/hosts"
tail -n 2 /etc/hosts

If using the WSL2, you may need to install & use a browser from the WSL so that it properly uses /etc/hosts declaration:

firefox http://notebook.local/

The cluster may then be monitored using k9s:

k9s

About

A minikube MLflow stack

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published