To reduce application startup time and make your applications run more efficiently, you can configure additional storage locations for the CRI-O container engine.
By using storage locations for the CRI-O container engine other than the default you gain control over where CRI-O stores and retrieves OCI artifacts, complete container images, and container image layers. Using additional storage locations for these CRI-O objects can reduce application startup time and make your applications run more efficiently through dedicated solid-state drive (SSD) storage, shared image caches, or lazy pulling.
By default, CRI-O stores all container data under a single root directory, /var/lib/containers/storage. This works well for typical workloads, but can create problems in clusters that use large images or artifacts, such as artificial intelligence and machine learning (AI/ML) workloads.
For example, large OCI artifacts, such as machine learning models, are stored in the default location, consuming space and preventing the use of faster dedicated storage. By configuring the additionalArtifactStores field, you can store large AI/ML models on high-performance solid-state drives (SSD) separate from the root file system. As a result, your workloads can experience faster start times and your clusters can use storage more efficiently.
Also, you could use the additionalImageStores field to mount an NFS share with prepopulated images across all worker nodes. Nodes read from the shared cache instead of pulling from an external registry. This is useful in disconnected environments or when many nodes run the same workloads.
With the additionalLayerStores field, you could enable lazy pulling through a third-party storage plugin, such as stargz-store. With lazy pulling, containers start after downloading only the required file chunks. The remaining data is fetched during runtime.
After you configure any of these new storage locations, the Machine Config Operator (MCO) reboots the affected nodes with the new configuration. After the reboot, CRI-O begins resolving storage from the additional locations.
- Additional storage for OCI artifacts
-
Use the additionalArtifactStores field in a container runtime config to specify read-only locations where CRI-O resolves OCI artifacts, such as machine learning models pulled as OCI volume images. CRI-O checks these locations in order before falling back to the default storage location. CRI-O requires an existing, prepopulated artifacts/ subdirectory within each configured path. For example, if the path is /mnt/ssd-artifacts, place the artifacts in the /mnt/ssd-artifacts/artifacts/ directory.
The following example container runtime config configures storage for OCI artifacts.
apiVersion: machineconfiguration.openshift.io/v1
kind: ContainerRuntimeConfig
metadata:
name: ssd-artifact-stores
spec:
machineConfigPoolSelector:
matchLabels:
pools.operator.machineconfiguration.openshift.io/worker: ""
containerRuntimeConfig:
additionalArtifactStores:
- path: /mnt/ssd-artifacts
- path: /mnt/nfs-shared-artifacts
When you create the container runtime config, the Machine Config Operator (MCO) writes the configuration to the /etc/crio/crio.conf.d/01-ctrcfg-additionalArtifactStores file on the target nodes.
- Additional storage for container images
-
Use the additionalImageStores field to specify read-only container image caches on shared or high-performance storage. When CRI-O needs an image, it checks the additional image stores first. If the image exists there, no registry pull happens.
The following example container runtime config configures storage for container images.
apiVersion: machineconfiguration.openshift.io/v1
kind: ContainerRuntimeConfig
metadata:
name: shared-image-cache
spec:
machineConfigPoolSelector:
matchLabels:
pools.operator.machineconfiguration.openshift.io/worker: ""
containerRuntimeConfig:
additionalImageStores:
- path: /mnt/nfs-image-cache
- path: /mnt/ssd-images
When you create the container runtime config, the Machine Config Operator (MCO) writes the configuration to the /etc/containers/storage.conf file on the target nodes.
- Additional container image layers for lazy pulling
-
Use the additionalLayerStores field to enable lazy pulling through a third-party Bring Your Own storage (BYOS) plugin. With lazy pulling, you can start a container without waiting for the entire image to be downloaded. Instead, the necessary parts of the image are fetched on-demand during runtime using FUSE.
External BYOS plugins, such as stargz-snapshotter and nydus-storage-plugin, serve container image layers on-demand through a FUSE file system. The additionalLayerStores field configures the FUSE mount paths for CRI-O.
When CRI-O needs an image, it accesses the plugin’s FUSE file system, triggering metadata download and lazy pulling. The container starts after downloading only the required chunks.
|
|
If you are using the Linux native zstd:chunked format for partial pulling, you do not need to configure the additionalLayerStores field. With partial pulling, CRI-O retrieves the chunk metadata, determines which chunks are needed, and fetches only those chunks by using HTTP range requests rather than downloading the entire compressed layer.
|
To use lazy pulling, you must install a BYOS plugin on your nodes. Then, create a container runtime config to configure the FUSE mount paths.
The following example container runtime config configures container image layers for lazy pulling.
apiVersion: machineconfiguration.openshift.io/v1
kind: ContainerRuntimeConfig
metadata:
name: lazy-pulling
spec:
machineConfigPoolSelector:
matchLabels:
pools.operator.machineconfiguration.openshift.io/worker: ""
containerRuntimeConfig:
additionalLayerStores:
- path: /var/lib/stargz-store
When you create the container runtime config, the Machine Config Operator (MCO) writes the configuration to the /etc/containers/storage.conf file on the target nodes.
Limitations and known issues with additional CRI-O storage locations
When working with additional CRI-O storage locations, make note of the limitations and known issues that could affect your cluster.
The following limitations and known issues have been identified for additional CRI-O storage:
-
Lazy pulling and partial pulling rely on HTTP range requests. As such, your registry must support HTTP range requests. If not supported, CRI-O falls back to standard image pulls.
-
When using an additional layer store for Bring Your Own storage (BYOS) lazy pulling, you must convert the pulled container images from the standard OCI format to a compatible format, such as the eStargz or Nydus formats.
-
The zstd:chunked format performs partial pulling, where CRI-O fetches only the missing chunks before the container starts, skipping content already present from prior pulls. Partial pulling does not use the additionalLayerStores field.
-
After you configure additional CRI-O storage, the Machine Config Operator (MCO) reboots the affected nodes with the new configuration.
-
Container creation can be impacted if your storage plugin crashes or hangs. For more information, see "Troubleshoot additional CRI-O storage locations".
-
The additional layer store API is experimental in the upstream containers/storage project. Breaking changes are possible.
-
Multiple ContainerRuntimeConfig resources affecting the same configuration file might result in only a subset of the changes taking effect.
-
This feature is not supported for Red Hat build of MicroShift (MicroShift), which does not use the MCO.
-
If you need to downgrade your cluster to OKD version 4.21 or earlier, before you downgrade, delete any ContainerRuntimeConfig resource that includes the additionalArtifactStores, additionalImageStores, or additionalLayerStores fields.