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:
Saul Paredes
2024-09-03 19:09:13 -07:00
parent 36a4104753
commit 24c2d13fd3
2 changed files with 12 additions and 1 deletions

View File

@@ -181,6 +181,14 @@ fn get_empty_dir_mount_and_storage(
&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 {
destination: yaml_mount.mountPath.to_string(),
type_: mount_type.to_string(),
@@ -188,7 +196,7 @@ fn get_empty_dir_mount_and_storage(
options: vec![
"rbind".to_string(),
"rprivate".to_string(),
"rw".to_string(),
access.to_string(),
],
});
}

View File

@@ -27,6 +27,9 @@ spec:
volumeMounts:
- name: host-empty-vol
mountPath: "/host/cache"
- name: host-empty-vol
mountPath: "/host/cache-read-only"
readOnly: true
- mountPath: /tmp/results
name: hostpath-vol
- mountPath: /tmp/results-read-only