KubeRay#

KubeRay is an open source toolkit to run Ray applications on Kubernetes. It provides tools to improve running and managing Ray on Kubernetes.

  • Ray Operator

  • Backend services to create/delete cluster resources

  • Kubectl plugin/CLI to operate CRD objects

  • Native Job and Serving integration with Clusters

Installation#

To install the Ray plugin, run the following command:

pip install flytekitplugins-ray

To enable the plugin in the backend, follow instructions outlined in the K8s Operator guide.

Submit a Ray Job to Existing Cluster#

@ray.remote
def f(x):
    return x * x

@task(task_config=RayJobConfig(
    address=<RAY_CLUSTER_ADDRESS>
    runtime_env={"pip": ["numpy", "pandas"]})
)
def ray_task() -> typing.List[int]:
    futures = [f.remote(i) for i in range(5)]
    return ray.get(futures)

Create a Ray Cluster Managed by Flyte and Run a Ray Job on This Cluster#

@task(task_config=RayJobConfig(worker_node_config=[WorkerNodeConfig(group_name="test-group", replicas=10)])
def ray_task() -> typing.List[int]:
    futures = [f.remote(i) for i in range(5)]
    return ray.get(futures)

Gallery generated by Sphinx-Gallery