Skip to content

Commit eb34cd4

Browse files
authored
Merge pull request #42178 from bgaydosrh/CNV-11176
2 parents 8fc3fec + 90a3fa9 commit eb34cd4

File tree

5 files changed

+205
-44
lines changed

5 files changed

+205
-44
lines changed

modules/virt-about-hostpath-provisioner.adoc

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44

55
:_content-type: CONCEPT
66
[id="virt-about-hostpath-provisioner_{context}"]
7-
= About the hostpath provisioner
8-
9-
The hostpath provisioner is a local storage provisioner designed for
10-
{VirtProductName}. If you want to configure local storage for
11-
virtual machines, you must enable the hostpath provisioner first.
12-
13-
When you install the {VirtProductName} Operator, the hostpath provisioner Operator
14-
is automatically installed. To use it, you must:
15-
16-
* Configure SELinux:
17-
** If you use {op-system-first} 8 workers, you must create a `MachineConfig`
18-
object on each node.
19-
** Otherwise, apply the SELinux label `container_file_t` to the persistent volume (PV) backing
20-
directory on each node.
21-
* Create a `HostPathProvisioner` custom resource.
22-
* Create a `StorageClass` object for the hostpath provisioner.
23-
24-
The hostpath provisioner Operator deploys the provisioner as a _DaemonSet_ on each
25-
node when you create its custom resource. In the custom resource file, you specify
26-
the backing directory for the persistent volumes that the hostpath provisioner
27-
creates.
7+
= About the hostpath provisioner (HPP)
8+
9+
When you install the {VirtProductName} Operator, the Hostpath Provisioner Operator is automatically installed. The HPP is a local storage provisioner designed for {VirtProductName} that is created by the Hostpath Provisioner Operator. To use the HPP, you must create a HPP custom resource.
10+
11+
[IMPORTANT]
12+
====
13+
In {VirtProductName} 4.10, the HPP Operator configures the Kubernetes CSI driver. The Operator also recognizes the existing (legacy) format of the custom resource.
14+
15+
The legacy HPP and the CSI host path driver are supported in parallel for a number of releases. However, at some point, the legacy HPP will no longer be supported. If you use the HPP, plan to create a storage class for the CSI driver as part of your migration strategy.
16+
====
17+
18+
If you upgrade to {VirtProductName} version 4.10 on an existing cluster, the HPP Operator is upgraded and the system performs the following actions:
19+
20+
* The CSI driver is installed.
21+
* The CSI driver is configured with the contents of your legacy custom resource.
22+
23+
If you install {VirtProductName} version 4.10 on a new cluster, you must perform the following actions:
24+
25+
* Create the HPP custom resource including a `storagePools` stanza in the HPP custom resource.
26+
* Create a storage class for the CSI driver.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="virt-creating-custom-resources-hpp_{context}"]
7+
= Create the HPP custom resource with a storage pool
8+
9+
Storage pools allow you to specify the name and path that are used by the CSI driver.
10+
11+
.Procedure
12+
13+
. Create a YAML file for the HPP custom resource with a `storagePools` stanza in the YAML. For example:
14+
+
15+
[source,terminal]
16+
----
17+
$ touch hostpathprovisioner_cr.yaml
18+
----
19+
20+
. Edit the file. For example:
21+
+
22+
[source,yaml]
23+
----
24+
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
25+
kind: HostPathProvisioner
26+
metadata:
27+
 name: hostpath-provisioner
28+
spec:
29+
 imagePullPolicy: IfNotPresent
30+
 storagePools: <1>
31+
   - name: <any_name>
32+
     path: "</var/myvolumes>" <2>
33+
 workload:
34+
   nodeSelector:
35+
     kubernetes.io/os: linux
