radius-project / radius

Radius is a cloud-native, portable application platform that makes app development easier for teams building cloud-native apps.
https://radapp.io
Apache License 2.0
1.49k stars 96 forks source link

WebAssembly application support #6515

Open rchaganti opened 1 year ago

rchaganti commented 1 year ago

Overview of feature request

I read through the documentation and blog posts. However, I did not see any mention of support for WebAssembly applications. Is this something planned? With wasm runtime support with containerd, we have the ability to run wasm applications on K8s. It will be beneficial to have complete workflow of developing and deploying wasm applications within Radius.

Acceptance criteria

Support for developing and provisioning wasm applications.

Additional context

Cloud native wasm is certainly gaining traction and having wasm support will be very helpful for developers and organizations looking at developing hybrid application architectures.

AB#9854

jkotalik commented 1 year ago

From my understanding, you can still run any container you create on WASM if your Kubernetes Cluster supports it. Radius doesn't have any opinion on that part. So as long as you have a container image that is built with WASM, Radius shouldn't care about what is built with.

Feel free to correct me if I'm misunderstanding the goal of WASM here!

AaronCrawfis commented 1 year ago

Thanks @jkotalik! Yep you can run any WASM container using Radius today. Using Krustlet you can setup your cluster to run WASM workloads, and then in Radius you can punch through the Radius abstractions into the Kubernetes API to set the required tolerations and nodeSelector.

For background Applications.Core resources are meant to be abstractions that could run on any platform (Kubernetes being our first), which is why we started with containers and offered punch through for platforms like Kubernetes when you need access to the specific knobs and dials of the underlying platform.

Based on https://docs.krustlet.dev/howto/wasm/, the Radius container would look like:

import radius as rad

resource helloWasm 'Applications.Core/containers@2023-10-01-preview' = {
  name: 'hello-wasm'
  properties: {
    application: application
    container: {
      image: 'webassembly.azurecr.io/hello-wasm:v1'
    }
    runtimes: {
      kubernetes: {
        pod: {
          nodeSelector: {
            'kubernetes.io/arch': 'wasm32-wasi'
          }
          tolerations: [
            {
              effect: 'NoExecute'
              key: 'kubernetes.io/arch'
              operator: 'Equal'
              value: 'wasm32-wasi'
            }
            {
              effect: 'NoSchedule'
              key: 'kubernetes.io/arch'
              operator: 'Equal'
              value: 'wasm32-wasi'
            }
          ]
        }
      }
    }
  }
}

Agree though that we could potentially make this a more first-class experience. WASM is super early and there's still a lot in flight for a standardization that Radius could abstract over. But we'd love to hear if you have any proposed ideas for what you'd like to see WASM to look like. This has been a discussion we've had amongst the team and have so far been in a "wait and see" mode.

rchaganti commented 1 year ago

Thank you, @jkotalik and @AaronCrawfis. Wasm on Kubernetes is easy, given that containerd shim and runtimes are already available. My idea is outside Kubernetes, where I want to run Wasm in its sandbox alongside other microservices running in containers or otherwise. I'd like the platform to evolve into supporting something like Docker Swarm for multi-node application deployments. With this, I can run my application in a hybrid mode. Maybe this is too ambitious at this time, but as you rightly mentioned, there is still a need to get the necessary ecosystem and tooling around wasm, and it is changing rapidly.