Skip to content

Commit

Permalink
updating readme
Browse files Browse the repository at this point in the history
  • Loading branch information
autodidaddict committed Nov 15, 2023
1 parent 75414a5 commit 3beb905
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@ Turn your NATS infrastructure into a distributed workload deployment and executi
* [fc-image](./fc-image/) - Tools for building the rootfs (ext4) file system for use in firecracker VMs
* [agent-api](./agent-api/) - Protobuf API specification for protocol used between `nex-node` and `nex-agent` across the firecracker boundary. Also contains a client for communicating with an agent. This is an internal API unlikely to be of interest to users.

## Deploying and Running Workloads
Follow these steps to get up and running:

1. Build and launch a [nex-node](./nex-node/) instance. See the repo for configuration and deployment instructions. At the very least, you'll need:
* CNI configuration and plugins installed
* A linux kernel binary available
* A root file system (`ext4`) for the firecracker VMs
1. Push your statically linked linux binary to a NATS object store
1. Use the [nex-cli](./nex-cli) or the [control-api](./control-api/) to launch a workload. For this, you'll need:
* An xkey used by the publisher
* An nkey used to "issue" the workload (by convention, this is an account)
* A set of environment variables to pass into the workload at startup
* The URL of the workload in the format `nats://{object-store}/{key}`. This corresponds to where you uploaded the file in step 2. The `nex-node` must be able to pull from this store
1. Monitor events and logs on `$NEX.events.*` and `$NEX.logs.>`

**NOTE** that if your workload needs a NATS connection (or any other connection), not only will the firecracker CNI need to allow it, but you'll need to pass that URL/credentials/etc into the workload via the environment variables specified in the launch request.

## Supported Workloads
In order to create a deployable workload, you'll need to create a _statically linked_ executable compiled for 64-bit Linux. Creating a truly statically linked executable file can be tricky. The following shows how to do it in Go (run this in a directory with a `main.go` file):

```go
Expand All @@ -19,9 +35,9 @@ Building a statically linked 🦀 Rust binary involves using cargo to build agai

For other languages, check the language documentation or community.

Once your static executable is ready to run, you can use the [CLI](./nex-cli/) or the [Control API](./control-api/) to launch it.
Once your static executable is ready to run, you can use the [CLI](./nex-cli/) or the [Control API](./control-api/) to launch it. The system will validate that the binary is statically linked and reject it otherwise.

## Architecture
The following diagram provides a (rough) view of the various components of the system. Here, `nex-node` processes all attach to a NATS system. Each `nex-node` process is responsible for spinning up multiple firecracker VMs. Within each firecracker VM is a `nex-agent` process, and spawned by each `nex-agent` process is a _single_, untrusted workload (executable).
The following diagram provides a (rough) view of the various components of the system. Here, `nex-node` processes all attach to a NATS system. Each `nex-node` process is responsible for spinning up multiple firecracker VMs. Within each firecracker VM is a `nex-agent` process, and spawned by each `nex-agent` process is a _single_, untrusted workload (executable). This untrusted workload, if it has a NATS connection, is using completely separate credentials and URLs than the control interface for `nex-node`s.

![NEX architecture](./nex-arch.png)
2 changes: 2 additions & 0 deletions nex-node/machine_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (m *MachineManager) TakeFromPool() (*runningFirecracker, error) {
func (m *MachineManager) PublishCloudEvent(eventType string, data interface{}) {
pk, _ := m.kp.PublicKey()
cloudevent := cloudevents.NewEvent()
cloudevent.SetTime(time.Now().UTC())
cloudevent.SetID(uuid.NewString())
cloudevent.SetType(eventType)
cloudevent.SetSource(pk)
Expand Down Expand Up @@ -227,6 +228,7 @@ func agentEventToCloudEvent(vm *runningFirecracker, pk string, event *agentapi.A

cloudevent.SetSource(fmt.Sprintf("%s-%s", pk, vm.vmmID))
cloudevent.SetID(uuid.NewString())
cloudevent.SetTime(time.Now().UTC())
cloudevent.SetType(eventType)
cloudevent.SetDataContentType(cloudevents.ApplicationJSON)
cloudevent.SetData(event.Data)
Expand Down

0 comments on commit 3beb905

Please sign in to comment.