Example: Mounting a PersistentVolume for Dynamic Provisioning Using MapR Container Storage Interface (CSI) Storage Plugin
This example also uses a PersistentVolume. However, unlike the previous example, when you use the MapR dynamic provisioner, you do not need to create a PersistentVolume manually. The PersistentVolume is created automatically based on the parameters specified in the referenced StorageClass.
Dynamic provisioning is useful in cases where you do not want MapR and Kubernetes administrators to create storage manually to store the Pod storage state.
The following example uses a PersistentVolumeClaim that references a Storage Class. In
this example, a Kubernetes Administrator has created a storage class called
test-secure-sc
for Pod creators to use when they want to create
persistent storage for their Pods. In this example, it is important for the created Pod
storage to survive the deletion of a Pod.
To dynamically provision a volume, you must do the following:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: test-secure-sc
namespace: test-csi
provisioner: com.mapr.csi-kdf
parameters:
csiProvisionerSecretName: "mapr-provisioner-secrets"
csiProvisionerSecretNamespace: "test-csi"
csiNodePublishSecretName: "mapr-ticket-secret"
csiNodePublishSecretNamespace: "test-csi"
restServers: "10.10.10.210"
cldbHosts: "10.10.10.210"
cluster: "clusterA"
securityType: "secure"
namePrefix: "csi-pv"
mountPrefix: "/csi"
advisoryquota: "100M"
--
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-secure-pvc
namespace: test-csi
spec:
storageClassName: test-secure-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5G
--
apiVersion: v1
kind: Pod
metadata:
name: test-secure-pod
namespace: test-csi
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- "1000000"
resources:
requests:
memory: "2Gi"
cpu: "500m"
volumeMounts:
- mountPath: /mapr
name: maprflex
volumes:
- name: maprflex
persistentVolumeClaim:
claimName: test-secure-pvc