genpolicy: make pause container image configurable

CRIs don't always use a pause container, but even if they do the
concrete container choice is not specified. Even if the CRI config can
be tweaked, it's not guaranteed that registries in the public internet
can be reached. To be portable across CRI implementations and
configurations, the genpolicy user needs to be able to configure the
container the tool should append to the policy.

Signed-off-by: Markus Rudy <webmaster@burgerdev.de>
This commit is contained in:
Markus Rudy
2024-03-18 11:34:54 +01:00
parent 8b30fa103f
commit bc2292bc27
3 changed files with 6 additions and 4 deletions

View File

@@ -272,7 +272,8 @@
"confidential_guest": false
},
"cluster_config": {
"default_namespace": "default"
"default_namespace": "default",
"pause_container_image": "mcr.microsoft.com/oss/kubernetes/pause:3.6"
},
"request_defaults": {
"CreateContainerRequest": {

View File

@@ -834,9 +834,7 @@ fn compress_capabilities(capabilities: &mut Vec<String>, defaults: &policy::Comm
pub async fn add_pause_container(containers: &mut Vec<Container>, config: &Config) {
debug!("Adding pause container...");
let mut pause_container = Container {
// TODO: load this path from the settings file.
image: "mcr.microsoft.com/oss/kubernetes/pause:3.6".to_string(),
image: config.settings.cluster_config.pause_container_image.clone(),
name: String::new(),
imagePullPolicy: None,
securityContext: Some(SecurityContext {

View File

@@ -362,6 +362,9 @@ pub struct CommonData {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ClusterConfig {
default_namespace: String,
/// Pause container image reference.
pub pause_container_image: String,
}
impl AgentPolicy {