Provision a Static Local Volume
Learn how to provision a static local volume for a DKP cluster
When creating a pre-provisioned infrastructure cluster, DKP uses localvolumeprovisioner
as the default storage provider. However, localvolumeprovisioner
is not suitable for production use. You should use a Kubernetes CSI compatible storage that is suitable for production.
You can choose from any of the storage options available for Kubernetes. To disable the default that Konvoy deploys, set the default StorageClasslocalvolumeprovisioner
as non-default. Then set your newly-created StorageClass by following the steps in the Kubernetes documentation, Changing the Default Storage Class.
The localvolumeprovisioner
component uses the local volume static provisioner to manage persistent volumes for pre-allocated disks. It does this by watching the /mnt/disks
folder on each host and creating persistent volumes in the localvolumeprovisioner
storage class for each disk that it discovers in this folder.
Persistent volumes with a ‘Filesystem’ volume-mode are discovered if you mount them under
/mnt/disks
.Persistent volumes with a ‘Block’ volume-mode are discovered if you create a symbolic link to the block device in
/mnt/disks
.
For additional DKP documentation regarding StorageClass, see: Default Storage Providers in DKP
Before you Begin
Before starting, verify the following:
You have access to a Linux, macOS, or Windows computer with a supported operating system version.
You have a provisioned
dkp
cluster that uses thelocalvolumeprovisioner
platform application, but have not added any other Kommander applications to the cluster yet.
This distinction between provisioning and deployment is important because some applications depend on the storage class provided by the localvolumeprovisioner
component and can fail to start if it is not configured yet.
Provision the Cluster and a Volume
Create a pre-provisioned cluster by following the steps outlined in the Pre-provisioned Infrastructure topic.
As volumes are created/mounted on the nodes, the local volume provisioner detects each volume in the
/mnt/disks
directory and adds it as a persistent volume with thelocalvolumeprovisioner
storage class. For more information, see the documentation regarding Kubernetes Local Storage.Create at least one volume in
/mnt/disks
on each host.For example, mount a
tmpfs
volume:CODEmkdir -p /mnt/disks/example-volume && mount -t tmpfs example-volume /mnt/disks/example-volume
Verify the persistent volume by running the following command:
CODEkubectl get pv
The command displays output similar to the following:
CODENAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE local-pv-4c7fc8ba 3986Mi RWO Delete Available localvolumeprovisioner 2s
Claim the persistent volume using a PersistentVolumeClaim, by running the following command:
CODEcat <<EOF | kubectl create -f - kind: PersistentVolumeClaim apiVersion: v1 metadata: name: example-claim spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Mi storageClassName: localvolumeprovisioner EOF
Reference the persistent volume claim in a pod by running the following command:
CODEcat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: pod-with-persistent-volume spec: containers: - name: frontend image: nginx volumeMounts: - name: data mountPath: "/var/www/html" volumes: - name: data persistentVolumeClaim: claimName: example-claim EOF
Verify the persistent volume claim by running the following command:
CODEkubectl get pvc
The command displays output similar to the following:
CODENAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE example-claim Bound local-pv-4c7fc8ba 3986Mi RWO localvolumeprovisioner 78s
And you can also check the persistent volume:
CODENAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE local-pv-4c7fc8ba 3986Mi RWO Delete Bound default/example-claim localvolumeprovisioner 15m
Upon deletion of the persistent volume claim, the corresponding persistent volume resource uses the Delete reclaim policy, which removes all data on the volume.