Kubeflow Orchestrator
How to orchestrate pipelines with Kubeflow
The Kubeflow orchestrator is an orchestrator flavor provided with the ZenML kubeflow integration that uses Kubeflow Pipelines to run your pipelines.

When to use it

You should use the Kubeflow orchestrator if:
  • you're looking for a proven production-grade orchestrator.
  • you're looking for a UI in which you can track your pipeline runs.
  • you're already using Kubernetes or are not afraid of setting up and maintaining a Kubernetes cluster.
  • you're willing to deploy and maintain Kubeflow Pipelines on your cluster.

How to deploy it

The Kubeflow orchestrator supports two different modes: Local and remote. In case you want to run the orchestrator on a local Kubernetes cluster running on your machine, there is no additional infrastructure setup necessary.
If you want to run your pipelines on a remote cluster instead, you'll need to set up a Kubernetes cluster and deploy Kubeflow Pipelines:
AWS
GCP
Azure
  • Have an existing AWS EKS cluster set up.
  • Make sure you have the AWS CLI set up.
  • Download and install kubectl and configure it to talk to your EKS cluster using the following command:
    aws eks --region REGION update-kubeconfig --name CLUSTER_NAME
  • Install Kubeflow Pipelines onto your cluster.
  • Have an existing GCP GKE cluster set up.
  • Make sure you have the Google Cloud CLI set up first.
  • Download and install kubectl and configure it to talk to your GKE cluster using the following command:
    gcloud container clusters get-credentials CLUSTER_NAME
  • Install Kubeflow Pipelines onto your cluster.
  • Have an existing AKS cluster set up.
  • Make sure you have the az CLI set up first.
  • Download and install kubectl and it to talk to your AKS cluster using the following command:
    az aks get-credentials --resource-group RESOURCE_GROUP --name CLUSTER_NAME
  • Install Kubeflow Pipelines onto your cluster.
Since Kubernetes v1.19, AKS has shifted
. However, the workflow controller installed with the Kubeflow installation has Docker set as the default runtime. In order to make your pipelines work, you have to change the value to one of the options
listed here
, preferably k8sapi.
This change has to be made by editing the containerRuntimeExecutor property of the ConfigMap corresponding to the workflow controller. Run the following commands to first know what config map to change and then to edit it to reflect your new value.
kubectl get configmap -n kubeflow
kubectl edit configmap CONFIGMAP_NAME -n kubeflow
# This opens up an editor that can be used to make the change.
If one or more of the deployments are not in the Running state, try increasing the number of nodes in your cluster.
If you're installing Kubeflow Pipelines manually, make sure the Kubernetes service is called exactly ml-pipeline. This is a requirement for ZenML to connect to your Kubeflow Pipelines deployment.

How to use it

To use the Kubeflow orchestrator, we need:
  • The ZenML kubeflow integration installed. If you haven't done so, run
    zenml integration install kubeflow
  • Docker installed and running.
  • kubectl installed.
Local
Remote
When using the Kubeflow orchestrator locally, you'll additionally need
The local Kubeflow Pipelines deployment requires more than 2 GB of RAM, so if you're using Docker Desktop make sure to update the resource limits in the preferences.
We can then register the orchestrator and use it in our active stack:
zenml orchestrator register <NAME> \
--flavor=kubeflow
# Add the orchestrator to the active stack
zenml stack update -o <NAME>
When using the Kubeflow orchestrator with a remote cluster, you'll additionally need
  • Kubeflow pipelines deployed on a remote cluster. See the deployment section for more information.
  • The name of your Kubernetes context which points to your remote cluster. Run kubectl config get-contexts to see a list of available contexts.
  • A remote artifact store as part of your stack.
  • A remote metadata store as part of your stack. Kubeflow Pipelines already comes with its own MySQL database that is deployed in your Kubernetes cluster. If you want to use this database as your metadata store to get started quickly, check out the corresponding documentation page. For a more production-ready setup we suggest using a MySQL metatadata store instead.
  • A remote container registry as part of your stack.
We can then register the orchestrator and use it in our active stack:
zenml orchestrator register <NAME> \
--flavor=kubeflow \
--kubernetes_context=<KUBERNETES_CONTEXT>
# Add the orchestrator to the active stack
zenml stack update -o <NAME>
ZenML will build a Docker image called zenml-kubeflow which includes your code and use it to run your pipeline steps in Kubeflow. Check out this page if you want to learn more about how ZenML builds these images and how you can customize them.
If you decide you need the full flexibility of having a custom base image, you can update your existing orchestrator
zenml orchestrator update <NAME> \
--custom_docker_base_image_name=<IMAGE_NAME>
or set it when registering a new Kubeflow orchestrator:
zenml orchestrator register <NAME> \
--flavor=kubeflow \
--custom_docker_base_image_name=<IMAGE_NAME>
Once the orchestrator is part of the active stack, we need to run zenml stack up before running any pipelines. This command
  • forwards a port so you can view the Kubeflow UI in your browser.
  • (in the local case) uses K3D to provision a Kubernetes cluster on your machine and deploys Kubeflow Pipelines on it.
You can now run any ZenML pipeline using the Kubeflow orchestrator:
python file_that_runs_a_zenml_pipeline.py
A concrete example of using the Kubeflow orchestrator can be found here.
For more information and a full list of configurable attributes of the Kubeflow orchestrator, check out the API Docs.