When running stateful applications on Kubernetes, it is essential to ensure persistence of the underlying volumes. Without persistence, application data is lost whenever a Pod is restarted or updated. Ondat can provide persistent volumes in a Kubernetes-native way while ensuring maximum performance, availability and resilience for the applications you're running, regardless of whether you're on-premise or in the cloud.
Kubernetes provides a Persistent Volume subsystem that abstracts details of how storage is provided from how it is consumed and Ondat can power this subsystem using nearly any underlying storage system.
Ondat provides cloud native storage for Kubernetes used for provisioning Persistent Volumes. Get started in three easy steps:
- Establish that you have all the prerequisites for Ondat
- Install Ondat to the platform of your choice
- Create your first Ondat
PersistentVolumeClaim
as described below
Ondat Kubernetes Persistent Volume Guide
As a simple first use of Ondat with Kubernetes, following the example below will create a PersistentVolumeClaim (PVC) and schedule a Pod to mount the PersistentVolume (PV) provisioned by the PVC. You can read more about Ondat and Kubernetes best practices in our docs.
Creating a PersistentVolumeClaim
-
You can find many examples in the Ondat deployment repository
git clone https://github.com/storageos/deploy.git storageos
PVC definition:
The above PVC will dynamically provision a 5GB volume using the
StorageClass definition:fast
StorageClass. We will create this StorageClass with some additional parameters to enable encryption. -
Creating a PVC using this StorageClass causes Ondat to provision a PersistentVolume.
The above PVC has the
storageos.com/replicas
label set. This label tells Ondat to create a replica for the volume that is created. For the sake of keeping this example simple, we will use the non-replicated PVC from step 1 in the next step. - Move into the examples folder, setup the
StorageClass
and create a PVC using the PVC definition above.$ cd storageos
$ kubectl create -f ./k8s/examples/000-storageclass.yaml $ kubectl create -f ./k8s/examples/pvc.yamlYou can view the PVC that you have created with the command below
$ kubectl get pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE my-vol-1 Bound pvc-f8ffa027-e821-11e8-bc0b-0ac77ccc61fa 5Gi RWO fast 1m - Create a pod that mounts the PVC created in step 2.
$ kubectl create -f ./k8s/examples/debian-pvc.yaml
The command above creates a Pod that uses the PVC that was created in step 1.
In thePod
definition above, the volumev1
references the PVC created in step 2. The volume is mounted in the pod at/mnt
. In this example, adebian
image is used for the container but any container image with a shell would work. - Confirm that the pod is up and running
$ kubectl get pods NAME READY STATUS RESTARTS AGE d1 1/1 Running 0 1m
- Enter a shell inside the container and write some contents to a file
$ kubectl exec -it d1 -- bash [email protected]:/# echo "Hello World!" > /mnt/helloworld [email protected]:/# cat /mnt/helloworld Hello World!
When writing to/mnt
inside the container, the same data is written to the underlying StorageOS volume created by the PVC. If you were to kill the pod and start it again on a new node, thehelloworld
file would still be available.