Importing a Virtual Machine Image from an HTTPS Server with a Self-Signed Certificate
Use this procedure when the virtual machine image (qcow2 or raw) is served over HTTPS by a
server whose certificate is self-signed or issued by a private CA — a common setup for an
internal file server. CDI (Containerized Data Importer), which downloads the image, verifies the
server's TLS certificate and has no option to skip that verification for HTTP sources. An
untrusted certificate makes the import fail with:
The supported way to make such an import succeed is to give CDI the certificate through a
ConfigMap referenced from the DataVolume with spec.source.http.certConfigMap. The importer
adds the certificate to its trust store and verifies the server against it — hostname
verification stays on, nothing is bypassed.
How it works
spec.source.http.certConfigMapnames aConfigMapin the same namespace as theDataVolume. It cannot point to another namespace.- CDI mounts the
ConfigMapinto the importer pod and loads every key in it as PEM certificates (keys starting with.are ignored). Name the keytls.crt: since CDI 1.64 the importer also hands the certificate tonbdkit, which inspects the image size before the download starts and reads exactlytls.crt. Any other key name still imports successfully, but that pre-download size check is skipped (an oversized image is only rejected after it has been downloaded) and the importer log showsProblem with the SSL CA certlines fromnbdkit. One key may hold several concatenated PEM blocks, so a private CA chain (root plus intermediates) can be supplied in one key. - The certificate is added to the importer's system trust store, so public HTTPS sources keep working from the same importer.
- The field works the same in a standalone
DataVolumeand inside aVirtualMachinedataVolumeTemplatesentry, and is available on every CDI version shipped with Alauda Container Platform (it predates CDI 1.62).
Constraints
- An image source cannot carry a certificate; an image instance can. An image source added
under Administrator > Virtualization > Images > Image Source with an HTTPS URL of
a self-signed server is accepted, but a virtual machine created directly from it gets a
dataVolumeTemplatesentry with onlyhttp.urland fails with thex509error above (the Create Virtual Machine form points this out). Instead, add an Image Instance with the CA Certificate — in the console (see Adding Image Instances) or with the YAML of Step 4 — and create virtual machines from it: they are clones that never contact the HTTPS server. - There is no cluster-wide "trust this CA for all imports" setting: CDI only consults extra
certificates when the
DataVolumeitself references aConfigMap. - The certificate's Subject Alternative Name (SAN) must contain the host you use in the URL — a DNS name or an IP address. A certificate without a matching SAN is rejected even when it is trusted (see Troubleshooting).
- A
DataVolumespecis immutable, so a missingcertConfigMapcannot be patched in. For a standaloneDataVolume, delete it and create it again. For aDataVolumeowned by a virtual machine, first addcertConfigMapto the virtual machine'sdataVolumeTemplates, then delete theDataVolume; the virtual machine controller recreates it from the updated template. Deleting theDataVolumealone without changing the template recreates it without the certificate.
Prerequisites
- The server's certificate in PEM format: for a self-signed server the server certificate itself; for a private CA, the CA certificate (and intermediates, if any). Ask the server owner for the file, or fetch it from the server (Step 1).
- The
kubectlcommand-line tool, configured to access the cluster where virtualization runs. - A
StorageClassfor the virtual machine disk. - The HTTPS server is reachable from the cluster nodes (CDI downloads from an importer pod).
Procedure
Obtain and check the certificate
If you do not already have the PEM file, download the certificate the server presents:
For a private CA, use the CA certificate the server owner provides instead of the server certificate. Then confirm that the host you will put in the image URL is listed in the SAN:
Use a host from that list in the URL — https://images.example.internal/... or
https://192.168.10.20/... in this example. If the address you need is missing, have the
certificate re-issued with it; CDI does not relax hostname checks.
Create the certificate ConfigMap
Create the ConfigMap in the namespace where the DataVolume (or the virtual machine) will live:
For a CA chain, concatenate the PEM files into one before creating the ConfigMap
(cat intermediate.crt root.crt > chain.crt, then --from-file=tls.crt=chain.crt).
Create a virtual machine that imports the image directly
Reference the ConfigMap from the virtual machine's dataVolumeTemplates. Deleting the virtual
machine also deletes the imported disk.
A DataVolume alone works the same way — put the same source.http block under
spec.source of a DataVolume object.
(Optional) Import once as a golden image for the console
To let console users create virtual machines from this image, import it once into kube-public
and publish it as a DataSource — an Image Instance.
In the console: under Administrator > Virtualization > Images > Image Instance,
click Add Image Instance, choose Source > Network > HTTP (or an image source with
the HTTPS URL), enter the URL and paste the certificate into CA Certificate. The console
inspects the certificate in the browser — subject, validity, Subject Alternative Names and
fingerprint, with a warning when the host of the URL is not in the SAN — and creates the
ConfigMap <name>-img-ca (key tls.crt), the DataVolume and the DataSource for you. To keep
the image in one namespace instead, add it under Container Platform > Virtualization >
Images > Image Instance of that namespace.
With kubectl: create the objects below. The labels make the DataSource show up as an
Image Instance and in the Create VM form's Provision Method > Image Instance picker;
the ConfigMap is created in kube-public because the DataVolume lives there.
Virtual machines created from the Image Instance clone the kube-public volume
(dataVolumeTemplates[].spec.sourceRef pointing at the DataSource); the HTTPS server and its
certificate are only involved in this one-time import.
Troubleshooting
Read the importer's error from the DataVolume conditions — the phase stays ImportInProgress
while CDI retries and the RESTARTS column keeps growing:
Because the DataVolume spec cannot be edited, apply the fix by deleting and re-creating the
DataVolume (or the virtual machine that owns it through dataVolumeTemplates).