You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `containerd-shim-spin` SpinKube executor currently lackd the ability to configure runtime flags for Spin applications. This proposal aims to address this by enabling three types of configurations: Spin execution settings, shim execution settings, and shim execution environment variables. These configurations will be set via Custom Resource Definitions (CRDs) in Kubernetes, specifically extending the SpinExecutor and SpinApp CRDs. This approach will allow operators to easily configure both the application and the platform execution environments.
20
+
The `containerd-shim-spin` SpinKube executor currently lack the ability to configure Spin runtime flags for Spin applications. This proposal aims to address this by enabling three types of configurations: Spin execution settings, shim execution settings, and shim execution environment variables. These configurations will be set via Custom Resource Definitions (CRDs) in Kubernetes, specifically extending the SpinExecutor and SpinApp CRDs. This approach will allow operators to easily configure both the application and the platform execution environments.
21
21
22
22
## Background
23
23
@@ -42,22 +42,41 @@ A Runwasi containerd shim does more than execute a Wasm runtime such as Spin or
42
42
43
43
In summary, the following are types of configuration that should be supported:
44
44
45
-
-Wasm runtime specific options (oftentimes in the form of CLI flags: `spin up --listen "127.0.0.1:3000"`)
46
-
-Wasm runtime environment variables (such as `OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 spin up` )
47
-
-Shim execution options (such as disabling pre-compilation)
48
-
-Shim execution environment variables (such as `RUST LOG`)
45
+
-Spin runtime specific options (oftentimes in the form of CLI flags: `spin up --listen "127.0.0.1:3000"`)
46
+
-Spin runtime environment variables (such as `OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 spin up` )
47
+
-Spin shim execution options (such as disabling pre-compilation)
48
+
-Spin shim execution environment variables (such as `RUST LOG`)
49
49
50
-
Combining the first two categories and focusing on the Spin runtime, the list can be simplified:
50
+
The list can be simplified to abstract how configuration is set (flag, file, or environment variable):
51
51
52
52
- Spin execution configuration
53
53
- Shim execution configuration
54
-
- Shim execution environment variables
54
+
55
+
Note, that this list does not include Wasm instance environment variables. This document is focused on configuring the Wasm engine, namely Spin. The proposed approach does conclude that Wasm instance environment variables should not be configurable from the PodSpec; rather, Spin users should use configuration variables instead. See the ["Configuring Spin Execution in Container Environment Variables" section](#configuring-spin-execution-in-container-environment-variables) for more context.
56
+
57
+
## Terminology
58
+
59
+
| Term | Definition |
60
+
| ---- | ---------- |
61
+
| Container runtime | A program that runs and manages the lifecycle of containers, or in this case Spin apps, i.e. Youki. |
62
+
| CRD | Custom Resource Definition, a Kubernetes extension mechanism for defining custom resources |
63
+
| Environment Variables | Variables that are part of the environment in which a process runs |
64
+
| PodSpec | A Kubernetes object that describes the specification of a pod, including its containers, volumes, and other properties |
65
+
| Shim | A containerd shim, a lightweight process that acts as an intermediary between a container and the container runtime |
66
+
| Spin | A CLI tool for scaffolding, building and running serverless Wasm components |
67
+
| SpinApp | A custom resource definition (CRD) in Kubernetes that represents a Spin application |
68
+
| SpinExecutor | A custom resource definition (CRD) in Kubernetes that represents a Spin executor (such as the Spin containerd shim) |
69
+
| SpinKube | A Kubernetes operator for managing Spin applications |
70
+
| Spin runtime | A Wasm execution engine that executes Wasm components using Wasmtime |
71
+
| Wasm execution engine | An engine that execute Wasm components using a Wasm runtime, i.e. Spin which uses Wasmtime |
72
+
| Wasm runtime | A WebAssembly runtime, i.e. Wasmtime |
73
+
| Wasmtime | The WebAssembly runtime that Spin uses to execute WebAssembly components |
55
74
56
75
### Current Workarounds
57
76
58
-
#### Wasm Runtime Specific Options Workaround
77
+
#### Spin Runtime Specific Options Workaround
59
78
60
-
None, unless an environment variable is also exposed for the flag and can be configured with the [Wasm runtime environment variables workaround](#Wasm-runtime-environment-variables-workaround).
79
+
None, unless an environment variable is also exposed for the flag and can be configured with the [Spin runtime environment variables workaround](#spin-runtime-environment-variables-workaround).
61
80
62
81
These flags could be set in the runtime arguments for the container, such as the following in a Kubernetes PodSpec:
63
82
@@ -71,9 +90,9 @@ These flags could be set in the runtime arguments for the container, such as the
71
90
72
91
While the shim currently has access to these arguments from the [`RuntimeContext` args](https://github.com/containerd/runwasi/blob/f5f497c4b21a5d55613095a3ae878c4ef4b83b91/crates/containerd-shim-wasm/src/container/context.rs#L14), the shim does not parse these arguments and would need to be enlightened in a similar manner as the Spin CLI to discern which are for which trigger.
There is no SpinKube native way to configure environment variables on the runtime process. Working around the Spin operator, these environment variables can be configured by setting them in the container spec of a Spin app deployment:
95
+
There is no SpinKube native way to configure environment variables on the Spin. Working around the Spin operator, these environment variables can be configured by setting them in the container spec of a Spin app deployment:
77
96
78
97
```yaml
79
98
containers:
@@ -140,7 +159,7 @@ All Spin execution configuration will be defined as known environment variables
140
159
| Key | Spin CLI | Example Value|
141
160
| ---- | ---- | ---- |
142
161
| SPIN_HTTP_LISTEN_ADDR | `spin up --listen` | "0.0.0.0:3000" |
| SPIN_LOG_DIR | `spin up --log-dir /tmp/log` | "/tmp/log" |
145
164
| RUNTIME_CONFIG_FILE | `spin up --runtime-config-file /var/config.toml` | "/var/config.toml" |
146
165
@@ -179,7 +198,7 @@ spec
179
198
...
180
199
```
181
200
182
-
The `containerd-shim-spin` instance will look for all supported runtime environment variables and configure execution accordingly.
201
+
The `containerd-shim-spin` instance will look for all supported Spin runtime environment variables and configure execution accordingly.
183
202
184
203
### Configuring Shim Execution in Containerd Config Options
185
204
@@ -226,9 +245,9 @@ The following are alternate strategies for configuring the Spin runtime in the `
226
245
227
246
1. Spin execution options could be configured in in Pod annotations; however, it is not granular enough for the case of two Spin apps in a Pod, for example, [listen ports could still conflict](https://github.com/spinkube/containerd-shim-spin/issues/52).
228
247
229
-
2. As shown in the [runtime configuration workaround](#wasm-runtime-specific-options-workaround), options could be set as container arguments, but setting flags in CRDs is less ergonomic than environment variables, and parsing logic would need to be added to the shim. However, taking this path would potentially enable reusing Spin's reconciling of the mutual exclusiveness of flags.
248
+
2. As shown in the [Spin runtime configuration workaround](#wasm-runtime-specific-options-workaround), options could be set as container arguments, but setting flags in CRDs is less ergonomic than environment variables, and parsing logic would need to be added to the shim. However, taking this path would potentially enable reusing Spin's reconciling of the mutual exclusiveness of flags.
230
249
231
-
3. Spin Runtime config (`runtime-config.toml`) could be enhanced to support configuring triggers. Right now, runtime config is used to configure host components. So far, it has been used the describe how to configure the host environment for the guest. That could encompass considering how the host should be triggered to invoke the guest. This may be the better long term solution; however, it will take design to consider the scope of Spin runtime config.
250
+
3. Spin Runtime config (`runtime-config.toml`) could be enhanced to support configuring triggers. Right now, the Spin runtime config file is used to configure host components. So far, it has been used the describe how to configure the host environment for the guest. That could encompass considering how the host should be triggered to invoke the guest. This may be the better long term solution; however, it will take design to consider the scope of Spin runtime config.
232
251
233
252
4. Alternatively, there may be places each of these configuration options fit outside of CLI flags. For example, the port for HTTP triggered apps could be configured in the trigger specification in the `spin.toml`. Log directory is already a part of [runtime config](https://github.com/fermyon/spin/blob/b3db535c9edb72278d4db3a201f0ed214e561354/crates/trigger/src/runtime_config.rs#L203-L204) despite the fact that users are more comfortable configuring it through the Spin CLI.
0 commit comments