Skip to content

wasmtime: read config from env variable TOML#1105

Draft
tanishiking wants to merge 1 commit intocontainerd:mainfrom
tanishiking:wasmtime-toml-config
Draft

wasmtime: read config from env variable TOML#1105
tanishiking wants to merge 1 commit intocontainerd:mainfrom
tanishiking:wasmtime-toml-config

Conversation

@tanishiking
Copy link
Copy Markdown
Contributor

@tanishiking tanishiking commented Apr 14, 2026

fix #1004 and
#847 ?

Allow workloads to configure Wasmtime per deployment by setting RUNWASI_WASMTIME_CONFIG_TOML environment varialbe toml string. Not sure this is the best way to passing configuration, but it'd be a good starting point for discussing the design :)

Example:

apiVersion: v1
kind: ConfigMap
metadata:
  name: wasmtime-config
data:
  wasmtime.toml: |
    [wasm]
    gc = true
    function-references = true
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  template:
    spec:
      runtimeClassName: wasmtime
      containers:
        - name: app
          image: ghcr.io/example/hello-wasm:latest
          command: ["/"]
          env:
            - name: RUNWASI_WASMTIME_CONFIG_TOML
              valueFrom:
                configMapKeyRef:
                  name: wasmtime-config
                  key: wasmtime.toml

fix containerd#1004
and
containerd#847 ?

Allow workloads to configure Wasmtime per deployment by setting
`RUNWASI_WASMTIME_CONFIG_TOML` environment varialbe toml string.

Example:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: wasmtime-config
data:
  wasmtime.toml: |
    [wasm]
    gc = true
    function-references = true
    exceptions = true
    [optimize]
    opt-level = 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  template:
    spec:
      runtimeClassName: wasmtime
      containers:
        - name: app
          image: ghcr.io/example/hello-wasm:latest
          env:
            - name: RUNWASI_WASMTIME_CONFIG_TOML
              valueFrom:
                configMapKeyRef:
                  name: wasmtime-config
                  key: wasmtime.toml
```
@tanishiking tanishiking changed the title wasmtime: read config from ConfigMap-backed env TOML wasmtime: read config from env variable TOML Apr 14, 2026
Copy link
Copy Markdown
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial thoughts. Thank you for looking into this. A current workaround should be to set this as a containerd environment variable: https://github.com/spinframework/skips/tree/main/proposals/003-shim-runtime-options#spin-shim-executor-environment-variables

if needs_precompile {
log::info!("precompiling layers for image: {}", container.image);
let compiled_layers = match compiler.compile(&layers).await {
let compiled_layers = match compiler.compile(&layers, envs).await {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to pass all container environment variables to compile.

async fn compile(
&self,
_layers: &[WasmLayer],
_envs: &[String],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was your decision process around adding the configurability to Compiler::compile. Instead of Shim::compiler where many engines (wasmtime and spin) configure the runtime? We could look specify a known configuration file environment variable that is passed to shim::compiler to inform the construction of the compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuration of wasmtime features

2 participants