this repository assume that you have basic knowledge on Docker and Python and intended for learning purposes
- Install Docker
- Create a Dockerhub account (or any container registry)
- install kubectl
- install istioctl (for the gateway)
- (for Scheduling with Airflow) install helm
- for local development you can install Minikube
- Google Cloud Storage account (for
trainer
to push model to gcs andml-helper
to load model from gcs)
- set
DOCKER_USER
environment variable for image registry target (in my casem46f
) - update all the
image
user in themanifest
to the value of theDOCKER_USER
specified above (for example if your user isalice
) from:to:manifest/sa-ml/deployment.yaml:31: image: m46f/mlops-demo-ml-helper:latest manifest/sa-ml/deployment.yaml:49: image: m46f/mlops-demo-sa-ml:latest manifest/sa-be/deployment.yaml:24: - image: m46f/mlops-demo-sa-be:latest
manifest/sa-ml/deployment.yaml:31: image: alice/mlops-demo-ml-helper:latest manifest/sa-ml/deployment.yaml:49: image: alice/mlops-demo-sa-ml:latest manifest/sa-be/deployment.yaml:24: - image: alice/mlops-demo-sa-be:latest
- upload
model_chace/text-clf.joblib
to your storage (for this example we use google storage) and update the value insidemanifest/sa-ml/deployment.yaml:41:
from"gs://morgana-mlops/demo/text-clf.joblib"
to your GCS path - have a kubernetes cluster running
- create a
demo
namespace usingkubectl create namespace demo
- assuming you have a secret for GCS, create a secret for
GOOGLE_APPLICATION_CREDENTIALS
usingkubectl create secret -n demo generic google-app-key --from-file=secret.json=<path-to-your-secret-file.json>
this will store your secret asgoogle-app-key
secret inside the kubernetesdemo
namespace it will be accessed bysa-ml
svc defined involumeMounts: - name: model-volume mountPath: "/models" - name: google-cloud-keys mountPath: /var/secrets/google readOnly: true env: - name: GOOGLE_APPLICATION_CREDENTIALS value: /var/secrets/google/secret.json
- setup istio https://istio.io/latest/docs/setup/install/istioctl/ (or you can use
make setup-istio
for quick setup including setting the istio-injection fordemo
namespace) - apply the istio manifest using
make apply-istio
the directory structured such that:
manifest
contain all kubernetes configuration file, with the deployment config for each services put in themanifest/<service-folder>/
mirroringservices/<service-folder>
services
contain all services code, in this casesa-be
to simulate the backend service that will call our ML servicesa-ml
the machine learning service deployed using mlserverml-helper
helper image to load model from GCS to our ml service
trainer
contain the training pipeline to be used by the airflow dags
outside this repository: a repo for the airflow dags
├── Makefile #contain helper command
├── manifest #kubernetes configuration
│ ├── airflow
│ │ └── rbac.yaml
│ ├── istio
│ │ ├── http-gateway.yaml
│ │ └── vs-route-ingress.yaml
│ ├── sa-be
│ │ ├── deployment.yaml
│ │ └── service.yaml
│ └── sa-ml
│ ├── deployment.yaml
│ └── service.yaml
├── README.MD
├── services
│ ├── ml-helper
│ │ ├── Dockerfile
│ │ └── start.sh
│ ├── sa-be
│ │ ├── app
│ │ │ └── main.py
│ │ ├── Dockerfile
│ │ ├── Makefile
│ │ └── requirements.txt
│ └── sa-ml
│ ├── Dockerfile
│ ├── Makefile
│ ├── models
│ ├── model-settings.json
│ └── requirements.txt
└── trainer
└── text-trainer
├── Dockerfile
├── Makefile
├── requirements.txt
└── worker
├── gcs.py
└── main.py
to build an Image you can use make build svc=<service-folder>
for example make build svc=sa-ml
to deploy a service you can execute make deploy svc=<service-folder> ns=<namespace>
for example: make deploy svc=sa-ml ns=demo
- the repository for the dags is here
- go to
trainer
to see the directory that store the training pipeline example
coming soon. . .
coming soon. . .