Skip to content

Commit bc21781

Browse files
authored
Merge pull request #37887 from ousleyp/hostpath-dir-bug
BZ1994507: HPP backing directory must not be in root
2 parents 6104e1e + 717d7e6 commit bc21781

File tree

5 files changed

+32
-34
lines changed

5 files changed

+32
-34
lines changed

modules/virt-about-hostpath-provisioner.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ When you install the {VirtProductName} Operator, the hostpath provisioner Operat
1313
is automatically installed. To use it, you must:
1414

1515
* Configure SELinux:
16-
** If you use Red Hat Enterprise Linux CoreOS 8 workers, you must create a `MachineConfig`
16+
** If you use {op-system-first} 8 workers, you must create a `MachineConfig`
1717
object on each node.
1818
** Otherwise, apply the SELinux label `container_file_t` to the persistent volume (PV) backing
1919
directory on each node.

modules/virt-configuring-selinux-hpp-on-rhcos8.adoc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
// * virt/virtual_machines/virtual_disks/virt-configuring-local-storage-for-vms.adoc
44

55
[id="virt-configuring-selinux-hpp-on-rhcos8_{context}"]
6-
= Configuring SELinux for the hostpath provisioner on Red Hat Enterprise Linux CoreOS 8
6+
= Configuring SELinux for the hostpath provisioner on {op-system-first} 8
77

8-
You must configure SELinux before you create the `HostPathProvisioner` custom
9-
resource. To configure SELinux on Red Hat Enterprise Linux CoreOS 8 workers, you
10-
must create a `MachineConfig` object on each node.
8+
You must configure SELinux before you create the `HostPathProvisioner` custom resource. To configure SELinux on {op-system-first} 8 workers, you must create a `MachineConfig` object on each node.
119

1210
.Prerequisites
1311

14-
* Create a backing directory on each node for the persistent volumes (PVs)
15-
that the hostpath provisioner creates.
12+
* Create a backing directory on each node for the persistent volumes (PVs) that the hostpath provisioner creates.
13+
+
14+
[IMPORTANT]
15+
====
16+
The backing directory must not be located in the filesystem's root directory because the `/` partition is read-only on {op-system}. For example, you can use `/var/<directory_name>` but not `/<directory_name>`.
17+
====
1618

1719

1820
.Procedure
@@ -25,8 +27,7 @@ that the hostpath provisioner creates.
2527
$ touch machineconfig.yaml
2628
----
2729

28-
. Edit the file, ensuring that you include the directory where you want the
29-
hostpath provisioner to create PVs. For example:
30+
. Edit the file, ensuring that you include the directory where you want the hostpath provisioner to create PVs. For example:
3031
+
3132

3233
[source,yaml]
@@ -49,14 +50,14 @@ spec:
4950
Before=kubelet.service
5051
5152
[Service]
52-
ExecStart=/usr/bin/chcon -Rt container_file_t <path/to/backing/directory> <1>
53+
ExecStart=/usr/bin/chcon -Rt container_file_t <backing_directory_path> <1>
5354
5455
[Install]
5556
WantedBy=multi-user.target
5657
enabled: true
5758
name: hostpath-provisioner.service
5859
----
59-
<1> Specify the backing directory where you want the provisioner to create PVs.
60+
<1> Specify the backing directory where you want the provisioner to create PVs. This directory must not be located in the filesystem's root directory (`/`).
6061

6162
. Create the `MachineConfig` object:
6263
+

modules/virt-creating-storage-class.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ do not specify a value, the storage class defaults to `Delete`.
4848
binding occur. Specify `WaitForFirstConsumer` to delay the binding and provisioning
4949
of a PV until after a pod that uses the persistent volume claim (PVC)
5050
is created. This ensures that the PV meets the pod's scheduling requirements.
51-
51+
+
5252
[NOTE]
5353
====
5454
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.
@@ -63,6 +63,6 @@ To solve this problem, use the Kubernetes pod scheduler to bind the PVC to a PV
6363
$ oc create -f storageclass.yaml
6464
----
6565

66-
.Additional information
66+
.Additional resources
6767

68-
* link:https://kubernetes.io/docs/concepts/storage/storage-classes/[Storage Classes]
68+
* link:https://kubernetes.io/docs/concepts/storage/storage-classes/[Storage classes]

modules/virt-using-hostpath-provisioner.adoc

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55
[id="virt-using-hostpath-provisioner_{context}"]
66
= Using the hostpath provisioner to enable local storage
77

