This example also uses a PersistentVolume. However, unlike the previous example, when you use the 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 data-fabric and Kubernetes cluster 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.
The information on this page is valid for both FUSE POSIX and Loopback NFS plugins.
Examples or tables that mention the FUSE POSIX provisioner
(com.mapr.csi-kdf) are equally valid for the Loopback NFS provisioner
(com.mapr.csi-nfskdf).
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