WASI and Kubernetes +Docker : Friends or Foes?
Tags: kubernetes, docker, devops, design
Published: 2024-03-06 16:21:08


First with confession, my love for Kubernetes and docker is never ending, but when I first heard about WASI (WebAssembly System Interface), I was like oh god..., it will kill docker and Kubernetes, and started exploring WASI, it started with confusion, will it replace docker or not? umm... ok so you confused that why I even confused? let me explain:

WASI is a "Secure Sandbox" environment to run code. You see "Sandbox" like container to run code? and if its a sandbox in itself do we really need another orchestration like Kubernetes, you see ? few months passed agonizing, and here is what I learned.

It is unlikely that WebAssembly System Interface (WASI) will completely replace Docker as a containerization technology. While
WASI provides a secure and portable platform for running WebAssembly (WASM) modules, it is primarily designed for running specific types of applications and may not be suitable for all use cases. Docker, on the other hand, is a more general-purpose containerization technology that can be used to package and deploy applications written in a wide range of languages and frameworks.

It is widely adopted and has a large ecosystem of tools and services built around it, making it a well-established choice for containerization.

So it will not, you know what I think? HashiCorp’s Nomad scheduler will, currently I'm exploring it, and while it's premature for me to say, but Nomad does an amazing job of scheduling both containers and WebAssembly based on what I have explore so far, but that is for another article some another day.

Let us take a bit closer look at WASI


![Google search plus microsoft paint mergedn](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wawp4hgqzbpct91mh11x.png)

As the world becomes increasingly reliant on cloud computing and containerization, the demand for efficient and secure ways to run applications in these environments is growing. One solution that has gained a lot of attention in recent years is WebAssembly System Interface (WASI). WASI is a standardized interface for running WebAssembly (WASM) modules outside of a web browser, allowing them to be used for a wide range of applications. WASI enables WASM modules to access resources and functionality provided by the host operating system, such as file system access, networking, and system calls.

WASI is designed to provide a secure sandbox environment for running untrusted code, making it well-suited for use in cloud environments where multiple users may be sharing resources. It achieves this security by limiting the capabilities of WASM modules and providing a defined set of APIs for interacting with the host operating system.

To use WASI, developers first write their application as a WASM module using a programming language that can be compiled to WASM, such as C, C++, or Rust. They can then use a WASI runtime, such as Wasmer or Wascc, to execute the WASM module and provide the necessary interfaces for accessing host resources.

Here are a few examples of how WASI can be used:

- Running a serverless function in the cloud: WASI can be used to run a WASM module as a serverless function in a cloud environment. This allows developers to write their functions in a wide range of languages and deploy them to the cloud with ease.
- Running a command-line tool: WASI can be used to execute a WASM module as a command-line tool. This allows developers to write their tools in a language that compiles to WASM and run them on any platform that supports WASI.
- Running a standalone application: WASI can be used to execute a WASM module as a standalone application on a desktop or mobile device. This allows developers to write their applications in a language that compiles to WASM and run them on any platform that supports WASI.

Overall, WASI is a powerful technology for running WASM modules in a secure and portable way. It has the potential to revolutionize the way we run cloud-based applications and is worth considering for any project that involves WASM.

So, how can WASI and Kubernetes work together?

Kubernetes is a powerful platform for managing containerized applications, but it has traditionally been limited to running applications written in languages like Go, Java, and Python. However, with the growing popularity of WASI, it's time for these two technologies to work together.

The benefits of running WASI modules in Kubernetes are numerous. For one, WASI offers a secure sandbox environment for running untrusted code, which is especially important in a cloud environment where multiple users may be sharing resources. Additionally, WASI modules are portable and can be run on any platform that supports WASI, making it easy to deploy applications across multiple environments.

Below is my try to put my understanding as how WASI and Kubernetes be integrated :

By combining these technologies, developers can leverage the security and portability of WASI with the powerful orchestration capabilities of Kubernetes.

Here is an example of how WASI and Kubernetes could work together:

- A developer writes an application as a WASM module using a programming language that can be compiled to WASM, such as C, C++, or Rust.
-  The developer uses a WASI runtime, such as Wasmer or Wascc, to execute the WASM module and provide the necessary interfaces for accessing host resources.
- The developer packages the WASM module and the WASI runtime into a Docker container.
- The developer deploys the Docker container to a Kubernetes cluster, either by using kubectl or through a continuous integration/continuous delivery (CI/CD) pipeline.
- Kubernetes manages the deployment and execution of the WASM module, ensuring that it is running efficiently and reliably in the cloud.

This is just one example of how WASI and Kubernetes can work together. There are also other ways to integrate these technologies, such as through the use of custom runtime classes or WASI-specific container runtimes. Regardless of the approach taken, the combination of WASI and Kubernetes has the potential to revolutionize the way we run cloud-based applications.

In conclusion, the relationship between WASI, Kubernetes, and Docker is one of friendship, not rivalry. While these technologies may seem like they are competing for the same space in the cloud computing market, they actually complement and enhance each other in many ways.

WASI provides a secure and portable platform for running WebAssembly (WASM) modules, while Kubernetes is a powerful platform for managing containerized applications. By combining these technologies, developers can leverage the security and portability of WASI with the powerful orchestration capabilities of Kubernetes.

And while Docker is a well-established choice for containerization, it can also work alongside WASI and Kubernetes to provide a complete solution for running cloud-based applications. In fact, Docker containers can be used to package and deploy WASM modules, making it easy to benefit from the security and portability of WASI in a Docker-based environment.

So, rather than seeing WASI, Kubernetes, and Docker as foes, it's time to recognize them as the powerful friends they are in the world of cloud computing. Together, these technologies have the potential to revolutionize the way we run applications in the cloud.