File tree Expand file tree Collapse file tree 3 files changed +102
-0
lines changed
reference/command-line-tools-reference/feature-gates
tasks/configure-pod-container Expand file tree Collapse file tree 3 files changed +102
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : ImageVolume
3+ content_type : feature_gate
4+ _build :
5+ list : never
6+ render : false
7+
8+ stages :
9+ - stage : alpha
10+ defaultValue : false
11+ fromVersion : " 1.31"
12+ ---
13+ Enable the ` ImageVolumeSource ` API to be able to use ` pod.spec.volumes[*].image `
Original file line number Diff line number Diff line change 1+ ---
2+ title : Use an Image Volume With a Pod
3+ reviewers :
4+ content_type : task
5+ weight : 210
6+ min-kubernetes-server-version : v1.31
7+ ---
8+
9+ <!-- overview -->
10+
11+ {{< feature-state feature_gate_name="ImageVolume" >}}
12+
13+ This page shows how to configure a pod using image volumes. This allows you to
14+ mount content from OCI registries inside containers.
15+
16+ The feature has been developed as part of [ Kubernetes enhancement #4639 ] ( https://kep.k8s.io/4639 ) .
17+
18+ ## {{% heading "prerequisites" %}}
19+
20+ {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
21+
22+ {{% thirdparty-content single="true" %}}
23+
24+ - The node OS needs to be Linux
25+ - The container runtime needs to support the image volumes feature.
26+ - You need to exec commands in the host
27+ - You need to be able to exec into pods
28+ - You need to enable the ` ImageVolume ` [ feature gate] ( /docs/reference/command-line-tools-reference/feature-gates/ )
29+
30+ <!-- steps -->
31+
32+ ## Run a Pod that uses an image volume {#create-pod}
33+
34+ An image volume for a pod is enabled setting the ` volumes.[*].image ` field of ` .spec `
35+ to a valid reference and consuming it in the ` volumeMounts ` of the container. For example:
36+
37+ {{% code_sample file="pods/image-volumes.yaml" %}}
38+
39+ 1 . Create the pod on your cluster:
40+
41+ ``` shell
42+ kubectl apply -f https://k8s.io/examples/pods/image-volumes.yaml
43+ ```
44+
45+ 1 . Attach to the container:
46+
47+ ``` shell
48+ kubectl attach -it image-volume bash
49+ ```
50+
51+ Run this command:
52+
53+ ``` shell
54+ cat /volume/dir/file
55+ ```
56+
57+ The output is similar to:
58+
59+ ``` shell
60+ 1
61+ ```
62+
63+ Also run:
64+
65+ ``` shell
66+ cat /volume/file
67+ ```
68+
69+ The output is similar to:
70+
71+ ``` shell
72+ 2
73+ ```
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ name : image-volume
5+ spec :
6+ containers :
7+ - name : shell
8+ command : ["sleep", "infinity"]
9+ image : debian
10+ volumeMounts :
11+ - name : volume
12+ mountPath : /volume
13+ volumes :
14+ - name : volume
15+ image :
16+ reference : quay.io/saschagrunert/artifact:v1
You can’t perform that action at this time.
0 commit comments