Skip to content

Commit f509243

Browse files
Merge pull request #88890 from danielclowers/CNV-45704_417
CNV#45704 4.17: Configuring a storage class for custom boot source updates
2 parents 20c12c0 + 041362b commit f509243

File tree

3 files changed

+92
-34
lines changed

3 files changed

+92
-34
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Module included in the following assembly:
2+
//
3+
// * virt/storage/virt-automatic-bootsource-updates.adoc
4+
//
5+
6+
:_mod-docs-content-type: PROCEDURE
7+
[id="virt-configuring-default-and-virt-default-storage-class_{context}"]
8+
= Configuring the default and virt-default storage classes
9+
10+
A storage class determines how persistent storage is provisioned for workloads. In {VirtProductName}, the virt-default storage class takes precedence over the cluster default storage class and is used specifically for virtualization workloads. Only one storage class should be set as virt-default or cluster default at a time. If multiple storage classes are marked as default, the virt-default storage class overrides the cluster default. To ensure consistent behavior, configure only one storage class as the default for virtualization workloads.
11+
12+
[IMPORTANT]
13+
====
14+
Boot sources are created using the default storage class. If your cluster does not have a default storage class, you must define one.
15+
====
16+
17+
.Procedure
18+
19+
. Patch the current virt-default or a cluster default storage class to false:
20+
.. Identify all storage classes currently marked as virt-default by running the following command:
21+
+
22+
[source,terminal]
23+
----
24+
$ oc get sc -o json| jq '.items[].metadata|select(.annotations."storageclass.kubevirt.io/is-default-virt-class"=="true")|.name'
25+
----
26+
+
27+
.. For each storage class returned, remove the virt-default annotation by running the following command:
28+
+
29+
[source,terminal]
30+
----
31+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubevirt.io/is-default-virt-class": "false"}}}'
32+
----
33+
+
34+
.. Identify all storage classes currently marked as cluster default by running the following command:
35+
+
36+
[source,terminal]
37+
----
38+
$ oc get sc -o json| jq '.items[].metadata|select(.annotations."storageclass.kubernetes.io/is-default-class"=="true")|.name'
39+
----
40+
+
41+
.. For each storage class returned, remove the cluster default annotation by running the following command:
42+
+
43+
[source,terminal]
44+
----
45+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'
46+
----
47+
48+
. Set a new default storage class:
49+
.. Assign the virt-default role to a storage class by running the following command:
50+
+
51+
[source,terminal]
52+
----
53+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubevirt.io/is-default-virt-class": "true"}}}'
54+
----
55+
+
56+
.. Alternatively, assign the cluster default role to a storage class by running the following command:
57+
+
58+
[source,terminal]
59+
----
60+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'
61+
----
62+
63+
. Delete any outdated `DataVolume` and `VolumeSnapshot` objects from the `openshift-virtualization-os-images` namespace by running the following command.
64+
+
65+
[source,terminal]
66+
----
67+
$ oc delete DataVolume,VolumeSnapshot -n openshift-virtualization-os-images --selector=cdi.kubevirt.io/dataImportCron
68+
----
69+
70+
. Wait for all `DataSource` objects to reach a "Ready - True" status. Data sources can reference either a PersistentVolumeClaim (PVC) or a VolumeSnapshot. To check the expected source format, run the following command:
71+
+
72+
[source,terminal]
73+
----
74+
$ oc get storageprofile <storage_class_name> -o json | jq .status.dataImportCronSourceFormat
75+
----

modules/virt-configuring-storage-class-bootsource-update.adoc

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
:_mod-docs-content-type: PROCEDURE
77
[id="virt-configuring-storage-class-bootsource-update_{context}"]
8-
= Configuring a storage class for custom boot source updates
8+
= Configuring a storage class for boot source images
99

10-
You can override the default storage class by editing the `HyperConverged` custom resource (CR).
10+
You can configure a specific storage class in the `HyperConverged` resource.
1111

1212
[IMPORTANT]
1313
====
14-
Boot sources are created from storage using the default storage class. If your cluster does not have a default storage class, you must define one before configuring automatic updates for custom boot sources.
14+
To ensure stable behavior and avoid unnecessary re-importing, you can specify the `storageClassName` in the `dataImportCronTemplates` section of the `HyperConverged` resource.
1515
====
1616

