diff --git a/.prettierignore b/.prettierignore index af9c509..045e606 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,4 @@ node_modules/ .next/ package.json package-lock.json -pnpm-lock.yaml +pnpm-lock.yaml \ No newline at end of file diff --git a/package.json b/package.json index 2c6ea4b..25647d7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pages/docs/_meta.json b/pages/docs/_meta.json index e7e884e..817be43 100644 --- a/pages/docs/_meta.json +++ b/pages/docs/_meta.json @@ -3,5 +3,6 @@ "type": "separator", "title": "Getting Started" }, - "index": "Introduction" + "index": "Introduction", + "user-guide": "User Guide" } diff --git a/pages/docs/user-guide/_meta.json b/pages/docs/user-guide/_meta.json new file mode 100644 index 0000000..45e26ff --- /dev/null +++ b/pages/docs/user-guide/_meta.json @@ -0,0 +1,4 @@ +{ + "compiling-linux-kernel": "Compiling Linux Kernel", + "building-initramfs": "Building initramfs" +} diff --git a/pages/docs/user-guide/building-initramfs.mdx b/pages/docs/user-guide/building-initramfs.mdx new file mode 100644 index 0000000..0a5a038 --- /dev/null +++ b/pages/docs/user-guide/building-initramfs.mdx @@ -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)). + +
+ Initramfs components +
+ +## 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 +``` + + + Your init script **must** have execution rights. + + + + Your init script **must** start agent process to work with Lambdo. + + +## 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`.** diff --git a/pages/docs/user-guide/compiling-linux-kernel.mdx b/pages/docs/user-guide/compiling-linux-kernel.mdx new file mode 100644 index 0000000..b4acc74 --- /dev/null +++ b/pages/docs/user-guide/compiling-linux-kernel.mdx @@ -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`** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2146fe5..466b155 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,6 +34,9 @@ devDependencies: '@types/node': specifier: 18.11.10 version: 18.11.10 + '@types/react': + specifier: ^18.2.31 + version: 18.2.31 '@typescript-eslint/eslint-plugin': specifier: 6.7.4 version: 6.7.4(@typescript-eslint/parser@6.7.4)(eslint@8.51.0)(typescript@4.9.3) @@ -426,7 +429,7 @@ packages: react: '>=16' dependencies: '@types/mdx': 2.0.3 - '@types/react': 18.0.25 + '@types/react': 18.2.31 react: 18.2.0 dev: false @@ -772,19 +775,16 @@ packages: /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} - dev: false - /@types/react@18.0.25: - resolution: {integrity: sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==} + /@types/react@18.2.31: + resolution: {integrity: sha512-c2UnPv548q+5DFh03y8lEDeMfDwBn9G3dRwfkrxQMo/dOtRHUUO57k6pHvBIfH/VF4Nh+98mZ5aaSe+2echD5g==} dependencies: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.2 csstype: 3.1.1 - dev: false /@types/scheduler@0.16.2: resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} - dev: false /@types/semver@7.5.4: resolution: {integrity: sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==} @@ -1422,7 +1422,6 @@ packages: /csstype@3.1.1: resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==} - dev: false /debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} diff --git a/public/images/schemas/initramfs-components.png b/public/images/schemas/initramfs-components.png new file mode 100644 index 0000000..11dc500 Binary files /dev/null and b/public/images/schemas/initramfs-components.png differ