Skip to content

Commit

Permalink
feat: create user guide section
Browse files Browse the repository at this point in the history
* new User Guide section
* compile-kernel page
* build-initramfs page

Signed-off-by: RedbeanGit <dubois.julien.mail@gmail.com>
  • Loading branch information
RedbeanGit committed Oct 30, 2023
1 parent eff12b4 commit 89481d6
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ node_modules/
.next/
package.json
package-lock.json
pnpm-lock.yaml
pnpm-lock.yaml
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@ianvs/prettier-plugin-sort-imports": "4.1.0",
"@next/eslint-plugin-next": "13.5.4",
"@types/node": "18.11.10",
"@types/react": "^18.2.31",
"@typescript-eslint/eslint-plugin": "6.7.4",
"@typescript-eslint/parser": "6.7.4",
"autoprefixer": "^10.4.16",
Expand Down
3 changes: 2 additions & 1 deletion pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"type": "separator",
"title": "Getting Started"
},
"index": "Introduction"
"index": "Introduction",
"user-guide": "User Guide"
}
4 changes: 4 additions & 0 deletions pages/docs/user-guide/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"compiling-linux-kernel": "Compiling Linux Kernel",
"building-initramfs": "Building initramfs"
}
128 changes: 128 additions & 0 deletions pages/docs/user-guide/building-initramfs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
title: Building initramfs
description: A guide on how to build initramfs for Lambdo.
---

import Image from 'next/image';
import Link from 'next/link';
import { Callout } from 'nextra/components';
import InitramfsComponentsImage from '../../../public/images/schemas/initramfs-components.png';

# Building initramfs

Requirements:

- [Rust toolchain](https://www.rust-lang.org/fr/learn/get-started)

## Introduction

Lambdo uses custom initramfs built from Docker images. You can build it by
yourself or use prebuilt one.

## Lambdo initramfs structure

Lambdo initramfs contains at least 3 components:

- **init** - init process which starts all other processes.
- **agent** - agent process which is responsible for communication with Lambdo
API.
- **config.yaml** - configuration file which contains all necessary
configuration for Lambdo agent (see
[Configuration documentation](/docs/reference/configuration)).

<div className="col-span-2 flex items-center justify-center py-2">
<Image
src={InitramfsComponentsImage}
alt="Initramfs components"
width={500}
height={500}
/>
</div>

## Preparation

Create an empty directory for initramfs:

```bash copy
mkdir initramfs
```

Clone `lambdo` repository:

```bash copy
git clone https://github.com/faast-rt/lambdo.git
```

## Build Lambdo agent

Build Lambdo agent and move it to initramfs directory:

```bash copy
cd lambdo/agent
cargo build --release
cd ../..
mv lambdo/target/release/agent initramfs
```

## Write init script

You can write your own script or use example one (must be named `init`):

```bash copy filename="initramfs/init"
#! /bin/sh
mount -t devtmpfs dev /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
ip link set up dev lo

exec /agent --config /config.yaml

exit
poweroff -f
```

<Callout type="warning">
Your init script **must** have execution rights.
</Callout>

<Callout type="warning">
Your init script **must** start agent process to work with Lambdo.
</Callout>

## Write configuration file

You can write your own configuration file or use example one (must be named
`config.yaml`):

```yaml copy filename="initramfs/config.yaml"
apiVersion: lambdo.io/v1alpha1
kind: AgentConfig
# Leave empty if you want to use default Lambdo API.
grpc:
remote_port: 50051
remote_host: 127.0.0.1
local_port: 0
local_host: 0.0.0.0
```
## Build initramfs by yourself
Build initramfs tool and move it to initramfs directory:
```bash copy
cd lambdo/initramfs
cargo build --release
cd ../..
mv lambdo/target/release/initramfs initramfs
```

Run initramfs tool (replace `node:20-alpine` with the image of the language you
want):

```bash copy
cd initramfs
./initramfs --image node:20-alpine
```

**The image built here is stored at
`initramfs/initramfs-library-node-20-alpine.img`.**
54 changes: 54 additions & 0 deletions pages/docs/user-guide/compiling-linux-kernel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Compiling Linux kernel
description: A guide to compile the Linux kernel.
---

# Compiling Linux kernel

Lambdo uses a Linux kernel compiled from source. This is a guide to compile the
kernel.

## Install dependencies

### Debian / Ubuntu

```bash copy filename="bash"
sudo apt update
sudo apt install git build-essential bc flex bison curl tar
```

### Fedora / RHEL / CentOS

```bash copy filename="bash"
sudo dnf install git gcc make xz bc flex bison diffutils curl tar
```

### Arch Linux

```bash copy filename="bash"
sudo pacman -Syu git gcc make xz bc flex bison diffutils curl tar
```

## Build the kernel

Download and extract the kernel source:

```bash copy filename="bash"
curl -L https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.9.tar.xz --output linux.tar.xz
tar xf linux.tar.xz
```

Generate the default configuration:

```bash copy filename="bash"
cd linux
sudo make tinyconfig
```

Compile the kernel:

```bash copy filename="bash"
KCFLAGS="-Wa,-mx86-used-note=no" sudo make bzImage -j `nproc`
```

**The image is located at `arch/x86/boot/compressed/vmlinux.bin`**
13 changes: 6 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/images/schemas/initramfs-components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 89481d6

Please sign in to comment.