The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.
If you like or are using this project to learn or start your solution, please give it a star. Thanks!
This example demonstrates how to schedule Machine Learning Model building process for Spam and Sentiment ML.NET models.
The idea is that ML.NET model is not stale and would have the input of a new datapoints
and would require the rebuild of the model at the eve of each day.
The sample was designed to be run Kubernetes Cluster in two ways:
-
As
.NET Core Worker
(this would require a consistent memory allocation). This also demonstratesworker
tcp based health check for the pod. The schedule is based on CronScheduler. -
As a Cron Job (preferred usage). The execution schedule is based on Kubernetes
This sample is fully containerized to be used as:
- As stand-alone Docker container that runs application every 30 min interval. It utilizes
TcpListener
for Pod health checks. - As Kubernetes CronJob with interval specified in the deployment which is once a day at 1:00am.
- Azure Blob storage has to have permission for MSI access as
Storage Blob Data Contributor
Testing K8 Cron Job in the local cluster please follow the setup instruction per K8.DotNetCore.Workshop.
Make sure to execute all of the commands from the solution folder.
- Build the Image
# builds and runs the container
docker-compose -f "docker-compose.yml" -f "docker-compose.override.yml" up -d bet.hosting
# simply builds the image
docker-compose -f "docker-compose.yml" up -d --build --no-recreate bet.hosting
# publish if needed
docker push kdcllc/bet:hosting
- Helm Install
# install cron job
helm install betcronjob k8s/bethosting/charts/betcronjob --set aadpodidbinding=[msiId],local.enabled=false
# delete cron job
helm uninstall betcronjob
# install worker pod
helm install betworker k8s/bethosting/charts/betworker --set aadpodidbinding=[msiId],local.enabled=false
# delete worker deployment
helm uninstall betworker
Or
- Install with Kubernetes
Installing simple yaml deployment for cron job:
# https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: mlmodelbuilder-job
spec:
schedule: "*/5 * * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 2
jobTemplate:
spec:
template:
spec:
containers:
- name: mlmodelbuilder-job
image: kdcllc/bet:hosting
command: ["./Bet.Hosting.Sample"]
env:
- name: MSI_ENDPOINT
value: http://host.docker.internal:5050/oauth2/token
- name: MSI_SECRET
value: 1c791bd8-94e7-468f-97f3-4b46a1d0aea5
args:
- "--runAsCronJob=true"
restartPolicy: OnFailure
-
Install
kubectl apply -f "cronjob.yaml"
-
Remove
kubectl delete -f "cronjob.yaml"
RunConsoleAsync
– Enables console supportUseConsoleLifetime
– Listens for shutdown signals