36+
----
37+
<1> The `storagePools` stanza is an array to which you can add multiple entries.
38+
<2> Create directories under this node path. Read/write access is required. Ensure that the node-level directory (`/var/myvolumes`) is not on the same partition as the operating system. If it is on the same partition as the operating system, users can potentially fill the operating system partition and impact performance or cause the node to become unstable or unusable.
39+
40+
. Save the file and exit.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="virt-creating-single-pvc-template-storage-pool_{context}"]
7+
= Creating a storage pool using a pvcTemplate specification in a host path provisioner (HPP) custom resource.
8+
9+
If you have a single large persistent volume (PV) on your node, you might want to virtually divide the volume and use one partition to store only the HPP volumes. By defining a storage pool using a `pvcTemplate` specification in the HPP custom resource, you can virtually split the PV into multiple smaller volumes, providing more flexibility in data allocation.
10+
11+
The `pvcTemplate` matches the `spec` portion of a persistent volume claim (PVC). For example:
12+
13+
[source,yaml]
14+
----
15+
apiVersion: v1
16+
kind: PersistentVolumeClaim
17+
metadata:
18+
name: "iso-pvc"
19+
labels:
20+
app: containerized-data-importer
21+
annotations:
22+
cdi.kubevirt.io/storage.import.endpoint: "http://cdi-file-host.cdi:80/tinyCore.iso.tar"
23+
spec: <1>
24+
volumeMode: Block
25+
  storageClassName: <any_storage_class>
26+
  accessModes:
27+
    - ReadWriteOnce
28+
       resources:
29+
         requests:
30+
           storage: 5Gi
31+
----
32+
<1> A `pvcTemplate` is the `spec` (specification) section of a PVC
33+
34+
The Operator creates a PVC from the PVC template for each node containing the HPP CSI driver. The PVC created from the PVC template consumes the single large PV, allowing the HPP to create smaller dynamic volumes.
35+
36+
You can create any combination of storage pools. You can combine standard storage pools with storage pools that use PVC templates in the `storagePools` stanza.
37+
38+
.Procedure
39+
40+
. Create a YAML file for the CSI custom resource specifying a single `pvcTemplate` storage pool. For example:
41+
+
42+
[source,terminal]
43+
----
44+
$ touch hostpathprovisioner_cr_pvc.yaml
45+
----
46+
47+
. Edit the file. For example:
48+
+
49+
[source,yaml]
50+
----
51+
apiVersion: hostpathprovisioner.kubevirt.io/v1beta1
52+
kind: HostPathProvisioner
53+
metadata:
54+
 name: hostpath-provisioner
55+
spec:
56+
 imagePullPolicy: IfNotPresent
57+
storagePools: <1>
58+
   - name: <any_name>
59+
     path: "</var/myvolumes>" <2>
60+
  pvcTemplate:
61+
       volumeMode: Block <3>
62+
       storageClassName: <any_storage_class> <4>
63+
       accessModes:
64+
       - ReadWriteOnce
65+
       resources:
66+
         requests:
67+
           storage: 5Gi <5>
68+
   workload:
69+
   nodeSelector:
70+
     kubernetes.io/os: linux
71+
----
72+
<1> The `storagePools` stanza is an array to which you can add multiple entries.
73+
<2> Create directories under this node path. Read/write access is required. Ensure that the node-level directory (`/var/myvolumes`) is not on the same partition as the operating system. If it is, users of the volumes can potentially fill the operating system partition and cause the node to impact performance, become unstable, or become unusable.
74+
<3> `volumeMode` parameter is optional and can be either `Block` or `Filesystem` but must match the provisioned volume format, if used. The default value is `Filesystem`. If the `volumeMode` is `block`, the mounting pod creates an XFS file system on the block volume before mounting it.
75+
<4> If the `storageClassName` parameter is omitted, the default storage class is used to create PVCs. If you omit `storageClassName`, ensure that the HPP storage class is not the default storage class.
76+
<5> You can specify statically or dynamically provisioned storage. In either case, ensure the requested storage size is appropriate for the volume you want to virtually divide or the PVC cannot be bound to the large PV. If the storage class you are using uses dynamically provisioned storage, pick an allocation size that matches the size of a typical request.
77+
78+
. Save the file and exit.

