How To Create Pvc In Kubernetes
Create Kubernetes Persistent Volume
Kubernetes provides a Persistent Volume subsystem that abstracts details of how storage is provided from how it is consumed. You still need to provide the underlying storage system. Ondat provides cloud native storage for Kubernetes used for provisioning Persistent Volumes. Get started in four steps: 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 details about Ondat and Kubernetes best practices at our docs. $ kubectl get pvc
Ondat Kubernetes Persistent Volume Guide
Creating the PersistentVolumeClaim
git clone https://github.com/storageos/deploy.git storageos
PVC definition
apiVersion : v1 kind : PersistentVolumeClaim metadata : name : my-vol-1 spec : storageClassName : " fast" accessModes : - ReadWriteOnce resources : requests : storage : 5Gi
The above PVC will dynamically provision a 5GB volume using the fast StorageClass. This StorageClass was created during the Ondat install and causes Ondat to provision a PersistentVolume.
apiVersion : v1 kind : PersistentVolumeClaim metadata : name : my-vol-1 labels : storageos.com/replicas : " 1" spec : storageClassName : " fast" accessModes : - ReadWriteOnce resources : requests : storage : 5Gi
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, the unreplicated volume will be used.
$ cd storageos $ kubectl create -f ./k8s/examples/pvc.yaml
You can view the PVC that you have created with the command below
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE my-vol-1 Bound pvc-f8ffa027-e821-11e8-bc0b-0ac77ccc61fa 5Gi RWO fast 1m
$ kubectl create -f ./k8s/examples/debian-pvc.yaml
The command above creates a Pod that uses the PVC that was created in step 1.
apiVersion : v1 kind : Pod metadata : name : d1 spec : containers : - name : debian image : debian:9-slim command : [ " /bin/sleep" ] args : [ " 3600" ] volumeMounts : - mountPath : /mnt name : v1 volumes : - name : v1 persistentVolumeClaim : claimName : my-vol-1
In the Pod definition above the volume v1, which references the PVC created in step 2, is mounted in the pod at /mnt. In this example, a debian image is used for the container but any container image with a shell would work for this example.
$ kubectl get pods NAME READY STATUS RESTARTS AGE d1 1/1 Running 0 1m
By writing to /mnt inside the container, the StorageOS volume created by the PVC is being written to. If you were to kill the pod and start it again on a new node, the helloworld file would still be available.
How To Create Pvc In Kubernetes
Source: https://www.ondat.io/blog/create-kubernetes-persistent-volume
Posted by: morrisboally.blogspot.com

0 Response to "How To Create Pvc In Kubernetes"
Post a Comment