1.11. Using the LVMS
The LVMS StorageClass is deployed with a default StorageClass. Any PersistentVolumeClaim objects without a .spec.storageClassName defined automatically has a PersistentVolume provisioned from the default StorageClass. Use the following procedure to provision and mount a logical volume to a pod.
Procedure
To provision and mount a logical volume to a pod, run the following command:
$ cat <<EOF | oc apply -f - kind: PersistentVolumeClaim apiVersion: v1 metadata: name: my-lv-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1G --- apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: nginx image: nginx command: ["/usr/bin/sh", "-c"] args: ["sleep", "1h"] volumeMounts: - mountPath: /mnt name: my-volume securityContext: allowPrivilegeEscalation: false capabilities: drop: - ALL runAsNonRoot: true seccompProfile: type: RuntimeDefault volumes: - name: my-volume persistentVolumeClaim: claimName: my-lv-pvc EOF
1.11.1. Device classes リンクのコピーリンクがクリップボードにコピーされました!
You can create custom device classes by adding a device-classes array to your logical volume manager storage (LVMS) configuration. Add the array to the /etc/microshift/lvmd.yaml configuration file. A single device class must be set as the default. You must restart MicroShift for configuration changes to take effect.
Removing a device class while there are still persistent volumes or VolumeSnapshotContent objects connected to that device class breaks both thick and thin provisioning.
You can define multiple device classes in the device-classes array. These classes can be a mix of thick and thin volume configurations.
Example of a mixed device-class array
socket-name: /run/topolvm/lvmd.sock
device-classes:
- name: ssd
volume-group: ssd-vg
spare-gb: 0
default: true
- name: hdd
volume-group: hdd-vg
spare-gb: 0
- name: thin
spare-gb: 0
thin-pool:
name: thin
overprovision-ratio: 10
type: thin
volume-group: ssd
- name: striped
volume-group: multi-pv-vg
spare-gb: 0
stripe: 2
stripe-size: "64"
lvcreate-options:
- 1
- When you set the spare capacity to anything other than
0, more space can be allocated than expected. - 2
- Extra arguments to pass to the
lvcreatecommand, such as--type=<type>. Neither MicroShift nor the LVMS verifieslvcreate-optionsvalues. These optional values are passed as is to thelvcreatecommand. Ensure that the options specified here are correct.