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 gives you 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 storage plugin.
Note that CRI-O falls back to a standard image pull in the following cases:
-
The registry does not support HTTP range requests.
-
The image is in standard OCI format, not a lazy-pull-compatible format such as eStargz or Nydus.
-
The storage plugin is not running.
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.