subPath 挂载 上面那个镜像里放了两个模型目录如果 Pod 只需要 Qwen2-0.5B不需要把整个镜像都挂进来用 subPath 就行apiVersion: v1 kind: Pod metadata: name: image-volume-subpath spec: containers: - name: app image: busybox:1.36 command: [sleep, 3600] volumeMounts: - name: model-volume mountPath: /models/qwen2 subPath: Qwen2-0.5B readOnly: true volumes: - name: model-volume image: reference: registry.example.com/demo/image-volume:v1 pullPolicy: IfNotPresent验证一下挂载目录里只有 Qwen2-0.5B 的内容$ kubectl exec image-volume-subpath -- ls -la /models/qwen2/ total 12 drwxr-xr-x 2 root root 4096 Jun 16 13:03 . drwxr-xr-x 3 root root 4096 Jun 16 13:03 .. -rw-r--r-- 1 root root 14 Jun 16 13:03 config.json -rw-r--r-- 1 root root 22 Jun 16 13:03 model.bin $ kubectl exec image-volume-subpath -- cat /models/qwen2/config.json qwen2 config只挂载了 Qwen2-0.5B 目录Llama2-7B 和 app.conf 都不在。如果 subPath 指定的路径在镜像中不存在容器创建会直接报错$ kubectl get pod image-volume-subpath-err -o jsonpath{.status.containerStatuses[0].state.waiting.message} failed to mount image volume: ImageVolumeMountFailed: failed to ensure image subpath not-exist-dir in ...: openat not-exist-dir: no such file or directory3.5 只读挂载验证ImageVolume 挂载是只读的尝试写入会报Read-only file system$ kubectl exec image-volume-demo -- sh -c echo test /models/test.txt sh: cant create /models/test.txt: Read-only file system最后提几个实际使用中的注意事项。ImageVolume 挂载是只读的如果需要运行时修改文件还是得用 PVC目前没有读写支持的 KEP。Pod 重建时 ImageVolume 会重新解析远端镜像所以生产环境建议用 digest 而不是 tag 引用镜像避免 Pod 重建后 tag 被覆盖导致拿到非预期版本。镜像层共享能省磁盘两个 ImageVolume 引用的镜像有相同层的话 containerd 只存一份但大模型镜像多了也要注意节点磁盘压力。4. 小结OCI 从 2017 年 image-spec v1.0 发布到今天走了一条挺清晰的路先是容器镜像格式标准化然后 OCI Registry 被社区 hack 成通用内容仓库接着 image-spec v1.1.0 和 distribution-spec v1.1.0 把这种用法正式写入规范artifactType referrers API。OCI Artifacts 从社区变通变成了标准的一部分。ImageVolume GA 等于 Kubernetes 也跟上了OCI Artifacts 在 K8s 里有了第一个原生的消费方式。往后看读写支持可能是下一个方向目前只读挂载还是限制了些场景社区已经有相关讨论。另外ImageVolumeWithDigest子特性在 v1.36 也 GA 了Pod Status 里能直接看到挂载镜像的 digest版本追溯方便不少。