Run an MLFlow project in less than 5 minutes on Kubernetes with K3ai

Alessandro Festa
4 min readNov 5, 2021

Four Steps to deploy an entire AI Infrastructure Stack to learn or run your CI/CD pipelines.

“Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.” — Alan Perils.

Photo by Xavi Cabrera on Unsplash

Introduction

One of the greatest hurdles in learning AI is how to play with some of its tools.

In the majority of cases you’ll end up stumbling upon a Jupiter Notebooks or a python script that you’ll eventually have to execute against your Kubernetes cluster…no wait against what?

Oh you mean we forgot that our super-simple example has a ton of requirements you never heard of?

Like:

  • You’ll need a Kubernetes cluster and our super simple manifest…
  • Download and configure Helm and run this chart…. But not to worry it will be super easy just do these 200 steps before…

Yeah, you may use minikube,microk8s,kubeadm, or whatever…oh yeah those are super simple right but did I tell you’ll need other dependencies like kubectl, helm or simply have knowledge of everything after you installed those tools?? Also did You get the right version of those?
Your goal is to focus on AI but this approach implies learning the basics of infrastructure even before be able to deploy the AI tools you are interested in and obviously you’ll stumble upon all the possible errors and mistakes…

So here’s the deal:
Can we make it simpler? Yes we can

Photo by Jackson Simmer on Unsplash

Enter the Use Case

Alex is a curious person and wants to learn some machine learning. He found MLFlow and believe is what he would like to start. Looking at the documentation he found out that could run it as a python library either in Conda or in a docker image (that needs to be built) or directly on his laptop.
That’s great but Alex is a DevOps that try to become an MLOp so he already knows that his “target” will be Kubernetes.
Alex goal is ideally to get a flow that looks like this:

  1. Kubernetes deployment

2. MLFlow deployment (on K8s?)

3. Take a public example of MLFlow and run it against the newly deployed MLFLow server

All without having to worry about infrastructure, deployment, manifest,etc..

The first problem is that the “local” solutions like minikube or microk8s are great but Alex want something more flexible, maybe something even not necessarily local.

Alex know a simple, lightweight tool that allow him to experiment.

The tool is named K3ai.

Using K3ai he knows he may create a Kubernetes cluster, deploy the AI tools of choice and finally execute the code for the training but even better becasue K3ai works on any upstream K8s it could be easily embedded in Alex CI/CD environment later.

So here’s the step that everyone may follow to get Alex use case done.

Step 1 — K3ai Configuration

First things first right?

Let’s download K3ai on our Linux machine:

curl -sfL https://get.k3ai.in | sh -

or simply watch the video:

Ok we got K3ai installed now let’s move on into the configuration.

k3ai up

or, again let’s watch the video:

Step 2 — Deploy a Cluster

Nothing is more easier that deploy a full K8s cluster

k3ai cluster deploy --type k3s --name mycluster

Yep that’s and one may even choose between options, check them out with:

k3ai cluster list --all

Let’s watch the cluster deployment:

Step 3 — Deploy MLFLow

Okay, the cluster is up and we did not have to learn anything if not simply a single one command but let’s deploy MLFLow on our newly created cluster.

k3ai plugin deploy --name mlflow --target mycluster

And as for the clusters let’s check the plugin list with:

k3ai plugin list --all

Oh, by the way, was the plugin did complete? Yes, so you may login at http://<YOUR LAPTOP IP>:3500

okay let’s recap this step with a video:

Step 4 — Run our code on it

So what are we going to run? How about the xgboost tutorial from MLFLOW here?

Well to make your life super easy K3ai as a quickstart clone of it here

So let’s simply type:

k3ai run --source https://github.com/k3ai/quickstart --backend mlflow --target mycluster

Wait for a minute or so, now worried K3ai will tell you once has done everything and check your MLFLOW ui…you’ll thank me as Alex did it!

Not yet convinced let me show it to you:

Yep 4 steps, training your code with the tool of your choice, now one may really say that learn AI is super simple!.

K3ai is an open source project maintained by a single person so if you enjoyed what you just read and you like the idea please add a star to the project it means a lot for me! Check the project at https://github.com/k3ai/k3ai

--

--

Alessandro Festa

猿も木から落ちる。 (Saru mo ki kara ochiru) = (Everyone makes mistakes). @me = { [(blog) + (tweet)]/Co-Author#K3aiProject}