An image volume exposes the files in an OCI image as a volume mounted into containers in the same pod. Containers can read these files but cannot write to them, making the type useful for static or large files such as model weights or database initialization scripts. section 9.3.1 section 9.7
The volume is declared at pod level and mounted by individual containers. Unlike an emptyDir volume populated by an init container, an image volume needs no file-copying helper: the kubelet obtains the referenced image and exposes its contents at the mount path. section 9.3.1 section 9.1.2
Listing 9.8 Defining an image volume in a pod manifest
apiVersion: v1
kind: Pod
metadata:
name: quiz
spec:
volumes:
- name: initdb #1
image: #1
reference: luksa/quiz-questions:latest #2
pullPolicy: Always #3
- name: quiz-data
emptyDir: {}
containers:
- name: quiz-api
image: luksa/quiz-api:0.1
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
- name: mongo
image: mongo:7
volumeMounts:
- name: quiz-data
mountPath: /data/db
- name: initdb #4
mountPath: /docker-entrypoint-initdb.d/ #4
readOnly: true #4
A complete pod manifest shows the image reference, pull policy, container mount, and read-only setting. section 9.3.1
Providing MongoDB initialization files
A quiz pod uses luksa/quiz-questions:latest as an image volume and mounts it in MongoDB at /docker-entrypoint-initdb.d/. Inspecting that directory reveals insert-questions.js, while kubectl describe pod shows the image being pulled before the application containers start. section 9.3.1
The feature is not automatically available in every cluster. The administrator must enable the ImageVolume feature gate; otherwise, manifests may accept the fields while the volume does not work. Current support covers image artifacts, while broader OCI artifact support is planned. section 9.3 section 9.3.1
