-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support trigger command #50
Conversation
@radu-matei I think I get mechanically how this works, but I'm not quite clear on the use case for init container having a command trigger. Can you explain what it would be used for? |
I should have added a bit more context to this — we've had a lot of conversations during KubeCon with people who are interested in using Wasm as init containers — where their init containers take dozens of seconds to start, even if all they do is a tiny bit of work. So they are interested in seeing how to use Wasm because of its tiny footprint and fast startup. At the same time, we've also long been interested in a Spin trigger that ran a WASI (CLI) component to completion (regardless of what it does exactly). So this brings the two together and a) lets you execute a "main" function to completion through Spin, and b) enables using that as an init container. Turning this into a draft for now, as we want to discuss this in the next SpinKube meeting. |
containerd-shim-spin/src/engine.rs
Outdated
.context("failed to build spin trigger")?; | ||
|
||
info!(" >>> running spin trigger"); | ||
command_trigger.run(spin_trigger::cli::NoArgs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you want to pass in the args from the entrypoint of the container spec?
There isn't anything in here that makes it specifically for init containers, this could be used to run the main pod to completion as well? Thinking something like a kubernetes Job. |
LGTM, We might add a workload test for the init container scenario: https://github.com/spinkube/containerd-shim-spin/tree/main/tests/workloads |
@jsturtevant correct, this can definitely be used for other kinds of workloads, not just init containers. |
Is the spin command trigger implementing the wasip2 |
@Mossaka yeah, the trigger now supports both WASI Preview 1 and WASI Preview 2 components (using the CLI world). Tested with a Rust component that uses sockets, so that definitely works (will push an example on this over the next few days). On passing arguments, we have a proposal for that here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a55e5d2
to
98b7d1e
Compare
This app manifest works in the shim using the command trigger: apiVersion: apps/v1
kind: Deployment
metadata:
name: spin-test-init
spec:
replicas: 1
selector:
matchLabels:
app: spin-test
template:
metadata:
labels:
app: spin-test
spec:
runtimeClassName: wasmtime-spin-v2
initContainers:
- name: spin-init
image: ttl.sh/spinkube-init-args:24h
args: ["these", "are", "some", "args"]
containers:
- name: spin-test
image: ghcr.io/deislabs/containerd-wasm-shims/examples/spin-rust-hello:v0.10.0
command: ["/"]
ports:
- containerPort: 80 Getting the logs from the init container:
|
This commit implements support for running "command" triggers in the shim, based on https://github.com/fermyon/spin-trigger-command. Specifically, it runs a WASI command component to completion, with support for both classical WASI preview 1 core modules and WASI preview 2 CLI components. Finally, this supports passing Kubernetes arguments: ```yaml - name: spin-command image: <command-component-that-prints-args> args: ["these", "are", "some", "args"] ``` These arguments are passed in the component and can be read at runtime using WASI. Signed-off-by: Radu Matei <radu@fermyon.com>
7c14e3a
to
36b2365
Compare
I'll merge this so we can iterate. Thank you all for the feedback! |
This commit allows Spin apps to be init containers, based on https://github.com/fermyon/spin-trigger-command: