ML Deployment K8S Fastapi

This project shows how to serve an ONNX-optimized image classification model as a web service with FastAPI, Docker, and Kubernetes.

Blockchain & Cloud ComputingJupyter NotebookApache-2.0

Abstract

ML Deployment K8S Fastapi is an open-source Blockchain & Cloud Computing project. This project shows how to serve an ONNX-optimized image classification model as a web service with FastAPI, Docker, and Kubernetes. It is built using Jupyter Notebook, Docker, FastAPI, Kubernetes, TensorFlow. The complete source code is publicly available on GitHub under the Apache License 2.0, making it a useful reference for students building a Blockchain & Cloud Computing mini project or final-year project.

1. Introduction

This project shows how to serve an ONNX-optimized image classification model as a RESTful web service with FastAPI, Docker, and Kubernetes (k8s). The idea is to first Dockerize the API and then deploy it on a k8s cluster running on Google Kubernetes Engine (GKE). We do this integration using GitHub Actions.

relevant resource. We used 8 nodes (each with 2 vCPUs and 4 GBs of RAM) for the cluster.

service account key (JSON) file. It's a good practice to only grant it the roles required for the project. For example, for this project, we created a fresh service account and granted it permissions for the following: Storage Admin, GKE Developer, and GCR Developer.

2. Objective

This project shows how to serve an ONNX-optimized image classification model as a web service with FastAPI, Docker, and Kubernetes.

This project demonstrates how Jupyter Notebook, Docker, FastAPI can be applied to a real-world Blockchain & Cloud Computing problem.

4. Technology Stack

Jupyter NotebookDockerFastAPIKubernetesTensorFlow

5. System Requirements

General requirements for this technology stack — check the README for exact versions.

  • Python 3.8 or later with Jupyter Notebook / JupyterLab (or Google Colab)
  • pip for dependencies
  • Git (to clone the repository)

6. Installation & Setup

git clone https://github.com/sayakpaul/ml-deployment-k8s-fastapi.git
cd ml-deployment-k8s-fastapi
  1. We decouple the model optimization part from our API code. The optimization part is
  2. Then we locally test the API. You can find the instructions within the api
  3. To deploy the API, we define our deployment.yaml workflow file inside .github/workflows.
  4. Looks for any changes in the specified directory. If there are any changes:
  5. Builds and pushes the latest Docker image to Google Container Register (GCR).
  6. Deploys the Docker container on the k8s cluster running on GKE.

Full setup instructions are in the project README.

7. Future Enhancements

Suggested extensions you can add to make this your own project.

  • Add a CI/CD pipeline with GitHub Actions
  • Deploy to a public test network or cloud free tier
  • Add monitoring and cost alerts

8. Viva / Review Questions

Common questions examiners ask for projects in this domain.

  1. Why does this problem need a blockchain or cloud-native design?
  2. Explain the smart contract / infrastructure components and how they interact.
  3. How are gas costs or cloud costs kept under control?
  4. How is the system secured (keys, IAM, access control)?
  5. How would the solution scale to many more users?

9. Source Code & License

This project is developed by sayakpaul and published on GitHub under the Apache License 2.0. Please follow the license terms and credit the original author when you use or modify this code.

Want to build this as your internship project?

Work on a Blockchain & Cloud Computing project like this with mentor guidance, weekly reviews and an internship certificate from Training Trains, Erode — online or offline.

Apply for Blockchain & Cloud Computing Internship