Automatic importing and updating of pre-defined boot sources
As of version 4.10, OKD Virtualization automatically imports and updates pre-defined boot sources, unless you manually opt-out. If you upgrade to version OKD Virtualization 4.10 from version 4.9 or earlier and have pre-defined boot sources from the earlier version, you must manually opt-in to automatic imports and updates for those pre-defined boot sources.
Enabling automatic boot source updates
If you have pre-defined boot sources from OKD Virtualization 4.9, then you must manually opt them in to the automatic boot source updates. All pre-defined boot sources from OKD Virtualization 4.10 and later are automatically updated by default.
Procedure
Use the following command to apply the
dataImportCron
label to the data source:$ oc label --overwrite DataSource rhel8 -n openshift-virtualization-os-images cdi.kubevirt.io/dataImportCron=true
Disabling automatic boot source updates
You can reduce the number of logs on disconnected environments or reduce resource usage by disabling the automatic imports and updates of pre-defined boot sources. Set the spec.featureGates.enableCommonBootImageImport
field in the HyperConverged
custom resource (CR) to false
.
Custom boot sources are not affected by this setting. |
Procedure
Use the following command to disable automatic updates:
$ oc patch hco kubevirt-hyperconverged -n openshift-cnv --type json -p '[{"op": "replace", "path": "/spec/featureGates/enableCommonBootImageImport", "value": false}]'
Re-enabling automatic boot source updates
If you have previously disabled automatic boot source updates, you must manually re-enable the feature. Set the spec.featureGates.enableCommonBootImageImport
field in the HyperConverged
custom resource (CR) to true
.
Procedure
Use the following command to re-enable automatic updates:
$ oc patch hco kubevirt-hyperconverged -n openshift-cnv --type json -p '[{"op": "replace", "path": "/spec/featureGates/enableCommonBootImageImport", "value": true}]'
Enabling automatic updates on custom boot sources
OKD Virtualization automatically updates pre-defined boot sources by default, but does not automatically update custom boot sources. You must manually enable automatic imports and updates on any custom boot sources by editing the HyperConverged
custom resource (CR).
Procedure
Use the following command to open the
HyperConverged
CR for editing:$ oc edit -n openshift-cnv HyperConverged
Edit the
HyperConverged
CR, specifying the appropriate template and boot source in thedataImportCronTemplates
section. For example:Example in CentOS 7
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
spec:
dataImportCronTemplates:
- metadata:
name: centos7-image-cron
annotations:
cdi.kubevirt.io/storage.bind.immediate.requested: "true" (1)
spec:
schedule: "0 */12 * * *" (2)
template:
spec:
source:
registry: (3)
url: docker://quay.io/containerdisks/centos:7-2009
storage:
resources:
requests:
storage: 10Gi
managedDataSource: centos7 (4)
retentionPolicy: "None" (5)
1 This annotation is required for storage classes with volumeBindingMode
set toWaitForFirstConsumer
.2 Schedule for the job specified in cron format. 3 Use to create a data volume from a registry source. Use the default pod
pullMethod
and notnode
pullMethod
, which is based on thenode
docker cache. Thenode
docker cache is useful when a registry image is available viaContainer.Image
, but the CDI importer is not authorized to access it.4 For the custom image to be detected as an available boot source, the name of the image’s managedDataSource
must match the name of the template’sDataSource
, which is found underspec.dataVolumeTemplates.spec.sourceRef.name
in the VM template YAML file.5 Use All
to retain data volumes and data sources when the cron job is deleted. UseNone
to delete data volumes and data sources when the cron job is deleted.