Skip to content

Documentation for Custom Volumes/Volume Mounts #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/cluster-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>
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/).