Skip to content

Commit 66153fb

Browse files
committed
Documentation for Custom Volumes/Volume Mounts
1 parent 20476aa commit 66153fb

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Diff for: docs/cluster-configuration.md

+51
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,60 @@ cluster = Cluster(ClusterConfiguration(
2222
image="quay.io/project-codeflare/ray:latest-py39-cu118", # Mandatory Field
2323
machine_types=["m5.xlarge", "g4dn.xlarge"],
2424
labels={"exampleLabel": "example", "secondLabel": "example"},
25+
volumes=[], # See Custom Volumes/Volume Mounts
26+
volume_mounts=[], # See Custom Volumes/Volume Mounts
2527
))
2628
```
2729

2830
The `labels={"exampleLabel": "example"}` parameter can be used to apply additional labels to the RayCluster resource.
2931

3032
After creating their`cluster`, a user can call `cluster.up()` and `cluster.down()` to respectively create or remove the Ray Cluster.
33+
34+
## Custom Volumes/Volume Mounts
35+
To add custom Volumes and Volume Mounts to your Ray Cluster you need to create two lists `volumes` and `volume_mounts`.
36+
The lists consist of `V1Volume` and `V1VolumeMount` objects respectively.<br>
37+
Populating these parameters will create Volumes and Volume Mounts for the head and each worker pod.
38+
39+
Below is an example of how a user would create these lists using the Python Kubernetes Library.
40+
41+
```python
42+
from kubernetes.client import V1Volume, V1VolumeMount, V1EmptyDirVolumeSource, V1ConfigMapVolumeSource, V1KeyToPath, V1SecretVolumeSource
43+
# In this example we are using the Config Map, EmptyDir and Secret Volume types
44+
volume_mounts_list = [
45+
V1VolumeMount(
46+
mount_path="/home/ray/test1",
47+
name = "test"
48+
),
49+
V1VolumeMount(
50+
mount_path = "/home/ray/test2",
51+
name = "test2",
52+
),
53+
V1VolumeMount(
54+
mount_path = "/home/ray/test3",
55+
name = "test3",
56+
)
57+
]
58+
59+
volumes_list = [
60+
V1Volume(
61+
name="test",
62+
empty_dir=V1EmptyDirVolumeSource(size_limit="2Gi"),
63+
),
64+
V1Volume(
65+
name="test2",
66+
config_map=V1ConfigMapVolumeSource(
67+
name="test-config-map",
68+
items=[V1KeyToPath(key="test", path="data.txt")]
69+
)
70+
),
71+
V1Volume(
72+
name="test3",
73+
secret=V1SecretVolumeSource(
74+
secret_name="test-secret"
75+
)
76+
)
77+
]
78+
```
79+
80+
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)).
81+
You can also find further information on Volumes and Volume Mounts by visiting the Kubernetes [documentation](https://kubernetes.io/docs/concepts/storage/volumes/).

0 commit comments

Comments
 (0)