×

You can use boot sources that are system-defined and included with OpenShift Virtualization or user-defined, which you create. System-defined boot source imports and updates are controlled by the product feature gate. You can enable, disable, or re-enable updates using the feature gate. User-defined boot sources are not controlled by the product feature gate and must be individually managed to opt in or opt out of automatic imports and updates.

You must set a default storage class for automatic import and update of boot sources.

Enabling automatic boot source updates

If you have pre-defined boot sources from OpenShift Virtualization 4.9, then you must manually opt them in to the automatic boot source updates. All pre-defined boot sources from OpenShift 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

OpenShift 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:

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