$ oc label --overwrite DataSource rhel8 -n openshift-virtualization-os-images cdi.kubevirt.io/dataImportCron=true
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.
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.
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
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. |
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}]'
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
.
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}]'
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).
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 the dataImportCronTemplates
section. For example:
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 to WaitForFirstConsumer . |
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 not node pullMethod , which is based on the node docker cache. The node docker cache is useful when a registry image is available via Container.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’s DataSource , which is found under spec.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. Use None to delete data volumes and data sources when the cron job is deleted. |