Skip to content

Commit

Permalink
csi: support ephemeral volumes with Ceph CSI RBD and CephFS driver
Browse files Browse the repository at this point in the history
This commit make required changes for ceph csi drivers to work with
ephemeral volume support. With ephemeral volume support a user can
specify ephemeral volumes in its pod spec and tie the lifecycle
of the PVC with the POD.

An example POD spec looks like this:

```
kind: Pod
apiVersion: v1
metadata:
  name: csi-rbd-demo-ephemeral-pod
spec:
  containers:
    - name: web-server
      image: docker.io/library/nginx:latest
      volumeMounts:
        - mountPath: "/myspace"
          name: mypvc
  volumes:
    - name: mypvc
      ephemeral:
        volumeClaimTemplate:
          spec:
            accessModes: ["ReadWriteOnce"]
            storageClassName: "rook-ceph-block"
            resources:
              requests:
                storage: 1Gi
```

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
  • Loading branch information
humblec committed Nov 2, 2021
1 parent 33072bf commit dcf522c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Documentation/ceph-csi-drivers.md
Expand Up @@ -3,7 +3,7 @@ title: Ceph CSI
weight: 3200
indent: true
---

{% include_relative branch.liquid %}
# Ceph CSI Drivers

There are two CSI drivers integrated with Rook that will enable different scenarios:
Expand Down Expand Up @@ -92,3 +92,39 @@ kubectl create -f https://raw.githubusercontent.com/csi-addons/volume-replicatio
2. Enable the volume replication controller:
- For Helm deployments see the [csi.volumeReplication.enabled setting](helm-operator.md#configuration).
- For non-Helm deployments set `CSI_ENABLE_VOLUME_REPLICATION: "true"` in operator.yaml

## Ephemeral volume support

The generic ephemeral volume feature adds support for specifying PVCs in the
`volumes` field to indicate a user would like to create a Volume as part of the pod spec.
This feature requires the GenericEphemeralVolume feature gate to be enabled.

For example:

```yaml
kind: Pod
apiVersion: v1
...
volumes:
- name: mypvc
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "rook-ceph-block"
resources:
requests:
storage: 1Gi
```

A volume claim template is defined inside the pod spec which refers to a volume
provisioned and used by the pod with its lifecycle. The volumes are provisioned
when pod get spawned and destroyed at time of pod delete.

Refer to [ephemeral-doc]( https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#generic-ephemeral-volumes )
for more info. Also, See the example manifests for an [RBD ephemeral volume]
(https://github.com/rook/rook/tree/{{ branchName }}/cluster/examples/kubernetes/ceph/csi/rbd/pod-ephemeral.yaml)

This comment has been minimized.

Copy link
@mykaul

mykaul Nov 11, 2021

Contributor

@humblec - this creates broken links, please fix.

This comment has been minimized.

Copy link
@humblec

humblec Nov 11, 2021

Author Contributor

It looks like the build tag (https://github.com/rook/rook/blob/master/Documentation/branch.liquid) is not working properly with {% include_relative branch.liquid %} , that said, even in other instances its broken https://github.com/rook/rook/blob/master/Documentation/ceph-csi-snapshot.md
Cc @travisn @leseb jfyi.

This comment has been minimized.

Copy link
@Madhu-1

Madhu-1 Nov 11, 2021

Member

@humblec do you see anything broken on the website?https://rook.github.io/docs/rook/v1.7/ceph-csi-snapshot.html. #9147 should fix it

This comment has been minimized.

Copy link
@humblec

humblec Nov 11, 2021

Author Contributor

looks like its an oversight from end on other doc, if thats the case above PR is enough.

This comment has been minimized.

Copy link
@humblec

humblec Nov 11, 2021

Author Contributor

ok... looks like there is an issue with build tag parsing..

This comment has been minimized.

Copy link
@travisn

travisn Nov 11, 2021

Member

There are two issues here...

  1. One is that the links need to be on a single line with their text, which is why this link does not render.
  2. The recent rename of rook "master" docs to "latest" has broken many links, i'm investigating...

This comment has been minimized.

Copy link
@Madhu-1
and a [CephFS ephemeral volume](https://github.com/rook/rook/tree/{{ branchName }}/cluster/examples/kubernetes/ceph/csi/cephfs/pod-ephemeral.yaml).

### Prerequisites
Kubernetes version 1.21 or greater is required.
21 changes: 21 additions & 0 deletions cluster/examples/kubernetes/ceph/csi/cephfs/pod-ephemeral.yaml
@@ -0,0 +1,21 @@
kind: Pod
apiVersion: v1
metadata:
name: csi-cephfs-demo-ephemeral-pod
spec:
containers:
- name: web-server
image: docker.io/library/nginx:latest
volumeMounts:
- mountPath: "/myspace"
name: mypvc
volumes:
- name: mypvc
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteMany"]
storageClassName: "rook-cephfs"
resources:
requests:
storage: 1Gi
21 changes: 21 additions & 0 deletions cluster/examples/kubernetes/ceph/csi/rbd/pod-ephemeral.yaml
@@ -0,0 +1,21 @@
kind: Pod
apiVersion: v1
metadata:
name: csi-rbd-demo-ephemeral-pod
spec:
containers:
- name: web-server
image: docker.io/library/nginx:latest
volumeMounts:
- mountPath: "/myspace"
name: mypvc
volumes:
- name: mypvc
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "rook-ceph-block"
resources:
requests:
storage: 1Gi

0 comments on commit dcf522c

Please sign in to comment.