From 7c880171e405d2de526b948fbe1573996a57e7fb Mon Sep 17 00:00:00 2001 From: Bobbins228 Date: Fri, 14 Jun 2024 12:09:09 +0100 Subject: [PATCH] Documentation for Custom Volumes/Volume Mounts --- docs/cluster-configuration.md | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/cluster-configuration.md b/docs/cluster-configuration.md index ae6cd2ead..dbed44238 100644 --- a/docs/cluster-configuration.md +++ b/docs/cluster-configuration.md @@ -22,9 +22,60 @@ cluster = Cluster(ClusterConfiguration( image="quay.io/project-codeflare/ray:latest-py39-cu118", # Mandatory Field machine_types=["m5.xlarge", "g4dn.xlarge"], labels={"exampleLabel": "example", "secondLabel": "example"}, + volumes=[], # See Custom Volumes/Volume Mounts + volume_mounts=[], # See Custom Volumes/Volume Mounts )) ``` The `labels={"exampleLabel": "example"}` parameter can be used to apply additional labels to the RayCluster resource. After creating their`cluster`, a user can call `cluster.up()` and `cluster.down()` to respectively create or remove the Ray Cluster. + +## Custom Volumes/Volume Mounts +To add custom Volumes and Volume Mounts to your Ray Cluster you need to create two lists `volumes` and `volume_mounts`. +The lists consist of `V1Volume` and `V1VolumeMount` objects respectively.
+Populating these parameters will create Volumes and Volume Mounts for the head and each worker pod. + +Below is an example of how a user would create these lists using the Python Kubernetes Library. + +```python +from kubernetes.client import V1Volume, V1VolumeMount, V1EmptyDirVolumeSource, V1ConfigMapVolumeSource, V1KeyToPath, V1SecretVolumeSource +# In this example we are using the Config Map, EmptyDir and Secret Volume types +volume_mounts_list = [ + V1VolumeMount( + mount_path="/home/ray/test1", + name = "test" + ), + V1VolumeMount( + mount_path = "/home/ray/test2", + name = "test2", + ), + V1VolumeMount( + mount_path = "/home/ray/test3", + name = "test3", + ) +] + +volumes_list = [ + V1Volume( + name="test", + empty_dir=V1EmptyDirVolumeSource(size_limit="2Gi"), + ), + V1Volume( + name="test2", + config_map=V1ConfigMapVolumeSource( + name="test-config-map", + items=[V1KeyToPath(key="test", path="data.txt")] + ) + ), + V1Volume( + name="test3", + secret=V1SecretVolumeSource( + secret_name="test-secret" + ) + ) +] +``` + +For more information on creating Volumes and Volume Mounts with Python check out the Python Kubernetes docs ([Volumes](https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Volume.md), [Volume Mounts](https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1VolumeMount.md)). +You can also find further information on Volumes and Volume Mounts by visiting the Kubernetes [documentation](https://kubernetes.io/docs/concepts/storage/volumes/).