(kuberay-volcano)= # KubeRay 与 Volcano 集成 [Volcano](https://github.com/volcano-sh/volcano) 是一个基于Kubernetes构建的批量调度系统。它提供了 Kubernetes 目前缺少的一套机制(组调度、作业队列、公平调度策略),而许多类别的批处理和弹性工作负载通常需要这些机制。 KubeRay 的 Volcano 集成可以在多租户 Kubernetes 环境中更有效地调度 Ray pod。 ## 设置 ### 步骤 1: 使用KinD创建Kubernetes集群 在终端中运行以下命令: ```shell kind create cluster ``` ### 步骤 2: 安装 Volcano 您需要在 Kubernetes 集群上成功安装 Volcano,然后才能启用 Volcano 与 KubeRay 的集成。 有关 Volcano 安装说明,请参阅 [快速入门指南](https://github.com/volcano-sh/volcano#quick-start-guide) 。 ### 步骤 3: 安装具有批量调度功能的 KubeRay Operator 部署 KubeRay Operator 使用 `--enable-batch-scheduler` 标志以启用 Volcano 批量调度支持。 使用 Helm 安装 KubeRay Operator 时,您应该使用以下两个选项之一: * 在你的 [`values.yaml`](https://github.com/ray-project/kuberay/blob/753dc05dbed5f6fe61db3a43b34a1b350f26324c/helm-chart/kuberay-operator/values.yaml#L48) 文件设置 `batchScheduler.enabled` 为 `true` ```shell # values.yaml file batchScheduler: enabled: true ``` * 在命令行上运行时传递 `--set batchScheduler.enabled=true` 标识: ```shell # Install the Helm chart with --enable-batch-scheduler flag set to true helm install kuberay-operator kuberay/kuberay-operator --version 1.0.0-rc.0 --set batchScheduler.enabled=true ``` ### 步骤 4: 使用 Volcano 调度程序安装 RayCluster RayCluster 自定义资源必须包含 `ray.io/scheduler-name: volcano` 标签来将集群 Pod 提交到 Volcano 进行调度的。 ```shell # Path: kuberay/ray-operator/config/samples # Includes label `ray.io/scheduler-name: volcano` in the metadata.labels curl -LO https://raw.githubusercontent.com/ray-project/kuberay/v1.0.0-rc.0/ray-operator/config/samples/ray-cluster.volcano-scheduler.yaml kubectl apply -f ray-cluster.volcano-scheduler.yaml # Check the RayCluster kubectl get pod -l ray.io/cluster=test-cluster-0 # NAME READY STATUS RESTARTS AGE # test-cluster-0-head-jj9bg 1/1 Running 0 36s ``` 您还可以在 RayCluster 元数据中提供以下标签: - `ray.io/priority-class-name`: [Kubernetes](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) 定义的集群优先级 - 该标签仅在创建 `PriorityClass` 资源才有效 - ```shell labels: ray.io/scheduler-name: volcano ray.io/priority-class-name: ``` - `volcano.sh/queue-name`: 集群提交到的 Volcano [queue](https://volcano.sh/en/docs/queue/) 名。 - 该标签仅在创建 `Queue` 资源后才有效 - ```shell labels: ray.io/scheduler-name: volcano volcano.sh/queue-name: ``` 如果启用了自动缩放, `minReplicas` 则用于组调度, 否则 `replicas` 使用所需的。 ### 步骤 5: 使用Volcano进行批量调度 如需指导,请参阅 [示例](https://github.com/volcano-sh/volcano/tree/master/example)。 ## 示例 在执行示例之前,请删除所有正在运行的 Ray Cluster,以确保成功运行下面的示例。 ```shell kubectl delete raycluster --all ``` ### 组调度 此示例演示了群组调度如何与 Volcano 和 KubeRay 配合使用。 首先,创建一个容量为 4 个 CPU 和 6Gi RAM 的队列: ```shell kubectl create -f - <