In this video, we’ll walk you through building a powerful machine learning model using Kubeflow and deploying it seamlessly to KServe with InferenceService!
Click here for full video: click here
- Docker Desktop (on Mac & Windows) or Docker Engine (on Linux)
- Kubectl
- Minikube
- Python Virtual Environment (venv) - optional
- kfp
- AWS IAM User (with S3 privileges)
- AWS S3 Bucket
- Custom Domain Name (DNS)
- Helm
t3.2xlarge with 8 cpus, 32 GiB Memory, 80 GiB Storage -> $0.33 per hour
chmod 600 <keypair>
ssh -i <keypair> ubuntu@<PublicIP>- Port 22: ssh
- Port 80, 443: http & https
- Port 8443: Kubernetes API
- Port 8080: Kubeflow Dashboard
- Port 30000-32767: Kubernetes NodePort Service
- Port 5000, 8081, 9000: KServe Model Serving
- Port 31390: KServe Inference
- Port 31380: Kubeflow Ingress Gateway
sudo apt update && apt upgrade -ysudo apt-get update && sudo apt-get install docker.io -y
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp dockersudo snap install kubectl --classic
kubectl version --client # Verify installationpython3 --version
pip --version
sudo apt install python3-pip -y
sudo apt install python3.12-venv -y
python3 -m venv path/to/venv
path/to/venv/bin/python --version
path/to/venv/bin/pip --version
source path/to/venv/bin/activatecurl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
minikube versionminikube start --cpus=4 --memory=10240 --driver=docker
kubectl get nodes
kubectl cluster-infowhich kfp
path/to/venv/bin/pip install kfpexport PIPELINE_VERSION=2.4.0
kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/cluster-scoped-resources?ref=$PIPELINE_VERSION"
kubectl wait --for condition=established --timeout=60s crd/applications.app.k8s.io
kubectl apply -k "github.com/kubeflow/pipelines/manifests/kustomize/env/platform-agnostic?ref=$PIPELINE_VERSION"kubectl get all -n kubeflowkubectl port-forward -n kubeflow svc/ml-pipeline-ui 8080:80kubectl port-forward -n kubeflow svc/ml-pipeline-ui 8080:80 &cd Downloads
ssh -i <keypair> -L 8080:localhost:8080 -N ubuntu@<Public_ip>localhost:8080source path/to/venv/bin/activate
touch pipeline.py
path/to/venv/bin/python pipeline.py
path/to/venv/bin/kfp pipeline create -p IrisProject pipeline.yaml- IAM -> Create User -> Attach Policy directly (AmazonS3FullAccess) -> Create User
- Click on Newly Created User -> Create Access Keys -> CLI -> Create Access Keys -> Download .csv file -> Done
- Configure AWS User on local terminal with Access Key ID & Secret Key ID using "aws configure"
Create S3 Bucket on AWS (or use an already existing bucket) S3 -> Create bucket -> General purpose -> Name: kubeflow-bucket-iquant01 -> Keep all default selections -> Create bucket
Create on Pipeline name -> Create run -> Provide Details -> etc
Provide all the details including
Access key id, Secret access key, S3 bucket name, S3 key Start the pipeline.
Inspect the bucket for the trained ML model (.joblib file)
sudo snap install helm --classiccurl -s "https://raw.githubusercontent.com/kserve/kserve/release-0.14/hack/quick_install.sh" | bashkubectl get pods -n kserve
kubectl get pods -n istio-system
kubectl get pods -n knative-servingminikube addons enable ingresskubectl get pods -n ingress-nginxminikube tunnelminikube ipkubectl get svc istio-ingressgateway -n istio-systemexport INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')kubectl create namespace kserve-testkubectl apply -n kserve-test -f - <<EOF
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "sklearn-iris"
spec:
predictor:
model:
modelFormat:
name: sklearn
storageUri: "gs://kfserving-examples/models/sklearn/1.0/model"
EOFkubectl get inferenceservices sklearn-iris -n kserve-testkubectl get svc istio-ingressgateway -n istio-systemkubectl get isvc sklearn-iris -n kserve-testcat <<EOF > "./iris-input.json"
{
"instances": [
[6.8, 2.8, 4.8, 1.4],
[6.0, 3.4, 4.5, 1.6]
]
}
EOFSERVICE_HOSTNAME=$(kubectl get inferenceservice sklearn-iris -n kserve-test -o jsonpath='{.status.url}' | cut -d "/" -f 3)
curl -v -H "Host: ${SERVICE_HOSTNAME}" -H "Content-Type: application/json" "http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/sklearn-iris:predict" -d @./iris-input.jsonCtrl + C -> To EXIT minikube tunnel
kubectl delete isvc sklearn-iris -n kserve-testminikube stop
minikube delete --all