Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(riklet): use firepilot binary autoload #123

Merged
merged 6 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/src/reference/riklet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Riklet

[Rust in Kube (RIK)](https://github.com/dev-sys-do/rik) node agent

## Faas Configuration

**Prerequisite**: You need firecracker in your PATH.

Here is a list of environment variables that can be used to configure run riklet:

| Environment Variable | Description | Default |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- |
| `IFACE` | Network interface connected to the internet | "" |
| `IFACE_IP` | IP of the Network interface connected to the internet | "" |
| `FIRECRACKER_LOCATION` | Path to the firecracker binary | "" |
| `KERNEL_LOCATION` | Path to the kernel location | "" |

To run riklet with FAAS configuration.

```bash
sudo riklet --kernel-path ${KERNEL_LOCATION} \
--ifnet ${IFACE} \
--ifnet-ip ${IFACE_IP} \
```

> The firecracker binary location is determined by the following order:
>
> - **$FIRECRACKER_LOCATION** environment variable: direct path to the binary
> - **$PATH** environment variable: search for the binary in the directories
> - firecracker binary in the current working directory

Exemple:

```bash
sudo riklet --kernel-path ./vmlinux.bin \
--ifnet wlp2s0 \
--ifnet-ip 192.168.1.84 \
--script-path ./scripts/setup-host-tap.sh
```
23 changes: 15 additions & 8 deletions riklet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,37 @@ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo run --bin riklet

### Faas Usage

**Prerequisite**: You need firecracker in yout PATH.
**Prerequisite**: You need firecracker in your PATH.

Here is a list of **required** environment variables to run riklet:
Here is a list of environment variables that can be used to configure run riklet:

| Environment Variable | Description | Default |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- |
| `IFACE` | Network interface connected to the internet | "" |
| `IFACE_IP` | IP of the Network interface connected to the internet | "" |
| `FIRECRACKER_LOCATION` | Path to the firecracker binary | "" |
| `KERNEL_LOCATION` | Path to the kernel location | "" |
| `SCRIPT_LOCATION` | Path to the [script](https://github.com/polyxia-org/rik/blob/main/scripts/setup-host-tap.sh) that create tap interface. | "" |

To run riklet with FAAS configuration.

```bash
sudo riklet --firecracker-path ${FIRECRACKER_LOCATION} \
--kernel-path ${KERNEL_LOCATION} --ifnet ${IFACE} \
--ifnet-ip ${IFACE_IP} --script-path ${SCRIPT_LOCATION}
sudo riklet --kernel-path ${KERNEL_LOCATION} \
--ifnet ${IFACE} \
--ifnet-ip ${IFACE_IP} \
```

> The firecracker binary location is determined by the following order:
>
> - **$FIRECRACKER_LOCATION** environment variable: direct path to the binary
> - **$PATH** environment variable: search for the binary in the directories
> - firecracker binary in the current working directory

Exemple:

```bash
sudo riklet --firecracker-path $(which firecracker) --kernel-path ./vmlinux.bin --ifnet wlp2s0 --ifnet-ip 192.168.1.84 --script-path ./scripts/setup-host-tap.sh
sudo riklet --kernel-path ./vmlinux.bin \
--ifnet wlp2s0 \
--ifnet-ip 192.168.1.84
```

You should see something like that :
Expand All @@ -74,7 +81,7 @@ You should see something like that :
| / | | | \ | | | __| | |
| |\ \ _| |_| |\ \| |____| |___ | |
\_| \_|\___/\_| \_/\_____/\____/ \_/

[2021-07-03T15:04:09Z INFO riklet::core] Riklet (v0.1.0) is ready to accept connections.
```

Expand Down
2 changes: 0 additions & 2 deletions riklet/src/cli/function_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ use clap::Parser;

#[derive(Debug, Clone)]
pub struct FnConfiguration {
pub firecracker_location: PathBuf,
pub kernel_location: PathBuf,
}

impl From<CliConfiguration> for FnConfiguration {
fn from(cli: CliConfiguration) -> Self {
FnConfiguration {
firecracker_location: cli.firecracker_path,
kernel_location: cli.kernel_path,
}
}
Expand Down
8 changes: 0 additions & 8 deletions riklet/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ pub struct CliConfiguration {
/// If set and there is a config file, values defined by the CLI will override values of the configuration file.
#[arg(long)]
pub override_config: bool,
/// Path to a firecracker binary on your system
#[arg(
long,
value_name = "FIRECRACKER_LOCATION",
env = "FIRECRACKER_LOCATION",
default_value = "firecracker"
)]
pub firecracker_path: PathBuf,
/// Path to the linux kernel.
#[arg(
long,
Expand Down
5 changes: 3 additions & 2 deletions riklet/src/runtime/function_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ impl FunctionRuntime {
)
.try_build()
.map_err(RuntimeError::FirepilotConfiguration)?;
let executor = FirecrackerExecutorBuilder::new()

let executor = FirecrackerExecutorBuilder::auto()
.map_err(RuntimeError::FirepilotConfiguration)?
.with_chroot(DEFAULT_FIRECRACKER_WORKSPACE.to_string())
.with_exec_binary(self.function_config.firecracker_location.clone())
MaloPolese marked this conversation as resolved.
Show resolved Hide resolved
.try_build()
.map_err(RuntimeError::FirepilotConfiguration)?;

Expand Down