modules/virt-creating-storage-class.adoc

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,69 @@
99
When you create a storage class, you set parameters that affect the
1010
dynamic provisioning of persistent volumes (PVs) that belong to that storage class.
1111

12-
[IMPORTANT]
13-
====
14-
When using {VirtProductName} with {product-title} Container Storage, specify RBD block mode persistent volume claims (PVCs) when creating virtual machine disks. With virtual machine disks, RBD block mode volumes are more efficient and provide better performance than Ceph FS or RBD filesystem-mode PVCs.
12+
In order to use the host path provisioner (HPP) you must create an associated storage class for the CSI driver with the `storagePools` stanza.
1513

16-
To specify RBD block mode PVCs, use the 'ocs-storagecluster-ceph-rbd' storage class and `VolumeMode: Block`.
14+
[NOTE]
15+
====
16+
You cannot update a `StorageClass` object's parameters after you create it.
1717
====
1818

1919
[NOTE]
2020
====
21-
You cannot update a `StorageClass` object's parameters after you create it.
21+
Virtual machines use data volumes that are based on local PVs. Local PVs are bound to specific nodes. While the disk image is prepared for consumption by the virtual machine, it is possible that the virtual machine cannot be scheduled to the node where the local storage PV was previously pinned.
22+
23+
To solve this problem, use the Kubernetes pod scheduler to bind the PVC to a PV on the correct node. By using the `StorageClass` value with `volumeBindingMode` parameter set to `WaitForFirstConsumer`, the binding and provisioning of the PV is delayed until a pod is created using the PVC.
2224
====
2325

26+
[id="virt-creating-storage-class-csi_{context}"]
27+
== Creating a storage class for the CSI driver with the storagePools stanza
28+
29+
Use this procedure to create a storage class for use with the HPP CSI driver implementation. You must create this storage class to use HPP in {VirtProductName} 4.10 and later.
30+
31+
.Procedure
32+
33+
. Create a YAML file for defining the storage class. For example:
34+
+
35+
[source,terminal]
36+
----
37+
$ touch <storageclass_csi>.yaml
38+
----
39+
40+
. Edit the file. For example:
41+
+
42+
[source,yaml]
43+
----
44+
apiVersion: storage.k8s.io/v1
45+
kind: StorageClass
46+
metadata:
47+
name: hostpath-csi <1>
48+
provisioner: kubevirt.io.hostpath-provisioner <2>
49+
reclaimPolicy: Delete <3>
50+
volumeBindingMode: WaitForFirstConsumer <4>
51+
parameters:
52+
storagePool: <any_name> <5>
53+
----
54+
<1> Assign any meaningful name to the storage class. In this example, `csi` is used to specify that the class is using the CSI provisioner instead of the legacy provisioner. Choosing descriptive names for storage classes, based on legacy or CSI driver provisioning, eases implementation of your migration strategy.
55+
<2> The legacy provisioner uses `kubevirt.io/hostpath-provisioner`. The CSI driver uses `kubevirt.io.hostpath-provisioner`.
56+
<3> The two possible `reclaimPolicy` values are `Delete` and `Retain`. If you
57+
do not specify a value, the storage class defaults to `Delete`.
58+
<4> The `volumeBindingMode` parameter determines when dynamic provisioning and volume binding occur. Specify `WaitForFirstConsumer` to delay the binding and provisioning of a PV until after a pod that uses the persistent volume claim (PVC) is created. This ensures that the PV meets the pod's scheduling requirements.
59+
<5> `<any_name>` must match the name of the storage pool, which you define in the HPP custom resource.
60+
61+
. Save the file and exit.
62+
63+
. Create the `StorageClass` object:
64+
+
65+
[source,terminal]
66+
----
67+
$ oc create -f <storageclass_csi>.yaml
68+
----
69+
70+
[id="virt-creating-storage-class-legacy-hpp_{context}"]
71+
== Creating a storage class for the legacy hostpath provisioner
72+
73+
Use this procedure to create a storage class for the legacy hostpath provisioner (HPP). You do not need to explicitly add a `storagePool` parameter.
74+
2475
.Procedure
2576

