Skip to content

MLOps Pipeline

Please review the overview section to understand details about the end-to-end MLOps pipeline you will implement in the steps below.


Step 1: Login

In this step, you will login to your MLOps Platform.

  • Navigate to the URL (This will be provided by your platform team)
  • Login using your local credentials or SSO credentials (Identity Provider such as Okta)

Login

Once logged in, you will see the home dashboard screen.

Dashboard


Step 2: Create a Notebook

In this step, you will create a Jupyter Notebook. The Rafay MLOps platform based on Kubeflow provides a way to use notebooks to create Pipelines in such a way that each step in the Pipeline runs in its own container.

ML orchestration in Kubeflow is done through Pipelines. A Pipeline is a multi-step workflow in which each step is run in its own container—with a special way for data and objects to flow between them. This allows containers to be reused over different Pipelines with extra code written. When Kubeflow Pipelines runs a Component, a container image is spawned in a Kubernetes Pod and the component’s inputs are passed in as command-line arguments. When the component has finished, its outputs are returned as files. These input arguments and output files are known as artifacts.

In this step, we will use our notebook to convert our Python code based pipeline into a Kubeflow Pipelines–compatible code.

  • Navigate to Notebooks
  • Click New Notebook
  • Enter a name for the notebook
  • Select JupyterLab
  • Select kubeflownotebookswg/jupyter-scipy:v1.8.0 for the custom notebook
  • Set the minimum CPU to 1
  • Set the minimum memory to 1
  • Click Advanced Options under Data Volumes
  • Select Configurations -> Allow access to Kubeflow Pipelines
  • Click Launch

Launch

It will take 1-2 minutes to create the notebook.

Launch


Step 3: Generate Pipeline

In this step, you will build a model life cycle pipeline.

  • Navigate to Notebooks
  • Click Connect on the previously created notebook
  • Click Terminal to open the terminal

Terminal

  • Enter the following command in the terminal to install kfp-kubernetes
pip install --user kfp-kubernetes
  • Download the following notebook file
  • In the left hand folder tree, click on the upload files icon
  • Upload the previously downloaded demo-notebook.ipynb file
  • Double click the demo-notebook.ipynb file in the folder tree to open the notebook
  • Click the run icon
  • Click the refresh icon in the folder tree view and you will see a new file named demo-pipeline.yaml
  • Right click on the file and select Download to download the file to to your local machine

Pipeline

Note

The file you downloaded is the Kubeflow Pipelines–compatible code generated from our Python code.


Step 4: Create Pipeline

In this step, we will use the pipeline YAML file generated in a previous step and load it in.

  • Navigate back to the Kubeflow dashboard
  • Click Pipelines
  • Click Upload pipeline
  • Enter a name for the pipeline
  • Select Upload a file
  • Click Choose file and select the previously downloaded demo-pipeline.yaml file
  • Click Create

Pipeline

  • Click Experiments (KFP)
  • Click Create experiment
  • Enter a name for the experiment
  • Click Next

Experiment

Now, we will run the pipeline.

  • Click Choose on the Pipeline section and select the previously created pipeline
  • Click Choose on the Experiment section and select the previously created experiment
  • Enter /data for the data_path parameter
  • Click Start

Pipeline

The pipeline will begin to run. After ~10 minutes, you should see the pipeline completed successfully.

Pipeline


Step 5: Model Registry

In this step, we will look at the newly created model's details that would have been uploaded to the integrated MLflow based model registry.

  • Navigate back to the Kubeflow dashboard
  • Click MlFlow
  • Click new-exp

You will see the newly created model.

Model

Note

If you updated the name of the experiment in the pipeline code, please select the appropriate name instead.

  • Click on the model name for more details

Model


Step 6: Model Serving

In this step, you will review the endpoints that were created to serve the newly created model.

  • Navigate back to the Kubeflow dashboard
  • Click Endpoints

Endpoints

  • Click on the name of the endpoint

You will see the model is being served on the URLs listed. Note that the model is automatically retrieved from the integrated MLFlow based model registry.

Endpoints

  • Copy the URL internal
  • Update the internal URL in the command below and run the shell commands to generate the inference URL
INTERNAL_URL='UPDATE_VALUE'
INF_NAME="$(echo "${INTERNAL_URL}" | cut -d '.' -f1 | cut -d '/' -f3-)"
INFERENCE_URL="${INTERNAL_URL}/v2/models/${INF_NAME}/infer"
echo "${INFERENCE_URL}"
  • Save the inference URL for the next step

Step 7: Test Application

In this step, you will create and deploy a test application that will use the inference endpoint that was created in the prior step for model serving. The Rafay platform provides data scientists and researchers extremely intuitive workflows to deploy and test applications on their organization's Kubernetes clusters.

Create Namespace

Your application will be deployed to a namespace in the same Kubernetes cluster where the Inference service is operating. Your administrator should have already created a Kubernetes namespace for you and provided you with at least namespace admin privileges.

If you do not have a namespace or if you have administrative privileges in Rafay, you can do this yourself by following the steps below:

  • Log into the Rafay console
  • Navigate to Infrastructure -> Namespaces
  • Click Create Namespace
  • Enter a name for the new namespace
  • Select Wizard for the type
  • Click Save & Go To Placement
  • Select the cluster where Kubeflow is installed
  • Click Save &Go To Publish
  • Click Publish

Deploy Workload

Next, create and deploy a workload to the namespace to test our inference service.

  • Navigate to Applications -> Workloads
  • Click New Workload -> Create New Workload
  • Enter a name for the workload
  • Select K8s YAML for the package type
  • Select Upload files manually
  • Select the namespace being used for your Notebook
  • Click Continue

Workload

  • Download the following application spec file
  • Update line 34 with the previously generated Inference URL
  • Click Choose File to upload the updated file
  • Click Save and Go to Placement

Workload

  • Select the cluster where Kubeflow is running
  • Click Save and go to Publish
  • Click Publish

Workload

  • Navigate to Infrastructure -> Clusters
  • Click KUBECTL on the cluster where Kubeflow is running
  • Enter the following command to retrieve the EXTERNAL IP address of the application. Be sure to update the namespace with the namespace where the application was deployed
kubectl get service/iris-web-app-service -n <UPDATE_VALUE>
  • Enter the IP address into a web browser to access the application. Note, this is an HTTP only site.

Application

The user can update the sepal and Petal values and then click the predict button. This application is internally using the KServe inference service endpoint that was generated earlier on by the pipeline


Recap

Congratulations! At this point, you have successfully created a Jupyter notebook which used a pipeline to create a data model and expose and inference server that was then used by a sample web application.