Skip to content

Commit

Permalink
feat: Configure max component memory
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
  • Loading branch information
lxfontes committed Aug 20, 2024
1 parent 788cbc0 commit 371cd17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/types/src/v1alpha1/wasmcloud_host_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pub struct WasmCloudHostConfigSpec {
pub certificates: Option<WasmCloudHostCertificates>,
/// wasmCloud secrets topic prefix, must not be empty if set.
pub secrets_topic_prefix: Option<String>,
/// Maximum memory in bytes that components can use.
pub max_linear_memory_bytes: Option<u32>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
Expand Down
2 changes: 2 additions & 0 deletions examples/full-config/wasmcloud-annotated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ spec:
# Optional: Subject prefix that will be used by the host to query for wasmCloud Secrets.
# See https://wasmcloud.com/docs/concepts/secrets for more context
secretsTopicPrefix: "wasmcloud.secrets"
# Optional: The maximum amount of memory bytes that a component can allocate.
maxLinearMemoryBytes: 20000000
# Optional: Additional options to control how the underlying wasmCloud hosts are scheduled in Kubernetes.
# This includes setting resource requirements for the nats and wasmCloud host
# containers along with any additional pot template settings.
Expand Down
8 changes: 8 additions & 0 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ async fn pod_template(config: &WasmCloudHostConfig, ctx: Arc<Context>) -> Result
})
}

if let Some(max_linear_memory_bytes) = &config.spec.max_linear_memory_bytes {
wasmcloud_env.push(EnvVar {
name: "WASMCLOUD_MAX_LINEAR_MEMORY".to_string(),
value: Some(max_linear_memory_bytes.to_string()),
..Default::default()
})
}

let mut wasmcloud_args = configure_observability(&config.spec);

let mut nats_resources: Option<k8s_openapi::api::core::v1::ResourceRequirements> = None;
Expand Down

0 comments on commit 371cd17

Please sign in to comment.