deislabs / containerd-wasm-shims

containerd shims for running WebAssembly workloads in Kubernetes
Apache License 2.0
303 stars 47 forks source link

feature(spin): Support for custom Spin triggers #193

Open 0xE282B0 opened 9 months ago

0xE282B0 commented 9 months ago

Spin has a plugin system that allows Spin apps to be triggered by user-defined events. To add a trigger to the spin-shim it needs to be added to the source code e.g. https://github.com/deislabs/containerd-wasm-shims/pull/192

Since it is not desirable to add all possible triggers to the shim, it would be nice to use the existing plugin system to load the plugins at runtime. Trigger plugins are standalone binary CLI programs that take the path of a locked spin application as a parameter.

I see two options:

Option 1: Mount Spin plugins folder from Host

image

With this approach, the plugins can be conveniently managed on the host using the spin cli tool, and only the mount needs to be added to the shim. However, it is a piece of "dark magic" for the user, and the plugins still need to be distributed across all nodes of a Kubernetes cluster (in the case of K8s).

Option 2: Make the shim aware of plugins and fetch them during container startup

image

This option fetches the plugin during container creation, what makes startup a bit slower but does not need the plugins being installed on the node.

Thoughts

Mossaka commented 8 months ago

I can see this as a very useful addition to the spin shim. Thanks for brining this up @0xE282B0 !

I am personally preferring the second approach where the spin shim is aware of the plugins because this seems more ops friendly.