The project is setup with automated scripts that manage this process automatically. This guide however allows to fine-tune the deployment and to gain a better understanding of the project. We will highlight which shell file automates the process
These are managed by
devel/tool.sh
and often installed (through curl in a local folder) when not present
- Rust - Required to build the parent controller and child controllers
- Go - Required to build the
ring-go-controller
which is used as a comparison - Cross - Easier cross-compilation than with cargo, while providing isolation through Docker containers
- wasm-opt - Required to optimize the WASM output from cross
- sccache - Compiler caching tool which can be used to speed up compilation through setting
export RUSTC_WRAPPER=sccache
- Python3 + pip3 - Can be used to setup the webserver for predictions locally
Tools mentioned in devel/tool.sh
, but not used
- sccache
Automatically installed when executing a shell script from devel - Python3 + pip3
- Helm
- kube-apiserver + etcd
Original file:
devel/create_cluster.sh
Kind (Kubernetes IN Docker) is a tool designed to run Kubernetes clusters locally using Docker containers. It is lightweight, easy to configure, and ideal for testing and development environments.
It is the recommended way of testing out the project and thus most tested. Be sure to create an issue if any problems arise on other Kubernetes environments however.
The following code snippet creates a Kind cluster using our default config. This config does the following:
- Mounts the containerd directory
- Sets static values for the
dnsDomain
,podSubnet
andserviceSubnet
- Increases the
maxPods
setting for the kubelet to support up to 1100 pods - Enables performance improvement for etcd
kind create cluster \
--name "wasm-operator" \
--config "./devel/kind-config.yaml"
Original file:
devel/setup_flask_server.sh
The Flask server is in order to enable prediction.
It is deployed within our Kubernetes cluster and provides POST method "/prediction" to enable predictions on when to wake up.
The code can be found in the ./prediction/webserver
directory.
To build the docker container and load the image into Kind:
docker build -t prediction_webserver:webserver ./prediction/webserver
kind load docker-image --name wasm-operator prediction_webserver:webserver
We then just need to create a Deployment + Service to deploy and expose our pod. This can be done using the following manifest:
kubectl apply -f ./tests/yaml/deploymentFlask.yaml
Original file:
devel/setup_wasm_rust_simple.sh
/devel/setup_wasm_rust.sh
The operator can be built using cross. Setting the target to x86_64-unknown-linux-musl allows the binary to remain light weight and work on many Linux distributions due to static linking with musl libc. It is a great fit for the Docker image we're going to use: gcr.io/distroless/cc:nonroot
The parent operator currently does not support loading child operators at runtime. Due to the difficulties with mounting volumes in Kubernetes environments, the operator image copies over the config file (wasm_config.yaml) and the WASM files for the child operators
cd ./pkg/controller
export COMPILE_WITH_UNINSTANTIATE=TRUE
cross build --release --target=x86_64-unknown-linux-musl