ray-cluster

by CodeScriptum

Helm chartv1.8.0

A Helm chart for deploying the RayCluster with the kuberay operator.

About this chart

RayCluster

A Helm chart for deploying the RayCluster with the kuberay operator.

Homepage: https://github.com/ray-project/kuberay

Introduction

RayCluster is a custom resource definition (CRD). KubeRay operator will listen to the resource events about RayCluster and create related Kubernetes resources (e.g. Pod & Service). Hence, KubeRay operator installation and CRD registration are required for this guide.

Prerequisites

See kuberay-operator/README.md for more details.

  • Helm
  • Install custom resource definition and KubeRay operator (covered by the following end-to-end example.)

End-to-end example

# Step 1: Create a KinD cluster
kind create cluster

# Step 2: Register a Helm chart repo
helm repo add kuberay https://ray-project.github.io/kuberay-helm/

# Step 3: Install both CRDs and KubeRay operator v1.8.0.
helm install kuberay-operator kuberay/kuberay-operator --version 1.8.0

# Step 4: Install a RayCluster custom resource
# (For x86_64 users)
helm install raycluster kuberay/ray-cluster --version 1.8.0
# (For arm64 users, e.g. Mac M1)
# See here for all available arm64 images: https://hub.docker.com/r/rayproject/ray/tags?page=1&name=aarch64
helm install raycluster kuberay/ray-cluster --version 1.8.0 --set image.tag=nightly-aarch64

# Step 5: Verify the installation of KubeRay operator and RayCluster
kubectl get pods
# NAME                                          READY   STATUS    RESTARTS   AGE
# kuberay-operator-6fcbb94f64-gkpc9             1/1     Running   0          89s
# raycluster-kuberay-head-qp9f4                 1/1     Running   0          66s
# raycluster-kuberay-worker-workergroup-2jckt   1/1     Running   0          66s

# Step 6: Forward the port of Dashboard
kubectl port-forward svc/raycluster-kuberay-head-svc 8265:8265

# Step 7: Check 127.0.0.1:8265 for the Dashboard

# Step 8: Log in to Ray head Pod and execute a job.
kubectl exec -it ${RAYCLUSTER_HEAD_POD} -- bash
python -c "import ray; ray.init(); print(ray.cluster_resources())" # (in Ray head Pod)

# Step 9: Check 127.0.0.1:8265/#/job. The status of the job should be "SUCCEEDED".

# Step 10: Uninstall RayCluster
helm uninstall raycluster

# Step 11: Verify that RayCluster has been removed successfully
# NAME                                READY   STATUS    RESTARTS   AGE
# kuberay-operator-6fcbb94f64-gkpc9   1/1     Running   0          9m57s

Values

