Ray is an open source framework for building scalable artificial intelligence (AI) and Python applications, and is widely used in machine learning. Deploy a Ray cluster on Container Service for Kubernetes (ACK) to run these applications.
Prerequisites
An ACK managed Pro cluster is created. For more information, see Create an ACK managed cluster.
Cluster version: v1.24 or later. To upgrade the cluster version, see Manually upgrade a cluster.
Node specifications: The cluster contains at least one node with 8 vCPUs and 32 GiB of memory or higher. For information about the instance types that Elastic Compute Service (ECS) supports, see Instance family overview.
The node specifications recommended in this example apply only to test environments. In production environments, choose node specifications based on your actual requirements. To use GPU-accelerated nodes, see Add GPU nodes to a cluster.
You have installed kubectl on your local machine and used it to connect to the Kubernetes cluster. For more information, see Connect to an ACK cluster using kubectl.
The KubeRay Operator add-on is installed. For more information, see Install the KubeRay add-on in ACK.
Deploy the Ray cluster
Create a RayCluster named demo-ray-cluster and check the deployment status.
Create a
ray-cluster.yamlfile with the following content.ImportantThe image (
registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/ray) used in the following sample YAML is for demonstration purposes only, and the Ray version in the sample image may be outdated. In production environments, replace the image based on your requirements, for example, with the latest image from the Ray open source community. For more information, see Shared responsibilities for Ray on ACK.Create the sample RayCluster resource.
kubectl apply -f ray-cluster.yaml
Check the deployment status of the RayCluster and its related resources.
Check the deployment status of the RayCluster.
kubectl get raycluster demo-ray-clusterExpected output:
NAME DESIRED WORKERS AVAILABLE WORKERS CPUS MEMORY GPUS STATUS AGE demo-ray-cluster 1 1 3 6Gi 0 ready 32sCheck the Pods of the RayCluster.
kubectl get podExpected output:
NAME READY STATUS RESTARTS AGE demo-ray-cluster-head-mdvzb 1/1 Running 0 46s demo-ray-cluster-worker-group-worker-c6zvw 1/1 Running 0 46sCheck the Services of the RayCluster.
kubectl get svcExpected output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE demo-ray-cluster-head-svc ClusterIP None <none> 10001/TCP,8265/TCP,6379/TCP,8080/TCP,8000/TCP 56s kubernetes ClusterIP 172.16.0.1 <none> 443/TCP 48d