MLOps Workflow with Kubeflow Lecture

Jun 4, 2024

MLOps Workflow with Kubeflow Lecture

Introduction

  • Speaker: Developer Advocate at Cisco
  • Topic: MLOps workflow with Kubeflow
  • GitHub repository holds all materials related to the workflow

Pipeline Overview

  • Deploy Kubeflow on any Kubernetes cluster
  • Create machine learning code using a notebook instance
  • Build Kubeflow Pipeline components
  • Serve the final pre-trained model using KServe
  • Recognition program (digit recognizing) using MNIST dataset

Key Components and Tools

  1. Kubeflow: Manage and orchestrate machine learning tasks on Kubernetes
  2. MinIO: Object storage for data and models
  3. KServe: Model inference server
  4. Jupyter Notebooks: For creating and running machine learning code
  5. TensorFlow/Keras: For model building and training

Steps to Setup and Execute Pipeline

1. Setting up Kubeflow

  • Visit the Kubeflow website for installation information
  • Install Kubeflow on Kubernetes
  • Verify installation by checking namespaces and running pods
  • Access Kubeflow Central Dashboard
    • Use kubectl port-forward to access the dashboard

2. Setting up Jupyter Notebooks in Kubeflow

  • Enable access to Kubeflow pipelines from Jupyter notebooks
    • Edit and apply specific YAML files for access and permissions
  • Launch and connect to a Jupyter Lab instance
  • Interactive Python coding and visualization with Jupyter Notebooks
  • Check and update Python packages (e.g., KFP, KServe)

3. Loading and Exploring Data

  • Use MNIST dataset (digits recognizing)
  • Create functions to load and split data into training and test sets
  • Data preprocessing including normalization
  • Visualize data using matplotlib and other visualization tools

4. Model Building and Training

  • Simple Keras model with sequential layers
  • Compile and train model with training data
  • Save trained model in the preferred format (TensorFlow’s save_model)
  • Store model in MinIO object storage

5. Setting Up MinIO for Object Storage

  • MinIO is installed and used with Kubeflow by default
  • Obtain access keys and configure MinIO
  • Store and retrieve models from MinIO

6. Configuring KServe for Model Serving

  • KServe (formerly KFServing) moved to an external project
  • Necessary configurations to allow access to models stored on MinIO
  • Create InferenceService via YAML or Python SDK
  • Ensure TensorFlow models are versioned correctly for KServe
    • Stored in a directory with a version number (e.g., model/1)

7. Creating and Running Kubeflow Pipelines

  • Define pipeline components for each step of the workflow
  • Component examples: Data Loader, Data Preprocessor, Model Trainer, Model Evaluator, Model Server
  • Compile pipeline and execute runs via Kubeflow dashboard or Python SDK
  • Monitor and visualize pipeline runs, access logs and performance metrics

Demonstration and Testing

  • Simple demonstration using digit recognizer web application
  • Run inference using pre-trained model via web app or Jupyter notebook scripts
    • Visual feedback and accuracy checks

Summary

  • Kubeflow integrates multiple tools and steps to manage the machine learning lifecycle on Kubernetes
  • Each component (data loading, model training, serving) is containerized and scalable
  • The lecture provided hands-on setup and execution details for an end-to-end MLOps workflow using Kubeflow