Rust is the most mature programming language that can generate WebAssembly modules: WebAssembly is a first-class citizen in the Rust world. That means many of the tools and crates of the Rust ecosystem work out of the box.

Kubewarden provides a Rust SDK that simplifies the process of writing policies, plus a template project to quickly scaffold a policy project using the cargo-generate utility.

This document illustrates how to take advantage of these projects to write Kubewarden policies using the Rust programming language.

Note well, we won't cover the details of Kubewarden's Rust SDK inside of this page. These can be found inside of the official crate documentation.

Getting Rust dependencies

This section guides you through the process of installing the Rust compiler and its dependencies.

As a first step install the Rust compiler and its tools, this can be easily done using rustup. Please follow rustup's install documentation.

Once rustup is installed add the Wasm target:

rustup target add wasm32-unknown-unknown