Skip to content

Commit

Permalink
rbd: add generic ephemeral volume validation
Browse files Browse the repository at this point in the history
This commit adds the validation of csi RBD driver 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: my-app
   spec:
  containers:
    - name: csi-rbd-demo-pod
      image: busybox
      volumeMounts:
        - mountPath: "/scratch"
          name: mypvc
      command: [ "sleep", "1000000" ]
  volumes:
    - name: mypvc
      ephemeral:
        volumeClaimTemplate:
          spec:
            accessModes: [ "ReadWriteOnce" ]
            storageClassName: "csi-rbd-sc"
            resources:
              requests:
                storage: 1Gi

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
  • Loading branch information
humblec committed Oct 29, 2021
1 parent de57fa1 commit 7830dcf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
23 changes: 23 additions & 0 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var (
appClonePath = rbdExamplePath + "pod-restore.yaml"
appSmartClonePath = rbdExamplePath + "pod-clone.yaml"
appBlockSmartClonePath = rbdExamplePath + "block-pod-clone.yaml"
appEphemeralPath = rbdExamplePath + "pod-ephemeral.yaml"
snapshotPath = rbdExamplePath + "snapshot.yaml"
defaultCloneCount = 10

Expand Down Expand Up @@ -367,6 +368,28 @@ var _ = Describe("RBD", func() {
}
})
}
By("verify ephemeral volume support", func() {
// create application
app, err := loadApp(appEphemeralPath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
}
app.Namespace = f.UniqueName
err = createApp(f.ClientSet, app, deployTimeout)
if err != nil {
e2elog.Failf("failed to create application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1, defaultRBDPool)

err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
if err != nil {
e2elog.Failf("failed to delete application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0, defaultRBDPool)
})

// todo: may be remove the below deletion test later once the migration nodestage tests are adjusted
// also to have deletion validation through the same.
By("validate RBD migration+static Block PVC Deletion", func() {
Expand Down
22 changes: 22 additions & 0 deletions examples/rbd/pod-ephemeral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
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: "csi-rbd-sc"
resources:
requests:
storage: 1Gi

0 comments on commit 7830dcf

Please sign in to comment.