Skip to content

Commit 9c3285f

Browse files
committed
Add ImageVolume documentation
Add a basic task how to use image volumes in pods. Signed-off-by: Sascha Grunert <[email protected]>
1 parent be3a417 commit 9c3285f

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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`
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

0 commit comments

Comments
 (0)