Project structure:
ext-simple-pod
: Wasm module that implements a simple controller to spawn podsext-memcached
: Wasm module that implements the operator-sdk Memcached samplekube-rs
: Hacked https://github.com/clux/kube-rs to run inside the modulekube-rs-host
: Hacked https://github.com/clux/kube-rs to use inside the hostrust-host
: The host running wasm modules
To build the memcached example controller:
cd ext-memcached
cargo build --target wasm32-wasi --release
Assuming you have a Kubernetes cluster up and running and you have an admin access to it configured in your local environment, deploy the CRD:
kubectl apply -f ext-memcached/crd.yaml
Now, copy in a directory (eg rust-host/compiled_mods
) the compiled module and the manifest the host needs to identify the abi to use:
mkdir rust-host/compiled_mods
cp ext-memcached/memcached.yaml rust-host/compiled_mods
cp ext-memcached/wasm32-wasi/release/memcached.wasm rust-host/compiled_mods
To compile and run the host:
cd rust-host
RUST_LOG=rust_host=debug,cranelift=warn,kube=debug cargo +nightly run compiled_mods
Now you can create the Memcached
CR with:
kubectl apply -f ext-memcached/cr.yaml