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:

    1. $ 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:

    1. $ 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:

    1. $ 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

  1. Use the following command to open the HyperConverged CR for editing:

    1. $ oc edit -n openshift-cnv HyperConverged
  2. Edit the HyperConverged CR, specifying the appropriate template and boot source in the dataImportCronTemplates section. For example:

    Example in CentOS 7

    1. apiVersion: hco.kubevirt.io/v1beta1
    2. kind: HyperConverged
    3. metadata:
    4. name: kubevirt-hyperconverged
    5. spec:
    6. dataImportCronTemplates:
    7. - metadata:
    8. name: centos7-image-cron
    9. annotations:
    10. cdi.kubevirt.io/storage.bind.immediate.requested: "true" (1)
    11. spec:
    12. schedule: "0 */12 * * *" (2)
    13. template:
    14. spec:
    15. source:
    16. registry: (3)
    17. url: docker://quay.io/containerdisks/centos:7-2009
    18. storage:
    19. resources:
    20. requests:
    21. storage: 10Gi
    22. managedDataSource: centos7 (4)
    23. retentionPolicy: "None" (5)
    1This annotation is required for storage classes with volumeBindingMode set to WaitForFirstConsumer.
    2Schedule for the job specified in cron format.
    3Use 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.
    4For 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.
    5Use 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.