ContentLibraryConfig document. The files in it are managed over the Talos API with talosctl hypervisor content-library.
This page shows how to create a library, and how to upload, verify, list, replace, and delete its files.
In the commands on this page, replace <host-ip> with the IP address of the host that stores the library.
Create a content library
A content library lives on a Talos volume, and its files are stored at the root of that volume. The volume is declared in its own document, which can be one of the following:- A
UserVolumeConfig, for a directory, partition, or disk on the host. - An
ExistingVolumeConfig, for a volume that already exists on the host. - An
ExternalVolumeConfig, for a volume mounted from outside the host, such as an NFS export. NFS support was added in Talos Linux v1.15.
-
Run the following command to create
content-library.yaml, which declares a directory volume namedvm-imagesand a content library namedimagesthat uses it:Thebacking.volumefield names the volume the library uses. The volume must follow these rules:- It backs only one content library. Use a separate volume for each content library and each storage pool.
- It is writable, because uploads write into it.
nameis its ID in the Talos API. It can contain only ASCII letters, digits, and hyphens, and can be up to 63 characters long. -
Apply the documents to the host:
-
Check that the library is ready:
Talos reports the library’s state in a
ContentLibraryStatusresource, with the following columns:PHASEisreadyonce the volume is mounted and the library accepts uploads.PATHis where the library’s files are stored on the host.ERRORexplains why a library is not ready.VOLUMEis the volume’s ID, which Talos derives from its name. For example, aUserVolumeConfignamedvm-imageshas the IDu-vm-images.
Manage images
The commands in this section use theimages library from Create a content library.
Upload an image
To upload a file into a content library, pass the library name and the path to the file:talosctl prints the SHA-256 and SHA-512 digests of the file the host received.
The file keeps its own name in the library. To change the name or the source, add these options:
- To store the file under a different name, add
--name <name>. - To upload from standard input, pass
-as the file and set its name with--name.
- It cannot contain a path separator.
- It cannot start with a dot.
- It can be up to 230 characters long.
Verify an upload
To have the host check an upload, add--digest with the file’s expected digest. The digest takes the form sha256:<checksum> or sha512:<checksum>, where <checksum> is the file’s checksum in hexadecimal.
The following example verifies a replacement of the file uploaded in the previous section, so it also includes --overwrite:
talosctl prints the digests of what the host received. Comparing those digests with the expected one shows whether the download was corrupted or the digest was mistyped.
Replace an image
The host refuses an upload whose name already exists in the library. To replace the existing file, add--overwrite:
List images
To list the files in a library, run:Delete an image
To delete a file from a library, run:- The virtual machine is removed.
- The virtual machine’s
powerStateis set tostopped. - The disk that uses the file is removed, or changed to use a different file.
Pin an image to a digest
A virtual machine refers to a library file by name, in theprovision.fromImage section of a disk. A file can be replaced while no running virtual machine uses it, so a virtual machine can start with a different file under the same name.
To make sure a virtual machine uses one exact file, add the file’s digest to the disk. Replace <checksum> with the file’s SHA-256 checksum:
- A virtual machine that is not running does not start.
- A running virtual machine is stopped.