Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions content/en/docs/concepts/storage/volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,10 @@ volume with file execution blocked (`noexec`).

Besides that:

- Sub path mounts for containers are not supported
(`spec.containers[*].volumeMounts.subpath`).
- [`subPath`](/docs/concepts/storage/volumes/#using-subpath) or
[`subPathExpr`](/docs/concepts/storage/volumes/#using-subpath-expanded-environment)
mounts for containers (`spec.containers[*].volumeMounts.[subPath,subPathExpr]`)
are only supported from Kubernetes v1.33.
- The field `spec.securityContext.fsGroupChangePolicy` has no effect on this
volume type.
- The [`AlwaysPullImages` Admission Controller](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ stages:
- stage: alpha
defaultValue: false
fromVersion: "1.31"
toVersion: "1.32"
- stage: beta
defaultValue: false
fromVersion: "1.33"
---
Allow using the [`image`](/docs/concepts/storage/volumes/) volume source in a Pod.
This volume source lets you mount a container image as a read-only volume.
33 changes: 33 additions & 0 deletions content/en/docs/tasks/configure-pod-container/image-volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,39 @@ to a valid reference and consuming it in the `volumeMounts` of the container. Fo
2
```

## Use `subPath` (or `subPathExpr`)

It is possible to utilize
[`subPath`](/docs/concepts/storage/volumes/#using-subpath) or
[`subPathExpr`](/docs/concepts/storage/volumes/#using-subpath-expanded-environment)
from Kubernetes v1.33 when using the image volume feature.

{{% code_sample file="pods/image-volumes-subpath.yaml" %}}

1. Create the pod on your cluster:

```shell
kubectl apply -f https://k8s.io/examples/pods/image-volumes-subpath.yaml
```

1. Attach to the container:

```shell
kubectl attach -it image-volume bash
```

1. Check the content of the file from the `dir` sub path in the volume:

```shell
cat /volume/file
```

The output is similar to:

```none
1
```

## Further reading

- [`image` volumes](/docs/concepts/storage/volumes/#image)
18 changes: 18 additions & 0 deletions content/en/examples/pods/image-volumes-subpath.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: image-volume
spec:
containers:
- name: shell
command: ["sleep", "infinity"]
image: debian
volumeMounts:
- name: volume
mountPath: /volume
subPath: dir
volumes:
- name: volume
image:
reference: quay.io/crio/artifact:v1
pullPolicy: IfNotPresent