Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit d6b5d7d

Browse files
committed
Add SDK install instructions
1 parent 7adb7ca commit d6b5d7d

File tree

2 files changed

+100
-1
lines changed

2 files changed

+100
-1
lines changed

docs/getting-started/environment-setup.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,18 @@ _On a Windows host_, follow the instructions on how to assign a static local IP
4747

4848
After installing the VM, **enable nested virtualization for the VM** so that it has KVM access. This will depend on which hypervisor you're using. Then, run `lsmod | grep kvm` to ensure KVM is accessible inside the VM.
4949

50-
## 3. WSL2 with nested virtualization and SSH
50+
## 3. A Linux bare metal server
51+
52+
If it's your own hardware:
53+
54+
1. Find the server's IP via `ip addr`
55+
2. Give it a static DHCP lease through the router
56+
3. Install an SSH server like shown in section 2
57+
4. Enable virtualization, install KVM like in preceding sections
58+
59+
If you're using a cloud provider, [refer to Firecracker's development team's recommendations](https://github.com/firecracker-microvm/firecracker/blob/main/docs/dev-machine-setup.md#cloud). It'll cost a fair amount to get a bare metal server in the cloud, but it's generally worth it if you can.
60+
61+
## 4. WSL2 with nested virtualization and SSH
5162

5263
**Warning:** WSL is a pretty specific type of Linux VM and you may encounter issues using it for nested virtualization you wouldn't have with a conventional VM made in Hyper-V, VirtualBox or VMWare. If possible, opt for a traditional VM instead when running Windows. The WSL + SSH approach hasn't been thoroughly tested and we don't provide official support for it.
5364

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Installing the SDK
2+
3+
## Installing packages
4+
5+
To use FirecrackerSharp, you'll need the core package (`FirecrackerSharp`):
6+
7+
```dotnet add package FirecrackerSharp```
8+
9+
And then, one of the hosts, the local host is installed as follows:
10+
11+
```dotnet add package FirecrackerSharp.Host.Local```
12+
13+
And the SSH host is installed as follows:
14+
15+
```dotnet add package FirecrackerSharp.Host.Ssh```
16+
17+
## Configuring the host
18+
19+
For now, the hosts are configured via static classes (`LocalHost` or `SshHost`). An ASP.NET Core-specific extension that will use Microsoft's DI to do it is planned for the 1.0 release, but not available yet.
20+
21+
### Local host
22+
23+
Simply call:
24+
25+
```cs
26+
LocalHost.Configure();
27+
```
28+
29+
No extra configuration is needed, everything should "just work".
30+
31+
### SSH host
32+
33+
The SSH host needs three main configurations to work, the first is a connection pool configuration that will specify the settings of the SSH and SFTP connection pool and the credentials used to connect to the destination:
34+
35+
```cs
36+
public sealed record ConnectionPoolConfiguration(
37+
ConnectionInfo ConnectionInfo,
38+
uint SshConnectionAmount,
39+
uint SftpConnectionAmount,
40+
TimeSpan KeepAliveInterval);
41+
```
42+
43+
The second configuration is used to create PTYs (virtual terminals) that are needed to launch and interact with the firecracker/jailer processes. There's a sensible default configuration at `ShellConfiguration.Default`:
44+
45+
```cs
46+
public sealed record ShellConfiguration(
47+
string Terminal,
48+
uint Columns,
49+
uint Rows,
50+
uint Width,
51+
uint Height,
52+
int BufferSize)
53+
{
54+
public static readonly ShellConfiguration Default = new(
55+
"/bin/bash", 1000, 1000, 1000, 1000, 1000);
56+
}
57+
```
58+
59+
The third configuration is used for the `curl` tool that is needed to make HTTP requests to Unix domain sockets of the Firecracker process. SSH.NET needs to support Unix socket forwarding for this not to be necessary, but the [related issue](https://github.com/sshnet/SSH.NET/issues/238) hasn't been resolved for more than 7 years, so `curl` is used over SSH instead. A sensible default configuration is available at `CurlConfiguration.Default`:
60+
61+
```cs
62+
public sealed record CurlConfiguration(
63+
TimeSpan PollFrequency,
64+
int RetryAmount,
65+
int RetryDelaySeconds,
66+
int RetryMaxTimeSeconds)
67+
{
68+
public static readonly CurlConfiguration Default = new(TimeSpan.FromMilliseconds(5), 1, 0, 20);
69+
}
70+
```
71+
72+
Lastly, **ensure the following packages are installed on the SSH Linux machine!**:
73+
74+
- `tar` (working with archives)
75+
- `untar` or `unar` (same thing)
76+
- `curl` (requests)
77+
78+
To set up the host, call `SshHost` like so:
79+
80+
```cs
81+
SshHost.Configure(new ConnectionPoolConfiguration(...), new CurlConfiguration(...), new ShellConfiguration(...));
82+
```
83+
84+
The connection pool keeps up the constant amount of SSH and SFTP connections through your app's lifetime. **Ensure the connection pool is disposed of like so:**
85+
86+
```cs
87+
SshHost.Dispose();
88+
```

0 commit comments

Comments
 (0)