https://github.com/grigorkh/fastapi-ml-deployment-template
This repository provides a complete example of serving a machine learning model with FastAPI, containerizing it using Docker, and deploying it on Kubernetes.
https://github.com/grigorkh/fastapi-ml-deployment-template
api docker fastapi fastapi-template kubernetes ml mlops python
Last synced: 5 months ago
JSON representation
This repository provides a complete example of serving a machine learning model with FastAPI, containerizing it using Docker, and deploying it on Kubernetes.
- Host: GitHub
- URL: https://github.com/grigorkh/fastapi-ml-deployment-template
- Owner: grigorkh
- Created: 2025-06-15T14:08:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-22T14:34:07.000Z (about 1 year ago)
- Last Synced: 2025-07-20T15:38:20.645Z (11 months ago)
- Topics: api, docker, fastapi, fastapi-template, kubernetes, ml, mlops, python
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI ML Deployment Template
This repository provides a complete example of serving a machine learning model with FastAPI, containerizing it using Docker, and deploying it on Kubernetes.
## 🧠Features
- ✅ FastAPI app with `/predict` endpoint
- ✅ Real scikit-learn model (Iris dataset)
- ✅ Lightweight Dockerfile with best practices
- ✅ Kubernetes manifests: Deployment, Service, HPA, Ingress
- ✅ Ready for production and educational use
## 📖 Related Medium Articles
- Part 1: [Serving ML Models with FastAPI](https://grigorkh.medium.com/serving-ml-models-with-fastapi-a-production-ready-api-in-minutes-b5f4839a33a9)
- Part 2: [Dockerizing Your FastAPI ML App](https://grigorkh.medium.com/dockerizing-your-fastapi-ml-app-from-script-to-container-5dcc28d3a6c0)
- Part 3: [Deploying Your ML API on Kubernetes - Comming Soon](https://grigorkh.medium.com/)
## 🚀 Quickstart
1. Clone the repo:
```
git clone https://github.com/your-username/fastapi-ml-deployment-template.git
```
2. Train the model:
```
python model/train_model.py
```
3. Build the Docker image:
```
docker build -t your-dockerhub-username/fastapi-ml:latest .
```
4. Push it to Docker Hub (detailed guide coming soon).
5. Apply Kubernetes manifests:
```
kubectl apply -f k8s/
```
6. Test the endpoint:
```
curl -X POST http://localhost:8000/predict -H "Content-Type: application/json" -d '{"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2}'
```
---
## 📄 License
MIT