1717
.Procedure
@@ -23,7 +23,7 @@ Boot sources are created from storage using the default storage class. If your c
2323
$ oc edit hyperconverged kubevirt-hyperconverged -n {CNVNamespace}
2424
----
2525

26-
. Define a new storage class by entering a value in the `storageClassName` field:
26+
. Add the `dataImportCronTemplate` to the spec section of the `HyperConverged` resource and set the `storageClassName`:
2727
+
2828
[source,yaml]
2929
----
@@ -34,11 +34,12 @@ metadata:
3434
spec:
3535
dataImportCronTemplates:
3636
- metadata:
37-
name: rhel8-image-cron
37+
name: rhel9-image-cron
3838
spec:
3939
template:
4040
spec:
41-
storageClassName: <new_storage_class> <1>
41+
storage:
42+
storageClassName: <storage_class> <1>
4243
schedule: "0 */12 * * *" <2>
4344
managedDataSource: <data_source> <3>
4445
# ...
@@ -47,43 +48,23 @@ spec:
4748
<2> Required: Schedule for the job specified in cron format.
4849
<3> Required: The data source to use.
4950
+
50-
--
5151
[NOTE]
52-
----
52+
====
5353
For the custom image to be detected as an available boot source, the value of the `spec.dataVolumeTemplates.spec.sourceRef.name` parameter in the VM template must match this value.
54-
----
55-
--
54+
====
5655
57-
. Remove the `storageclass.kubernetes.io/is-default-class` annotation from the current default storage class.
58-
.. Retrieve the name of the current default storage class by running the following command:
59-
+
60-
[source,terminal]
61-
----
62-
$ oc get storageclass
63-
----
64-
+
65-
.Example output
66-
[source,text]
67-
----
68-
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
69-
csi-manila-ceph manila.csi.openstack.org Delete Immediate false 11d
70-
hostpath-csi-basic (default) kubevirt.io.hostpath-provisioner Delete WaitForFirstConsumer false 11d <1>
71-
----
72-
+
73-
<1> In this example, the current default storage class is named `hostpath-csi-basic`.
56+
. Wait for the HyperConverged Operator (HCO) and Scheduling, Scale, and Performance (SSP) resources to complete reconciliation.
7457
75-
.. Remove the annotation from the current default storage class by running the following command:
58+
. Delete any outdated `DataVolume` and `VolumeSnapshot` objects from the `openshift-virtualization-os-images` namespace.
7659
+
7760
[source,terminal]
7861
----
79-
$ oc patch storageclass <current_default_storage_class> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}' <1>
62+
$ oc delete DataVolume,VolumeSnapshot -n openshift-virtualization-os-images --selector=cdi.kubevirt.io/dataImportCron
8063
----
81-
<1> Replace `<current_default_storage_class>` with the `storageClassName` value of the default storage class.
8264
83-
. Set the new storage class as the default by running the following command:
65+
. Wait for all `DataSource` objects to reach a "Ready - True" status. Data sources can reference either a PersistentVolumeClaim (PVC) or a VolumeSnapshot. To check the expected source format, run the following command:
8466
+
8567
[source,terminal]
8668
----
87-
$ oc patch storageclass <new_storage_class> -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' <1>
88-
----
89-
<1> Replace `<new_storage_class>` with the `storageClassName` value that you added to the `HyperConverged` CR.
69+
$ oc get storageprofile <storage_class_name> -o json | jq .status.dataImportCronSourceFormat
70+
----

virt/storage/virt-automatic-bootsource-updates.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ You must configure a storage profile. Otherwise, the cluster cannot receive auto
4141
====
4242
endif::openshift-rosa,openshift-dedicated[]
4343

44+
include::modules/virt-configuring-default-and-virt-default-storage-class.adoc[leveloffset=+2]
45+
4446
include::modules/virt-configuring-storage-class-bootsource-update.adoc[leveloffset=+2]
4547

4648
include::modules/virt-autoupdate-custom-bootsource.adoc[leveloffset=+2]

0 commit comments

Comments
 (0)