|
| 1 | +# Ray Cluster Configuration |
| 2 | + |
| 3 | +To create Ray Clusters using the CodeFlare SDK a cluster configuration needs to be created first.<br> |
| 4 | +This is what a typical cluster configuration would look like; Note: The values for CPU and Memory are at the minimum requirements for creating the Ray Cluster. |
| 5 | + |
| 6 | +``` |
| 7 | +from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration |
| 8 | +
|
| 9 | +cluster = Cluster(ClusterConfiguration( |
| 10 | + name='ray-example', # Mandatory Field |
| 11 | + namespace='default', # Default None |
| 12 | + head_cpus=1, # Default 2 |
| 13 | + head_memory=1, # Default 8 |
| 14 | + head_gpus=0, # Default 0 |
| 15 | + num_workers=1, # Default 1 |
| 16 | + min_cpus=1, # Default 1 |
| 17 | + max_cpus=1, # Default 1 |
| 18 | + min_memory=2, # Default 2 |
| 19 | + max_memory=2, # Default 2 |
| 20 | + num_gpus=0, # Default 0 |
| 21 | + mcad=True, # Default True |
| 22 | + image="quay.io/project-codeflare/ray:latest-py39-cu118", # Mandatory Field |
| 23 | + instascale=False, # Default False |
| 24 | + machine_types=["m5.xlarge", "g4dn.xlarge"], |
| 25 | + ingress_domain="example.com" # Default None, Mandatory for Kubernetes Clusters |
| 26 | +)) |
| 27 | +``` |
| 28 | + |
| 29 | +Upon creating a cluster configuration with `mcad=True` an appwrapper will be created featuring the Ray Cluster and any Routes, Ingresses or Secrets that are needed to be created along side it.<br> |
| 30 | +From there a user can call `cluster.up()` and `cluster.down()` to create and remove the appwrapper thus creating and removing the Ray Cluster. |
| 31 | + |
| 32 | +In cases where `mcad=False` a yaml file will be created with the individual Ray Cluster, Route/Ingress and Secret included.<br> |
| 33 | +The Ray Cluster and service will be created by KubeRay directly and the other components will be individually created. |
| 34 | + |
| 35 | +## Ray Cluster Configuration in a Kubernetes environment |
| 36 | +To create a Ray Cluster using the CodeFlare SDK in a Kubernetes environment an `ingress_domain` must be passed in the Cluster Configuration. |
| 37 | +This is used for the creation of the Ray Dashboard and Client ingresses. |
| 38 | + |
| 39 | +`ingress_options` can be passed to create a custom Ray Dashboard ingress, `ingress_domain` is still a required variable for the Client ingress. |
| 40 | +An example of `ingress_options` would look like this. |
| 41 | + |
| 42 | +``` |
| 43 | +ingress_options = { |
| 44 | + "ingresses": [ |
| 45 | + { |
| 46 | + "ingressName": "<ingress_name>", |
| 47 | + "port": <port_number>, |
| 48 | + "pathType": "<path_type>", |
| 49 | + "path": "<path>", |
| 50 | + "host":"<host>", |
| 51 | + "annotations": { |
| 52 | + "foo": "bar", |
| 53 | + "foo": "bar", |
| 54 | + } |
| 55 | + } |
| 56 | + ] |
| 57 | +} |
| 58 | +``` |
0 commit comments