8-
To deploy the hostpath provisioner and enable your virtual machines to use local
9-
storage, first create a `HostPathProvisioner` custom resource.
8+
To deploy the hostpath provisioner and enable your virtual machines to use local storage, first create a `HostPathProvisioner` custom resource.
109

1110
.Prerequisites
1211

13-
* Create a backing directory on each node for the persistent volumes (PVs)
14-
that the hostpath provisioner creates.
12+
* Create a backing directory on each node for the persistent volumes (PVs) that the hostpath provisioner creates.
13+
+
14+
[IMPORTANT]
15+
====
16+
The backing directory must not be located in the filesystem's root directory because the `/` partition is read-only on {op-system-first}. For example, you can use `/var/<directory_name>` but not `/<directory_name>`.
17+
====
1518

16-
* Apply the SELinux context `container_file_t` to the PV
17-
backing directory on each node. For example:
19+
* Apply the SELinux context `container_file_t` to the PV backing directory on each node. For example:
1820
+
1921
[source,terminal]
2022
----
21-
$ sudo chcon -t container_file_t -R </path/to/backing/directory>
23+
$ sudo chcon -t container_file_t -R <backing_directory_path>
2224
----
2325
+
2426
[NOTE]
2527
====
26-
If you use Red Hat Enterprise Linux CoreOS 8 workers, you must configure SELinux
27-
by using a `MachineConfig` manifest instead.
28+
If you use {op-system-first} 8 workers, you must configure SELinux by using a `MachineConfig` manifest instead.
2829
====
2930

3031
.Procedure
@@ -36,8 +37,7 @@ by using a `MachineConfig` manifest instead.
3637
$ touch hostpathprovisioner_cr.yaml
3738
----
3839

39-
. Edit the file, ensuring that the `spec.pathConfig.path` value is the directory
40-
where you want the hostpath provisioner to create PVs. For example:
40+
. Edit the file, ensuring that the `spec.pathConfig.path` value is the directory where you want the hostpath provisioner to create PVs. For example:
4141
+
4242
[source,yaml]
4343
----
@@ -48,20 +48,17 @@ metadata:
4848
spec:
4949
imagePullPolicy: IfNotPresent
5050
pathConfig:
51-
path: "</path/to/backing/directory>" <1>
51+
path: "<backing_directory_path>" <1>
5252
useNamingPrefix: false <2>
5353
workload: <3>
5454
----
55-
<1> Specify the backing directory where you want the provisioner to create PVs.
56-
<2> Change this value to `true` if you want to use the name of the persistent volume claim (PVC)
57-
that is bound to the created PV as the prefix of the directory name.
55+
<1> Specify the backing directory where you want the provisioner to create PVs. This directory must not be located in the filesystem's root directory (`/`).
56+
<2> Change this value to `true` if you want to use the name of the persistent volume claim (PVC) that is bound to the created PV as the prefix of the directory name.
5857
<3> Optional: You can use the `spec.workload` field to configure node placement rules for the hostpath provisioner.
5958
+
6059
[NOTE]
6160
====
62-
If you did not create the backing directory, the provisioner attempts to create
63-
it for you. If you did not apply the `container_file_t` SELinux context, this can cause
64-
`Permission denied` errors.
61+
If you did not create the backing directory, the provisioner attempts to create it for you. If you did not apply the `container_file_t` SELinux context, this can cause `Permission denied` errors.
6562
====
6663

6764
. Create the custom resource in the `openshift-cnv` namespace:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[id="virt-configuring-local-storage-for-vms"]
22
= Configuring local storage for virtual machines
3+
include::modules/common-attributes.adoc[]
34
include::modules/virt-document-attributes.adoc[]
45
:context: virt-configuring-local-storage-for-vms
56

@@ -14,8 +15,7 @@ include::modules/virt-configuring-selinux-hpp-on-rhcos8.adoc[leveloffset=+1]
1415

1516
include::modules/virt-using-hostpath-provisioner.adoc[leveloffset=+1]
1617

17-
[id="virt-local-storage-resources"]
18-
=== Additional resources
18+
.Additional resources
1919
* xref:../../../virt/install/virt-specifying-nodes-for-virtualization-components.adoc#virt-specifying-nodes-for-virtualization-components[Specifying nodes for virtualization components]
2020

2121
include::modules/virt-creating-storage-class.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)