This project demonstrates how to run a distributed Python task using the Ray framework on a Kubernetes cluster. It uses a Helm chart to deploy a Ray Head node, Worker nodes, and a Job submitter.
app/: Contains the Python application code (main.py) which calculates Pi using the Monte Carlo method.chart/: A Helm chart to deploy the Ray cluster and the job.Dockerfile: Defines the container image for the application.
- Docker
- Kubernetes Cluster (Minikube, Kind, or Cloud Provider)
kubectlhelm
Build docker image, and push to ACR
./push_img.sh <tag>Deploy chart
./deploy_chart.sh <tag> [--local]For cloud clusters, push the image to a container registry.
# Replace with your registry
docker build -t <your-registry>/ray-distributed-job:latest .
docker push <your-registry>/ray-distributed-job:latestRELEASE_NAME=ray-distributed-job
helm install $RELEASE_NAME ./chart \
--set image.repository=ray-distributed-job \
--set image.tag=latest \
--set image.pullPolicy=IfNotPresentRELEASE_NAME=ray-distributed-job
helm install $RELEASE_NAME ./chart \
--set image.repository=<your-registry>/ray-distributed-job \
--set image.tag=latest \
--set image.pullPolicy=Always-
Check Pods: Ensure the head, workers, and submitter pods are running.
Expected output:
Connecting to Ray at ... Starting Monte Carlo Pi estimation ... Estimated Pi: 3.14159...
To remove the deployment:
helm uninstall $RELEASE_NAME