Skip to content

Commit ca9e472

Browse files
committed
KEP-3857: Recursive Read-only (RRO) mounts
Signed-off-by: Akihiro Suda <[email protected]>
1 parent d665f92 commit ca9e472

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

content/en/docs/concepts/storage/volumes.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,65 @@ in `containers[*].volumeMounts`. Its values are:
12131213
(unmounted) by the containers on termination.
12141214
{{< /warning >}}
12151215

1216+
## Read-only mounts
12161217

1218+
A mount can be made read-only by setting the `.spec.containers[].volumeMounts[].readOnly`
1219+
field to `true`.
1220+
This does not make the volume itself read-only, but that specific container will
1221+
not be able to write to it.
1222+
Other containers in the Pod may mount the same volume as read-write.
1223+
1224+
On Linux, read-only mounts are not recursively read-only by default.
1225+
For example, consider a Pod which mounts the hosts `/mnt` as a `hostPath` volume. If
1226+
there is another filesystem mounted read-write on `/mnt/<SUBMOUNT>` (such as tmpfs,
1227+
NFS, or USB storage), the volume mounted into the container(s) will also have a writeable
1228+
`/mnt/<SUBMOUNT>`, even if the mount itself was specified as read-only.
1229+
1230+
### Recursive read-only mounts
1231+
1232+
{{< feature-state feature_gate_name="RecursiveReadOnlyMounts" >}}
1233+
1234+
Recursive read-only mounts can be enabled by setting the
1235+
`RecursiveReadOnlyMounts` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
1236+
for kubelet and kube-apiserver, and setting the `.spec.containers[].volumeMounts[].recursiveReadOnly`
1237+
field for a pod.
1238+
1239+
The allowed values are:
1240+
1241+
* `Disabled` (default): no effect.
1242+
1243+
* `Enabled`: makes the mount recursively read-only.
1244+
Needs all the following requirements to be satisfied:
1245+
* `readOnly` is set to `true`
1246+
* `mountPropagation` is unset, or, set to `None`
1247+
* The host is running with Linux kernel v5.12 or later
1248+
* The [CRI-level](/docs/concepts/architecture/cri) container runtime supports recursive read-only mounts
1249+
* The OCI-level container runtime supports recursive read-only mounts.
1250+
It will fail if any of these is not true.
1251+
1252+
* `IfPossible`: attempts to apply `Enabled`, and falls back to `Disabled`
1253+
if the feature is not supported by the kernel or the runtime class.
1254+
1255+
Example:
1256+
{{% code_sample file="storage/rro.yaml" %}}
1257+
1258+
When this property is recognized by kubelet and kube-apiserver,
1259+
the `.status.containerStatuses[].volumeMounts[].recursiveReadOnly` field is set to either
1260+
`Enabled` or `Disabled`.
1261+
1262+
1263+
#### Implementations {#implementations-rro}
1264+
1265+
{{% thirdparty-content %}}
1266+
1267+
The following container runtimes are known to support recursive read-only mounts.
1268+
1269+
CRI-level:
1270+
- [containerd](https://containerd.io/), since v2.0
1271+
1272+
OCI-level:
1273+
- [runc](https://runc.io/), since v1.1
1274+
- [crun](https://github.com/containers/crun), since v1.8.6
12171275

12181276
## {{% heading "whatsnext" %}}
12191277

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: RecursiveReadOnlyMounts
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.30"
12+
---
13+
Enables support for recursive read-only mounts.
14+
For more details, see [read-only mounts](/docs/concepts/storage/volumes/#read-only-mounts).

content/en/examples/storage/rro.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: rro
5+
spec:
6+
volumes:
7+
- name: mnt
8+
hostPath:
9+
# tmpfs is mounted on /mnt/tmpfs
10+
path: /mnt
11+
containers:
12+
- name: busybox
13+
image: busybox
14+
args: ["sleep", "infinity"]
15+
volumeMounts:
16+
# /mnt-rro/tmpfs is not writable
17+
- name: mnt
18+
mountPath: /mnt-rro
19+
readOnly: true
20+
mountPropagation: None
21+
recursiveReadOnly: Enabled
22+
# /mnt-ro/tmpfs is writable
23+
- name: mnt
24+
mountPath: /mnt-ro
25+
readOnly: true
26+
# /mnt-rw/tmpfs is writable
27+
- name: mnt
28+
mountPath: /mnt-rw

0 commit comments

Comments
 (0)