Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
WebAssembly components are a new way to build and deploy applications. They're designed to be a portable compilation target for programming languages and can run in various environments. WebAssembly components are sandboxed by design and expose their functionality using defined interfaces. Components differ from containers in that they single binaries that are much smaller and faster to start. Find the full description of the model and what a component in the specification.
wasmCloud is a Cloud Native Computing Foundation (CNCF) project designed to fast-track the development, deployment, and orchestration of WebAssembly components. This document details instructions on how to deploy wasmCloud on an Azure Kubernetes Service (AKS) cluster.
Before you begin
- This article assumes a basic understanding of Kubernetes concepts. For more information, see Kubernetes core concepts for Azure Kubernetes Service (AKS).
- You need an active Azure subscription. If you don't have one, create a Trial before you begin.
- You need an AKS cluster. If you don't have an existing cluster, you can create one using the Azure CLI, Azure PowerShell, or Azure portal.
- You need to install the wasmCloud CLI (wash) at version 0.39.0 or later. For installation options, see wasmcloud-cli.
Prerequisites
- You can't use the Azure portal to deploy wasmCloud to an AKS cluster.
Deploy wasmCloud
To deploy wasmCloud on an AKS cluster, you need to install the all in one Helm chart into your cluster. This installs the following services into a single namespace:
- NATS: NATS provides the backbone for all communication between components in wasmCloud.
- wadm: the wasmCloud Application Manager, otherwise known as wadm is the orchestrator for managing applications running on top of wasmCloud.
- the wasmCloud Operator: the wasmCloud Operator is a Kubernetes operator that manages the lifecycle of wasmCloud hosts.
We recommend deploying wasmCloud into a dedicated Kubernetes namespace.
Create a namespace for wasmCloud using
kubectl:kubectl create namespace wasmcloudInstall NATS and wadm into the wasmCloud namespace using the
helm upgradecommand:# By default, the chart installs NATS, Wadm, and wasmCloud Operator subcharts helm upgrade --install \ wasmcloud-platform \ --values https://raw.githubusercontent.com/wasmCloud/wasmcloud/main/charts/wasmcloud-platform/values.yaml \ oci://ghcr.io/wasmcloud/charts/wasmcloud-platform:0.1.2 \ --dependency-updateThe output from this command should look similar to the following:
NAME: wasmcloud-platform LAST DEPLOYED: Thu Nov 7 14:58:54 2024 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES:Wait for all of the pods to start using
kubectl:kubectl rollout status deploy,sts -l app.kubernetes.io/name=nats kubectl wait --for=condition=available --timeout=600s deploy -l app.kubernetes.io/name=wadm kubectl wait --for=condition=available --timeout=600s deploy -l app.kubernetes.io/name=wasmcloud-operatorStart a wasmCloud host using a CRD and
kubectl:cat << EOF | kubectl apply -f - apiVersion: k8s.wasmcloud.dev/v1alpha1 kind: WasmCloudHostConfig metadata: name: wasmcloud-host spec: lattice: default version: "1.4.1" EOFVerify that the wasmCloud host is running:
kubectl get pod -l app.kubernetes.io/instance=wasmcloud-hostYour output should look similar to the following:
NAME READY STATUS RESTARTS AGE wasmcloud-host-f9d67b8cf-lvsq6 2/2 Running 0 84sVerify that you can connect to the wasmCloud host using
wash:In a separate shell use run the following command to port forward to one of the running NATS pods:
kubectl port-forward nats-0 4222This command forwards all traffic on port 4222 locally to the NATS pod running in your cluster. You must have this port forwarded in order to connect to wasmCloud using
wash.In your original shell, run the following command with
washto verify that your wasmCloud host is running:wash get hostsYour output should look similar to the following:
Host ID Friendly name Uptime (seconds) ND2G4FRXLBCV3YL52OD4NRSS66Z5YOR3JOSL3Q7T5I6ZJM4EII3Y73CZ frosty-resonance-6227 312
Deploy a wasmCloud application
Now that wasmCloud is running on your AKS cluster, you can deploy a wasmCloud application. A wasmCloud application is a collection of WebAssembly components that are orchestrated by the wasmCloud Application Manager (wadm).
Create a wasmCloud application manifest file. This file describes components that comprise your application. Save the following yaml file as
hello-world.yaml.apiVersion: core.oam.dev/v1beta1 kind: Application metadata: name: hello-world annotations: description: 'HTTP hello world demo in Rust, using the WebAssembly Component Model and WebAssembly Interfaces Types (WIT)' spec: components: - name: http-component type: component properties: image: ghcr.io/wasmcloud/components/http-hello-world-rust:0.1.0 traits: # Govern the spread/scheduling of the component - type: spreadscaler properties: instances: 1 # Add a capability provider that enables HTTP access - name: httpserver type: capability properties: image: ghcr.io/wasmcloud/http-server:0.23.2 traits: # Establish a unidirectional link from this http server provider (the "source") # to the `http-component` component (the "target") so the component can handle incoming HTTP requests, # # The source (this provider) is configured such that the HTTP server listens on 0.0.0.0:8080 - type: link properties: target: http-component namespace: wasi package: http interfaces: [incoming-handler] source_config: - name: default-http properties: address: 0.0.0.0:8080Deploy the wasmCloud application using
wash:wash app deploy hello-world.yamlYour output should look similar to the following:
Deployed application "hello-world", version "01JC44TVDBC2V6MJ1NJTKNNX1J"Verify that the application is running using
wash:wash app status hello-worldYour output should look similar to the following:
Name Kind Status http_component SpreadScaler Deployed httpserver -(wasi:http)-> http_component LinkScaler Deployed httpserver SpreadScaler DeployedRepeat this command if necessary until all components are in the
Deployedstate.Invoke the http component using
curlandkubectl port-forward:In a separate shell, run the following command to port forward to the
hello-worldapplicationkubectl port-forward port-forward deployment/wasmcloud-host 8080This command forwards all traffic on port 8080 locally to the wasmCloud host running in your cluster. You must have this port forwarded in order to connect to wasmCloud using
curl.In your original shell, run the following command to invoke the http component:
curl http://localhost:8080Your output should look similar to the following:
Hello from Rust!Clean up the installed resources
To clean up the resources you created, run the following commands:
kubectl delete namespace wasmcloudThis command removes the wasmCloud components from your AKS cluster.
Next steps
You can continue to learn by following the wasmCloud Quickstart Guide, which walks you though creating a WebAssembly component from scratch, using different wasmCloud capabilities and scaling your application.