2677
. Create a YAML file for defining the storage class. For example:
@@ -42,20 +93,12 @@ provisioner: kubevirt.io/hostpath-provisioner
4293
reclaimPolicy: Delete <2>
4394
volumeBindingMode: WaitForFirstConsumer <3>
4495
----
45-
<1> You can optionally rename the storage class by changing this value.
96+
<1> Assign any meaningful name to the storage class. In this example, `csi` is used to specify that the class is using the CSI provisioner, instead of the legacy provisioner. Choosing descriptive names for storage classes, based on legacy or CSI driver provisioning, eases implementation of your migration strategy.
4697
<2> The two possible `reclaimPolicy` values are `Delete` and `Retain`. If you
4798
do not specify a value, the storage class defaults to `Delete`.
48-
<3> The `volumeBindingMode` value determines when dynamic provisioning and volume
49-
binding occur. Specify `WaitForFirstConsumer` to delay the binding and provisioning
50-
of a PV until after a pod that uses the persistent volume claim (PVC)
51-
is created. This ensures that the PV meets the pod's scheduling requirements.
52-
+
53-
[NOTE]
54-
====
55-
Virtual machines use data volumes that are based on local PVs. Local PVs are bound to specific nodes. While the disk image is prepared for consumption by the virtual machine, it is possible that the virtual machine cannot be scheduled to the node where the local storage PV was previously pinned.
99+
<3> The `volumeBindingMode` value determines when dynamic provisioning and volume binding occur. Specify the `WaitForFirstConsumer` value to delay the binding and provisioning of a PV until after a pod that uses the persistent volume claim (PVC) is created. This ensures that the PV meets the pod's scheduling requirements.
56100

57-
To solve this problem, use the Kubernetes pod scheduler to bind the PVC to a PV on the correct node. By using `StorageClass` with `volumeBindingMode` set to `WaitForFirstConsumer`, the binding and provisioning of the PV is delayed until a `Pod` is created using the PVC.
58-
====
101+
. Save the file and exit.
59102

60103
. Create the `StorageClass` object:
61104
+

virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ include::_attributes/virt-document-attributes.adoc[]
77

88
toc::[]
99

10-
You can configure local storage for your virtual machines by using the hostpath
11-
provisioner feature.
10+
Configure storage for your virtual machines. When configuring local storage, use the hostpath provisioner (HPP).
1211

1312
include::modules/virt-about-hostpath-provisioner.adoc[leveloffset=+1]
1413

15-
include::modules/virt-configuring-selinux-hpp-on-rhcos8.adoc[leveloffset=+1]
14+
include::modules/virt-creating-custom-resources-hpp.adoc[leveloffset=+1]
1615

17-
include::modules/virt-using-hostpath-provisioner.adoc[leveloffset=+1]
16+
include::modules/virt-creating-storage-class.adoc[leveloffset=+1]
17+
18+
In addition to configuring a basic storage pool for use with the HPP, you have the option of creating single storage pools with the `pvcTemplate` specification as well as multiple storage pools.
19+
20+
include::modules/virt-creating-single-pvc-template-storage-pool.adoc[leveloffset=+1]
1821

1922
[role="_additional-resources"]
2023
.Additional resources
21-
* xref:../../../virt/install/virt-specifying-nodes-for-virtualization-components.adoc#virt-specifying-nodes-for-virtualization-components[Specifying nodes for virtualization components]
22-
23-
include::modules/virt-creating-storage-class.adoc[leveloffset=+1]
24+
* xref:../../../virt/virtual_machines/virtual_disks/virt-creating-data-volumes.adoc#virt-customizing-storage-profile_virt-creating-data-volumes[Customizing the storage profile]

0 commit comments

Comments
 (0)