For Static Provisioning, we have an existing NVMesh volume that was created outside the CSI scope and want to consume it in Kubernetes.
By default, when creating a PVC from an NVMesh StorageClass, the CSI Driver will create a new NVMesh Volume and a new PersistentVolume in Kubernetes will be created to describe the new volume. This is called Dynamic Provisioning.
However, If you have an existing NVMesh Volume, possibly already populated with data, to consume it in Kubernetes, you will need to use Static Provisioning.
Following is an example of Static Provisioning:
- This example is also available in the github repo under docs/examples/static-provisioning.yaml.
Create NVMesh Volume
Create a volume in the NVMesh Management software with the following attributes:
- Name: vol-1
- Capacity: 5Gi
- Raid Type: RAID10 (you could use the DEFAULT_RAID_10_VPG)
Create a PersistentVolume in Kubernetes
Create a PersistentVolume in Kubernetes to represent the volume already defined in the NVMesh:
apiVersion: v1
kind: PersistentVolume
metadata:
name: name-in-k8s
spec:
accessModes:
- ReadWriteMany
- ReadWriteOnce
- ReadOnlyMany
persistentVolumeReclaimPolicy: Retain
capacity:
storage: 5Gi
volumeMode: Block
storageClassName: nvmesh-raid10
csi:
driver: nvmesh-csi.excelero.com
volumeHandle: vol-1
Relevant fields info:
metadata.name
is the name that this PV will have in Kubernetes.
spec.csi.driver
must be set to nvmesh-csi.excelero.com
.
spec.csi.volumeHandle
is the name of the volume in NVMesh.
persistentVolumeReclaimPolicy
, by setting this field to Retain
we let Kubernetes know this PersistentVolume should not be deleted when the bounded PVC is deleted.
accessModes
, note that in this example we allowed all Access Modes, but you can choose any sub-set of these 3 options.
Create a PersistentVolumeClaim
Create a PVC that will be bound to the PV just created.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-1
spec:
accessModes:
- ReadWriteOnce
volumeMode: Block
resources:
requests:
storage: 5Gi
storageClassName: nvmesh-raid10
Create a Pod that uses the Volume
Run a pod that will mount this volume and use it:
- This pod specifically does nothing with the volume, but you could get a shell to the running container and explore or run IO on the volume.
- The volume is available inside the pod under /vol.
apiVersion: v1
kind: Pod
metadata:
name: pod-1
spec:
containers:
- name: c-1
image: alpine
command: ["/bin/sh", "-c", "echo hello ; while true ; do wait 1; done"]
volumeDevices:
- name: vol
devicePath: /vol
restartPolicy: Never
volumes:
- name: vol
persistentVolumeClaim:
claimName: pvc-1
Post your comment on this topic.