Skip to content

Commit

Permalink
feat: Configure max component memory (#91)
Browse files Browse the repository at this point in the history
* feat: Configure max component memory

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>

* chore: Bumping versions

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>

---------

Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
  • Loading branch information
lxfontes authored Aug 20, 2024
1 parent 788cbc0 commit 6f63289
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmcloud-operator"
version = "0.4.0"
version = "0.4.1"
edition = "2021"

[[bin]]
Expand Down Expand Up @@ -77,7 +77,7 @@ opentelemetry_sdk = { version = "0.21", features = [
"metrics",
"trace",
"rt-tokio",
]}
] }
opentelemetry-otlp = { version = "0.14", features = ["tokio"] }
rcgen = "0.11"
schemars = "0.8"
Expand Down
12 changes: 6 additions & 6 deletions crates/types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "wasmcloud-operator-types"
version = "0.1.7"
version = "0.1.8"
edition = "2021"

[dependencies]
k8s-openapi = {workspace = true}
kube = {workspace = true, features = ["derive"]}
schemars = {workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
k8s-openapi = { workspace = true }
kube = { workspace = true, features = ["derive"] }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
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 6f63289

Please sign in to comment.