Use ephemeral volumes in OCP IBM Cloud
Summary and Key concepts
Summary:
This article details how to create and use generic ephemeral volumes with the Portworx CSI Driver. It explains that ephemeral volumes support standard storage operations such as snapshotting, cloning, resizing, and capacity tracking. A step-by-step example is provided to create a pod that utilizes a Portworx CSI-backed ephemeral volume through a volumeClaimTemplate
in the pod spec. The article also notes that PVCs created using Kubernetes' native driver cannot be migrated to the CSI driver, but both can co-exist in the same cluster.
Kubernetes Concepts:
- Ephemeral Volume: A type of volume that is temporary and exists only for the lifecycle of the pod.
- Pod: The smallest deployable unit in Kubernetes, representing a running process.
- PersistentVolumeClaim (PVC): A request for storage by a user.
- StorageClass: A specification for dynamic storage provisioning in Kubernetes.
- volumeClaimTemplate: Defines storage claims dynamically created for each pod in Kubernetes.
Portworx Concepts:
- Portworx CSI Driver: Implements the CSI specification to expose Portworx storage for ephemeral volumes.
- CSI Enabled Storage Classes: Predefined storage classes provided by Portworx for CSI-enabled deployments.
Generic Ephemeral volumes
Generic ephemeral volumes also work with typical storage operations such as snapshotting, cloning, resizing, and storage capacity tracking.
The following steps will allow you to create a generic ephemeral volume with the Portworx CSI Driver.
In this example we are using the px-csi-db
storage class out of the box. Please refer CSI Enabled Storage Classes for a list of available CSI enabled storage classes offered by Portworx.
-
Create a pod spec that uses a Portworx CSI Driver StorageClass, declaring the ephemeral volume as seen below in a YAML file named
ephemeral-volume-pod.yaml
:kind: Pod
apiVersion: v1
metadata:
name: my-app
spec:
containers:
- name: my-frontend
image: busybox
volumeMounts:
- mountPath: "/scratch"
name: scratch-volume
command: [ "sleep", "1000000" ]
volumes:
- name: scratch-volume
ephemeral:
volumeClaimTemplate:
metadata:
labels:
type: my-frontend-volume
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "px-csi-db"
resources:
requests:
storage: 1Gi -
Apply the
ephemeral-volume-pod.yaml
spec to create the pod with a generic ephemeral volume:oc apply -f ephemeral-volume-pod.yaml
Migration to CSI PVCs
Currently, you cannot migrate or convert PVCs created using the native Kubernetes driver to the CSI driver. However, this is not required, and both types of PVCs can co-exist on the same cluster.