Skip to content

Commit e901131

Browse files
authored
Merge pull request #88579 from danielclowers/CNV-45704_418
CNV#45704 4.18: Configuring a storage class for custom boot source updates
2 parents 325aa6b + 4b43997 commit e901131

File tree

3 files changed

+78
-30
lines changed

3 files changed

+78
-30
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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. When the default storage class changes, old boot sources are automatically updated using the new default storage class. If your cluster does not have a default storage class, you must define one.
15+
16+
If boot source images were stored as volume snapshots and both the cluster default and virt-default storage class have been unset, the volume snapshots are cleaned up and new data volumes will be created. However the newly created data volumes will not start importing until a default storage class is set.
17+
====
18+
19+
.Procedure
20+
21+
. Patch the current virt-default or a cluster default storage class to false:
22+
.. Identify all storage classes currently marked as virt-default by running the following command:
23+
+
24+
[source,terminal]
25+
----
26+
$ oc get sc -o json| jq '.items[].metadata|select(.annotations."storageclass.kubevirt.io/is-default-virt-class"=="true")|.name'
27+
----
28+
+
29+
.. For each storage class returned, remove the virt-default annotation by running the following command:
30+
+
31+
[source,terminal]
32+
----
33+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubevirt.io/is-default-virt-class": "false"}}}'
34+
----
35+
+
36+
.. Identify all storage classes currently marked as cluster default by running the following command:
37+
+
38+
[source,terminal]
39+
----
40+
$ oc get sc -o json| jq '.items[].metadata|select(.annotations."storageclass.kubernetes.io/is-default-class"=="true")|.name'
41+
----
42+
+
43+
.. For each storage class returned, remove the cluster default annotation by running the following command:
44+
+
45+
[source,terminal]
46+
----
47+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'
48+
----
49+
50+
. Set a new default storage class:
51+
.. Assign the virt-default role to a storage class by running the following command:
52+
+
53+
[source,terminal]
54+
----
55+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubevirt.io/is-default-virt-class": "true"}}}'
56+
----
57+
+
58+
.. Alternatively, assign the cluster default role to a storage class by running the following command:
59+
+
60+
[source,terminal]
61+
----
62+
$ oc patch storageclass <storage_class_name> -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'
63+
----

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

Lines changed: 13 additions & 30 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
# ...
@@ -54,36 +55,18 @@ For the custom image to be detected as an available boot source, the value of th
5455
----
5556
--
5657
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`.
58+
. Wait for the HyperConverged Operator (HCO) and Scheduling, Scale, and Performance (SSP) resources to complete reconciliation.
7459
75-
.. Remove the annotation from the current default storage class by running the following command:
60+
. Delete any outdated `DataVolume` and `VolumeSnapshot` objects from the `openshift-virtualization-os-images` namespace by running the following command.
7661
+
7762
[source,terminal]
7863
----
79-
$ oc patch storageclass <current_default_storage_class> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}' <1>
64+
$ oc delete DataVolume,VolumeSnapshot -n openshift-virtualization-os-images --selector=cdi.kubevirt.io/dataImportCron
8065
----
81-
<1> Replace `<current_default_storage_class>` with the `storageClassName` value of the default storage class.
8266
83-
. Set the new storage class as the default by running the following command:
67+
. 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:
8468
+
8569
[source,terminal]
8670
----
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.
71+
$ oc get storageprofile <storage_class_name> -o json | jq .status.dataImportCronSourceFormat
72+
----

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)