mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-03 18:04:16 +00:00
genpolicy: support readonly emptyDir mount
Set emptyDir access based on volume mount readOnly value Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
This commit is contained in:
@@ -181,6 +181,14 @@ fn get_empty_dir_mount_and_storage(
|
|||||||
&settings_empty_dir.mount_type
|
&settings_empty_dir.mount_type
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let access = match yaml_mount.readOnly {
|
||||||
|
Some(true) => {
|
||||||
|
debug!("setting read only access for emptyDir mount");
|
||||||
|
"ro"
|
||||||
|
}
|
||||||
|
_ => "rw",
|
||||||
|
};
|
||||||
|
|
||||||
p_mounts.push(policy::KataMount {
|
p_mounts.push(policy::KataMount {
|
||||||
destination: yaml_mount.mountPath.to_string(),
|
destination: yaml_mount.mountPath.to_string(),
|
||||||
type_: mount_type.to_string(),
|
type_: mount_type.to_string(),
|
||||||
@@ -188,7 +196,7 @@ fn get_empty_dir_mount_and_storage(
|
|||||||
options: vec![
|
options: vec![
|
||||||
"rbind".to_string(),
|
"rbind".to_string(),
|
||||||
"rprivate".to_string(),
|
"rprivate".to_string(),
|
||||||
"rw".to_string(),
|
access.to_string(),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,9 @@ spec:
|
|||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: host-empty-vol
|
- name: host-empty-vol
|
||||||
mountPath: "/host/cache"
|
mountPath: "/host/cache"
|
||||||
|
- name: host-empty-vol
|
||||||
|
mountPath: "/host/cache-read-only"
|
||||||
|
readOnly: true
|
||||||
- mountPath: /tmp/results
|
- mountPath: /tmp/results
|
||||||
name: hostpath-vol
|
name: hostpath-vol
|
||||||
- mountPath: /tmp/results-read-only
|
- mountPath: /tmp/results-read-only
|
||||||
|
Reference in New Issue
Block a user