Skip to content

Commit 8bc524c

Browse files
authored
Merge pull request #49984 from saschagrunert/k8s-1.33-blog-image-volume-beta
[KEP-4639] Feature blog 1.33: Image volumes graduate to beta
2 parents 6ec9eac + 0630c9d commit 8bc524c

File tree

1 file changed

+107
-0
lines changed
  • content/en/blog/_posts/2025-05-01-image-volume-beta

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
layout: blog
3+
title: "Kubernetes v1.33: Image Volumes graduate to beta!"
4+
date: 2025-05-01
5+
draft: true
6+
slug: kubernetes-1-33-image-volume-beta
7+
author: Sascha Grunert (Red Hat)
8+
---
9+
10+
[Image Volumes](/blog/2024/08/16/kubernetes-1-31-image-volume-source) were
11+
introduced as an Alpha feature with the Kubernetes v1.31 release as part of
12+
[KEP-4639](https://github.com/kubernetes/enhancements/issues/4639). In Kubernetes v1.33, this feature graduates to **beta**.
13+
14+
Please note that the feature is still _disabled_ by default, because not all
15+
[container runtimes](/docs/setup/production-environment/container-runtimes) have
16+
full support for it. [CRI-O](https://cri-o.io) supports the initial feature since version v1.31 and
17+
will add support for Image Volumes as beta in v1.33.
18+
[containerd merged](https://github.com/containerd/containerd/pull/10579) support
19+
for the alpha feature which will be part of the v2.1.0 release and is working on
20+
beta support as part of [PR #11578](https://github.com/containerd/containerd/pull/11578).
21+
22+
### What's new
23+
24+
The major change for the beta graduation of Image Volumes is the support for
25+
[`subPath`](/docs/concepts/storage/volumes/#using-subpath) and
26+
[`subPathExpr`](/docs/concepts/storage/volumes/#using-subpath-expanded-environment) mounts
27+
for containers via `spec.containers[*].volumeMounts.[subPath,subPathExpr]`. This
28+
allows end-users to mount a certain subdirectory of an image volume, which is
29+
still mounted as readonly (`noexec`). This means that non-existing
30+
subdirectories cannot be mounted by default. As for other `subPath` and
31+
`subPathExpr` values, Kubernetes will ensure that there are no absolute path or
32+
relative path components part of the specified sub path. Container runtimes are
33+
also required to double check those requirements for safety reasons. If a
34+
specified subdirectory does not exist within a volume, then runtimes should fail
35+
on container creation and provide user feedback by using existing kubelet
36+
events.
37+
38+
Besides that, there are also three new kubelet metrics available for image volumes:
39+
40+
- `kubelet_image_volume_requested_total`: Outlines the number of requested image volumes.
41+
- `kubelet_image_volume_mounted_succeed_total`: Counts the number of successful image volume mounts.
42+
- `kubelet_image_volume_mounted_errors_total`: Accounts the number of failed image volume mounts.
43+
44+
To use an existing subdirectory for a specific image volume, just use it as
45+
[`subPath`](/docs/concepts/storage/volumes/#using-subpath) (or
46+
[`subPathExpr`](/docs/concepts/storage/volumes/#using-subpath-expanded-environment))
47+
value of the containers `volumeMounts`:
48+
49+
```yaml
50+
apiVersion: v1
51+
kind: Pod
52+
metadata:
53+
name: image-volume
54+
spec:
55+
containers:
56+
- name: shell
57+
command: ["sleep", "infinity"]
58+
image: debian
59+
volumeMounts:
60+
- name: volume
61+
mountPath: /volume
62+
subPath: dir
63+
volumes:
64+
- name: volume
65+
image:
66+
reference: quay.io/crio/artifact:v2
67+
pullPolicy: IfNotPresent
68+
```
69+
70+
Then, create the pod on your cluster:
71+
72+
```shell
73+
kubectl apply -f image-volumes-subpath.yaml
74+
```
75+
76+
Now you can attach to the container:
77+
78+
```shell
79+
kubectl attach -it image-volume bash
80+
```
81+
82+
And check the content of the file from the `dir` sub path in the volume:
83+
84+
```shell
85+
cat /volume/file
86+
```
87+
88+
The output will be similar to:
89+
90+
```none
91+
1
92+
```
93+
94+
Thank you for reading through the end of this blog post! SIG Node is proud and
95+
happy to deliver this feature graduation as part of Kubernetes v1.33.
96+
97+
As writer of this blog post, I would like to emphasize my special thanks to
98+
**all** involved individuals out there!
99+
100+
If you would like to provide feedback or suggestions feel free to reach out
101+
to SIG Node using the [Kubernetes Slack (#sig-node)](https://kubernetes.slack.com/messages/sig-node)
102+
channel or the [SIG Node mailing list](https://groups.google.com/g/kubernetes-sig-node).
103+
104+
## Further reading
105+
106+
- [Use an Image Volume With a Pod](/docs/tasks/configure-pod-container/image-volumes)
107+
- [`image` volume overview](/docs/concepts/storage/volumes/#image)

0 commit comments

Comments
 (0)