|
| 1 | +# Testing in Kubernetes |
| 2 | + |
| 3 | +This guide explains how to test DataFusion Ray on Kubernetes during development. It assumes you have an existing Kubernetes cluster. |
| 4 | + |
| 5 | +## 1. Deploy the KubeRay Operator |
| 6 | + |
| 7 | +To manage Ray clusters, you need to deploy the KubeRay operator using Helm. This step is required once per Kubernetes cluster. |
| 8 | + |
| 9 | +```shell |
| 10 | +helm repo add kuberay https://ray-project.github.io/kuberay-helm/ |
| 11 | +helm repo update |
| 12 | + |
| 13 | +# Install the Custom Resource Definitions (CRDs) and KubeRay operator |
| 14 | +helm install kuberay-operator kuberay/kuberay-operator |
| 15 | + |
| 16 | +# Verify that the operator is running in the `default` namespace. |
| 17 | +kubectl get pods |
| 18 | + |
| 19 | +# Example output: |
| 20 | +# NAME READY STATUS RESTARTS AGE |
| 21 | +# kuberay-operator-7fbdbf8c89-pt8bk 1/1 Running 0 27s |
| 22 | +``` |
| 23 | + |
| 24 | +You can customize the operator's settings (e.g., resource limits and requests). For basic testing, the default configuration should suffice. |
| 25 | +For more details and customization options, refer to the [KubeRay Helm Chart documentation](https://github.com/ray-project/kuberay-helm/tree/main/helm-chart/kuberay-operator). |
| 26 | + |
| 27 | +## 2. Build a Custom Docker Image |
| 28 | +You need to build a custom Docker image containing your local development copy of DataFusion Ray rather than using the default PyPi release. |
| 29 | + |
| 30 | +Run the following command to build your Docker image: |
| 31 | + |
| 32 | +```shell |
| 33 | +docker build -t [YOUR_IMAGE_NAME]:[YOUR_TAG] -f k8s/Dockerfile . |
| 34 | +``` |
| 35 | +After building the image, push it to a container registry accessible by your Kubernetes cluster. |
| 36 | + |
| 37 | +## 3. Deploy a RayCluster |
| 38 | +Next, deploy a RayCluster using the custom image. |
| 39 | + |
| 40 | +```shell |
| 41 | +helm repo update |
| 42 | +helm install datafusion-ray kuberay/ray-cluster \ |
| 43 | + --set 'image.repository=[YOUR_REPOSITORY]' \ |
| 44 | + --set 'image.tag=[YOUR_TAG]' \ |
| 45 | + --set 'imagePullPolicy=Always' |
| 46 | +``` |
| 47 | +Make sure you replace *[YOUR_REPOSITORY]* and *[YOUR_TAG]* with your actual container registry and image tag values. |
| 48 | + |
| 49 | +You can further customize RayCluster settings (such as resource allocations, autoscaling, and more). |
| 50 | +For full configuration options, refer to the [RayCluster Helm Chart documentation](https://github.com/ray-project/kuberay-helm/tree/main/helm-chart/ray-cluster). |
| 51 | + |
| 52 | +## 4. Port Forwarding |
| 53 | + |
| 54 | +To access Ray's dashboard, set up port forwarding between your local machine and the Ray cluster's head node: |
| 55 | + |
| 56 | +```shell |
| 57 | +kubectl port-forward service/raycluster-kuberay-head-svc 8265:8265 |
| 58 | +``` |
| 59 | + |
| 60 | +This makes Ray’s dashboard and API available at `http://127.0.0.1:8265`. |
| 61 | + |
| 62 | + |
| 63 | +## 5. Run an Example |
| 64 | +From the examples directory in your project, you can run a sample job using the following commands: |
| 65 | + |
| 66 | +``` |
| 67 | +export RAY_ADDRESS="http://127.0.0.1:8265" |
| 68 | +ray job submit --working-dir ./examples/ -- python3 tips.py |
| 69 | +``` |
| 70 | + |
| 71 | +### Expected output: |
0 commit comments