KeyTypeDefaultDescription
image.repositorystring"rayproject/ray"Image repository.
image.tagstring"2.52.0"Image tag.
image.pullPolicystring"IfNotPresent"Image pull policy.
nameOverridestring"kuberay"String to partially override release name.
fullnameOverridestring""String to fully override release name.
imagePullSecretslist[]Secrets with credentials to pull images from a private registry
upgradeStrategyobject{}Recreate all Pods on RayCluster spec change. Intended for GitOps; running workloads are lost.
authOptionsobject{}Token authentication for the RayCluster.
gcsFaultTolerance.enabledboolfalse
common.containerEnvlist[]containerEnv specifies environment variables for the Ray head and worker containers. Follows standard K8s container env schema.
common.envFromlist[]envFrom specifies sources used to populate environment variables in the main Ray head and worker containers. Common sources are rendered before group-specific sources. Referenced ConfigMaps and Secrets must already exist.
head.initContainerslist[]Init containers to add to the head pod
head.labelsobject{}Labels for the head pod
head.serviceAccountNamestring""
head.restartPolicystring""
head.runtimeClassNamestring""runtimeClassName is the name of the RuntimeClass to use to run the head Pod.
head.containerEnvlist[]
head.envFromlist[]envFrom to pass to head pod
head.resources.limits.cpustring"1"
head.resources.limits.memorystring"5Gi"
head.resources.requests.cpustring"1"
head.resources.requests.memorystring"5Gi"
head.resourceClaimslist[]ResourceClaims to allocate with the head pod
head.annotationsobject{}Extra annotations for head pod
head.nodeSelectorobject{}Node labels for head pod assignment
head.tolerationslist[]Node tolerations for head pod scheduling to nodes with taints
head.affinityobject{}Head pod affinity
head.podSecurityContextobject{}Head pod security context.
head.securityContextobject{}Ray container security context.
head.volumes[0].namestring"log-volume"
head.volumes[0].emptyDirobject{}
head.volumeMounts[0].mountPathstring"/tmp/ray"
head.volumeMounts[0].namestring"log-volume"
head.sidecarContainerslist[]
head.commandlist[]
head.argslist[]
head.headServiceobject{}
head.topologySpreadConstraintslist[]
head.rayStartParamsobject{}
worker.groupNamestring"workergroup"The name of the workergroup
worker.replicasint1The number of replicas for the worker pod
worker.minReplicasint1The minimum number of replicas for the worker pod
worker.maxReplicasint5The maximum number of replicas for the worker pod
worker.labelsobject{}Labels for the worker pod
worker.serviceAccountNamestring""
worker.restartPolicystring""
worker.runtimeClassNamestring""runtimeClassName is the name of the RuntimeClass to use to run the worker Pods.
worker.initContainerslist[]Init containers to add to the worker pod
worker.containerEnvlist[]
worker.envFromlist[]envFrom to pass to worker pod
worker.resources.limits.cpustring"1"
worker.resources.limits.memorystring"1Gi"
worker.resources.requests.cpustring"1"
worker.resources.requests.memorystring"1Gi"
worker.resourceClaimslist[]ResourceClaims to allocate with the worker pod
worker.annotationsobject{}Extra annotations for worker pod
worker.nodeSelectorobject{}Node labels for worker pod assignment
worker.tolerationslist[]Node tolerations for worker pod scheduling to nodes with taints
worker.affinityobject{}Worker pod affinity
worker.podSecurityContextobject{}Worker pod security context.
worker.securityContextobject{}Ray container security context.
worker.volumes[0].namestring"log-volume"
worker.volumes[0].emptyDirobject{}
worker.volumeMounts[0].mountPathstring"/tmp/ray"
worker.volumeMounts[0].namestring"log-volume"
worker.sidecarContainerslist[]
worker.commandlist[]
worker.argslist[]
worker.topologySpreadConstraintslist[]
worker.rayStartParamsobject{}
additionalWorkerGroups.smallGroup.disabledbooltrue
additionalWorkerGroups.smallGroup.replicasint0The number of replicas for the additional worker pod
additionalWorkerGroups.smallGroup.minReplicasint0The minimum number of replicas for the additional worker pod
additionalWorkerGroups.smallGroup.maxReplicasint5The maximum number of replicas for the additional worker pod
additionalWorkerGroups.smallGroup.labelsobject{}Labels for the additional worker pod
additionalWorkerGroups.smallGroup.serviceAccountNamestring""
additionalWorkerGroups.smallGroup.restartPolicystring""
additionalWorkerGroups.smallGroup.runtimeClassNamestring""runtimeClassName for this additional worker group. Empty string means default runtime.
additionalWorkerGroups.smallGroup.containerEnvlist[]
additionalWorkerGroups.smallGroup.envFromlist[]envFrom to pass to additional worker pod
additionalWorkerGroups.smallGroup.resources.limits.cpuint1
additionalWorkerGroups.smallGroup.resources.limits.memorystring"1Gi"
additionalWorkerGroups.smallGroup.resources.requests.cpuint1
additionalWorkerGroups.smallGroup.resources.requests.memorystring"1Gi"
additionalWorkerGroups.smallGroup.resourceClaimslist[]ResourceClaims to allocate with the additional worker pod
additionalWorkerGroups.smallGroup.annotationsobject{}Extra annotations for additional worker pod
additionalWorkerGroups.smallGroup.nodeSelectorobject{}Node labels for additional worker pod assignment
additionalWorkerGroups.smallGroup.tolerationslist[]Node tolerations for additional worker pod scheduling to nodes with taints
additionalWorkerGroups.smallGroup.affinityobject{}Additional worker pod affinity
additionalWorkerGroups.smallGroup.podSecurityContextobject{}Additional worker pod security context.
additionalWorkerGroups.smallGroup.securityContextobject{}Ray container security context.
additionalWorkerGroups.smallGroup.volumes[0].namestring"log-volume"
additionalWorkerGroups.smallGroup.volumes[0].emptyDirobject{}
additionalWorkerGroups.smallGroup.volumeMounts[0].mountPathstring"/tmp/ray"
additionalWorkerGroups.smallGroup.volumeMounts[0].namestring"log-volume"
additionalWorkerGroups.smallGroup.sidecarContainerslist[]
additionalWorkerGroups.smallGroup.commandlist[]
additionalWorkerGroups.smallGroup.argslist[]
additionalWorkerGroups.smallGroup.topologySpreadConstraintslist[]
additionalWorkerGroups.smallGroup.rayStartParamsobject{}
service.typestring"ClusterIP"

Deploy ray-cluster with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ray-cluster on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartray-cluster is pinned at v1.8.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply