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
trainerto push model to gcs andml-helperto load model from gcs)
- set
DOCKER_USERenvironment variable for image registry target (in my casem46f) - update all the
imageuser in themanifestto the value of theDOCKER_USERspecified 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:latestmanifest/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.joblibto 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
demonamespace usingkubectl create namespace demo - assuming you have a secret for GCS, create a secret for
GOOGLE_APPLICATION_CREDENTIALSusingkubectl 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-keysecret inside the kubernetesdemonamespace it will be accessed bysa-mlsvc 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-istiofor quick setup including setting the istio-injection fordemonamespace) - apply the istio manifest using
make apply-istio
the directory structured such that:
manifestcontain all kubernetes configuration file, with the deployment config for each services put in themanifest/<service-folder>/mirroringservices/<service-folder>servicescontain all services code, in this casesa-beto simulate the backend service that will call our ML servicesa-mlthe machine learning service deployed using mlserverml-helperhelper image to load model from GCS to our ml service
trainercontain 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
trainerto see the directory that store the training pipeline example
coming soon. . .
coming soon. . .