>> Hey everyone, hope you're all having a great day today.
I'm Matt Fischer, one of the core maintainers of Krustlet.
Today I'm going to show you how to run
WebAssembly workloads natively on Kubernetes.
We're going to install Krustlet,
and run an application compiled to WebAssembly using Kubernetes.
If you'd like to skip the introduction
and go straight into the demo,
skip ahead to the timestamp provided in the video now.
So, you may be asking yourself,
"How is this possible?
Kubernetes runs container images executed under
the Docker Runtime, not WebAssembly, right?"
To answer this question,
let's quickly review some of
the components in a Kubernetes Cluster.
In Kubernetes, a kubelet is
the agent that runs on every node in the cluster.
It registers the node with the Kubernetes API server,
listening for requests from the API server to run,
stop, or fetch information from a pod running on the node.
Pods are a group of containers sharing a pool of
compute resources like a network bridge or storage.
The default kubelet uses
container images executed under the Docker Runtime.
Krustlet is a new spin on the kubelet.
Instead of container images,
it uses WebAssembly modules as the primary workload.
It registers the node to the Kubernetes cluster
informing the API server that I can run WebAssembly workloads.
When a user asks to run a pod using WebAssembly,
the API server will then check
the cluster for a node that can run WebAssembly,
see that Krustlet is installed and running and available,
and schedule the pod to that node.
We chose to write Krustlet because WebAssembly is
a portable binary format that can run
anywhere regardless of the underlying hardware.
Applications compiled to WebAssembly can run in any browser and on
any operating system without
requiring the developer to recompile their application.
It is also sandboxed from the host,
meaning that each module is executed in isolation from each other,
and applications cannot escape the sandbox that
are going through the APIs provided by the host.
Alright, so let's dive into today's lesson.
We're going to install Krustlet and run
a demo application on Kubernetes.
For this demonstration, I have four tools installed,
Kind, Docker, kubectl, and Krustlet.
You can find the tools in
their respective release pages on GitHub.
To create a new Kubernetes cluster,
make sure Docker is running then use
Kind to create cluster as shown on screen.
Now let's run Krustlet. To register
with the Kubernetes API server,
Krustlet needs to generate a bootstrap token and a kubeconfig.
In Krustlet's documentation, there's
a useful shell script that can be used to
generate this token and kubeconfig file.
The output you're seeing on screen
is the output from that shell script.
Once you have the bootstrap config in place,
you can run Krustlet.
Our demonstration today will be using
a WebAssembly runtime called WASCC,
which is short for WebAssembly Secure Capabilities Connector.
So we will register a new node with a krustlet-wascc binary runtime.
Krustlet will begin the bootstrapping process,
and then await manual certificate approval before launching.
We'll use kubectl get csr to
find the correct certificate signing requests,
Krustlet registered with Kubernetes,
then use kubectl certificate
approve to approve the sign-in request.
Now we can run a demo app.
We'll use kubectl create to spawn
a new pod using one of the demo apps available on GitHub.
This particular demo app was written in
Rust and has been compiled to WebAssembly.
The greet-wascc.yaml file requests that
the pod opens port 8080 on the node,
so we can make HTTP requests to the application from the node.
This is just a simple application that
greets the user with a familiar message.
There are many other examples available in the demo directory.
Then we'll delete the pod.
Notice that the user can no longer make requests to
the WebAssembly module that is no longer running.
Thanks for watching today's video.
Hopefully this video was helpful to you.
If you'd like to learn more about Krustlet,
please go visit our other guides for more information. Thank you.