This topic describes how to create and manage VCI image caches by using CustomResourceDefinition (CRD) resources in Kubernetes.
Prerequisites
- The container image required to create the VCI has been prepared. You can use images from Volcano Engine CR as well as images from third-party container registries. To upload an image to CR, see Pushing and pulling images.
Create a VCI image cache based on ImageCache
- Create a custom resource ImageCache that will be used to create the VCI image cache. The following imagecache-test.yaml file serves as an example:
- Run the following command to create the ImageCache.
Associating an existing VCI image cache by using ImageCache
- Create a custom resource ImageCache and associate it with an existing VCI image cache. The following imagecache-exist.yaml file serves as an example:
- Run the following command to create the ImageCache.
Querying ImageCache status and latest details
After a VCI image cache is created, the ImageCache Controller will obtain the latest information of the image cache and synchronize it to the description of the ImageCache. You can run the get ImageCache command to get the latest status and information of the image cache.
tip
- The status of the image cache after creation will be written back to the status field of the corresponding ImageCache custom resource.
- If the image cache information is updated via the UpdateImageCache API, the information of the corresponding ImageCache resource will also be refreshed.
- When the image cache is deleted or cleaned up, the status of the custom resource object is updated. The custom resource object is not deleted.
The following content provides an example of the custom resource ImageCache.
Deleting VCI image caches via ImageCache
When you delete the ImageCache resource using the delete command, the ImageCache Controller will also delete the corresponding VCI image cache.
The following example command deletes a resource ImageCache named imagecache-test. After the command is executed, the VCI image cache corresponding to imagecache-test will be deleted.
Updating VCI image caches via ImageCache
When you update an ImageCache resource, the ImageCache Controller will also update the corresponding VCI image cache.
tip
- When the status of the image cache is Ready, you must modify the images field (other fields can also be modified) to trigger the image cache update.
- When the status of the image cache is Failed, modifying any updatable field in the YAML below will trigger an image cache update.
For a list of fields that support updates, see the comments in the YAML file below (except for fields with the comment It cannot be updated, all other fields with comments support updates).
Automatically updating VCI image caches based on event notifications
When creating an ImageCache corresponding to a VCI image cache, you can configure CR event notification rules to enable automatic updates of the VCI image cache based on event notifications.
- Create an ImageCache corresponding to the VCI image cache and configure CR event notification rules. The following imagecache-test.yaml file serves as an example:
- Run the following command to create the ImageCache.
- The following sample code provides an example of the status field returned when you query the ImageCache containing CR event notification rules. For information about how to query the information, see Querying ImageCache status and latest details.