Skip to content

Commit 302edba

Browse files
authored
Merge pull request #99822 from mburke5678/node-image-volumes
OSDOCS 15329 Image Volume Source for AI Workloads in OpenShift - GA 4.20
2 parents f6c2caf + ffc92bd commit 302edba

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,8 @@ Topics:
26512651
File: nodes-pods-short-term-auth
26522652
- Name: Creating and using config maps
26532653
File: nodes-pods-configmaps
2654+
- Name: Mounting an OCI image into a pod
2655+
File: nodes-pods-image-volume
26542656
- Name: Using Device Manager to make devices available to nodes
26552657
File: nodes-pods-plugins
26562658
Distros: openshift-enterprise,openshift-origin
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * nodes/pods/nodes-pods-image-volume.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="nodes-pods-image-volume-about_{context}"]
7+
= Understanding image volumes
8+
9+
You can you use an _image volume_ to mount an Open Container Initiative (OCI)-compliant container image or artifact directly into a pod, making the files within the image accessible to the containers without the need to include them in the base image. This means you can host the data in an OCI-compliant registry.
10+
11+
By using an image volume in a pod, you can take advantage of the OCI image and distribution specification standards to accomplish several tasks including the following use cases:
12+
13+
//Use cases copied from the enhancement doc: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/4639-oci-volume-source
14+
* You can share configuration files among multiple containers in a pod without needing to include the file in the base image, which minimizes security risks and image size.
15+
16+
* In an artificial intelligence environment, you can use image volumes to mount large language model weights or machine learning model weights in a pod alongside a model-server. You can efficiently serve model weights this way without including them in the model-server container image. Therefore, you can separate the model specifications and content from the executables that process them.
17+
18+
* You can package and distribute binary artifacts and mount them directly into your pods, allowing you to streamline your CI/CD pipeline. This allows you to maintain a small set of base images by attaching the CI/CD artifacts to the image volumes instead.
19+
20+
* You can use a public image for a malware scanner and mount it in a volume of private malware signatures, so that you can load those signatures without incorporating the image into a base image, which might not be allowed by the copyright on the public image.
21+
22+
To mount an image volume, include a path to the image or artifact in your pod spec with an optional pull policy as described in _Adding an image volume to a pod_.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * nodes/pods/nodes-pods-image-volume.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="nodes-pods-image-volume-adding_{context}"]
7+
= Adding an image volume to a pod
8+
9+
To mount an Open Container Initiative (OCI)-compliant container image or artifact, use the `volume` parameter to include a path to the image or artifact in your pod spec with an optional pull policy. You can create the pod directly or use a controlling object, such as a deployment or replica set.
10+
11+
.Procedure
12+
13+
. Create a YAML file similar to the following.
14+
+
15+
[source,yaml]
16+
----
17+
apiVersion: v1
18+
kind: Pod
19+
metadata:
20+
name: image-volume
21+
spec:
22+
containers:
23+
- name: shell
24+
command: ["sleep", "infinity"]
25+
image: debian
26+
volumeMounts:
27+
- name: volume
28+
mountPath: /volume
29+
volumes:
30+
- name: volume
31+
image: <1>
32+
reference: quay.io/crio/artifact:v2 <2>
33+
pullPolicy: Always <3>
34+
----
35+
<1> Specifies an OCI container image or artifact that is available on the host machine.
36+
<2> Specifies the path to the image or artifact.
37+
<3> Specifies a pull policy, one of the following options:
38+
+
39+
--
40+
* If `Always`, the kubelet always attempts to pull the image. If the pull fails, the kubelet sets the pod to `Failed`.
41+
* If `Never`, the kubelet never pulls the image and only uses a local image or artifact. The pod becomes `Failed` if any layers of the image are not present locally, or if the manifest for that image is not already cached.
42+
* If `IfNotPresent` the kubelet pulls the image if it not present. The pod becomes `Failed` if the image is not present and the pull fails. This is the default.
43+
--
44+
// Pull policy details from upstream: https://kubernetes.io/docs/concepts/storage/volumes/#image
45+
46+
. Create the pod by running the following command:
47+
+
48+
[source,terminal]
49+
----
50+
$ oc create -f <file_name>.yaml
51+
----
52+
53+
.Verification
54+
55+
* Examine the pod to view detailed information about the image pull and mount by using a command similar to the following:
56+
+
57+
[source,terminal]
58+
----
59+
$ oc describe pod <pod_name>
60+
----
61+
+
62+
.Example output
63+
[source,yaml]
64+
----
65+
Name: image-volume
66+
Namespace: default
67+
# ...
68+
Volumes:
69+
volume: <1>
70+
Type: Image (a container image or OCI artifact)
71+
Reference: quay.io/crio/artifact:v2
72+
PullPolicy: IfNotPresent
73+
# ...
74+
Events:
75+
Type Reason Age From Message
76+
---- ------ ---- ---- -------
77+
# ...
78+
Normal Pulling 46s kubelet Pulling image "quay.io/crio/artifact:v2"
79+
Normal Pulled 44s kubelet Successfully pulled image "quay.io/crio/artifact:v2" in 2.261s (2.261s including waiting). Image size: 6707 bytes. <2>
80+
# ...
81+
----
82+
<1> Indicates that the image volume was mounted to the pod.
83+
<2> Indicates that the image was successfully pulled.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
:context: nodes-pods-node-selectors
3+
[id="nodes-pods-image-volume"]
4+
= Mounting an OCI image into a pod
5+
include::_attributes/common-attributes.adoc[]
6+
7+
toc::[]
8+
9+
10+
You can mount an Open Container Initiative (OCI)-compliant container image or artifact directly into a pod, making the files within the image accessible to the containers without the need to include them in the base image, which allows you to host the data in OCI-compliant registries.
11+
12+
// The following include statements pull in the module files that comprise
13+
// the assembly. Include any combination of concept, procedure, or reference
14+
// modules required to cover the user story. You can also include other
15+
// assemblies.
16+
17+
include::modules/nodes-pods-image-volume-about.adoc[leveloffset=+1]
18+
19+
include::modules/nodes-pods-image-volume-adding.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)