Prerequisite

You need a Ubuntu Linux to do this.

An Ubuntu in Virtual Machine is okay.

Video Tutorial

YouTube

Instructions

  1. Install docker
sudo apt install docker.io
# start docker daemon
sudo systemctl start docker
  1. Install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start
  1. Train the model

Install dependencies first

sudo apt install python3-pip
pip install tensorflow numpy mnist keras

create train.py file.

train the model

python3 train.py
  1. Create an API service

Install FastAPI dependencies

pip install fastapi "uvicorn[standard]" Pillow

create api.py file.

  1. Build Docker image

First create an account on Docker Hub

And Create a repository called digitreader.

Notice that zigzigcheers shown below is my Docker Hub account name, be sure to replace it with your account name

docker build -t zigzigcheers/digitreader:v1 .

test if it works

docker run -d -p 8080:8080  zigzigcheers/digitreader:v1 

ok, let's push it to Docker Hub

docker push zigzigcheers/digitreader:v1
  1. Deploy to Kubernetes Cluster
kubectl create deployment digitreader --image=zigzigcheers/digitreader:v1
kubectl expose deployment digitreader --type=LoadBalancer --port=8080
  1. Next steps

Using AWS service to make it better