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

docs(run-on-alpine.md): update for Alpine's kernel changes #712

Merged
merged 1 commit into from
Dec 9, 2024
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
57 changes: 24 additions & 33 deletions docs/en/tutorials/run-on-alpine.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
# Run on Alpine Linux

**Note**: Alpine Linux 3.18 or newer verison has full eBPF support out-of-box, older version of Alpine Linux need to build kernel by yourself.
**Note:**
1. Alpine Linux 3.18 or newer verison has full eBPF support out-of-box, older version of Alpine Linux need to build kernel by yourself.
2. From version 3.20, Alpine Linux has officially disabled some features dae needed beacuse of Alpine Linux's cross CPU architectures compatibility, so only `linux-virt` can be used to run dae defaultly. For `linux-lts` or `linux-edge`, you should build the kernel by yourself.
3. This tutorial is for Alpine Linux 3.20 and newer.

## Enable Community Repo

Edit apk's repositories config:
Run `setup-apkrepos` command, then you'll get a menu list like this:

```sh
vi /etc/apk/repositories
```

Then enable community repo, for example:

```ini
https://dl-cdn.alpinelinux.org/alpine/edge/main
https://dl-cdn.alpinelinux.org/alpine/edge/community
(f) Find and use fastest mirror
(s) Show mirrorlist
(r) Use random mirror
(e) Edit /etc/apk/repositories with text editor
(c) Community repo enable
(skip) Skip setting up apk repositories
```

## Enable CGroup2
Then input `c` to enable community repo.

Edit OpenRC's config file:

```sh
vi /etc/rc.conf
```

Then edit `rc_cgroup_mode`, defaultly it would be `#rc_cgroup_mode="hybrid"`, we should switch to `unified` to make sure CGroup2 in default.

```ini
rc_cgroup_mode="unified"
```
## Enable CGroups

Then enable `cgroups` service:
Enable `cgroups` service:

```sh
rc-update add cgroups boot
Expand All @@ -48,17 +39,17 @@ vi /etc/init.d/sysfs
Add the following to the `mount_misc` section:

```sh
# Setup Kernel Support for bpf file system
if [ -d /sys/fs/bpf ] && ! mountinfo -q /sys/fs/bpf; then
if grep -qs bpf /proc/filesystems; then
ebegin "Mounting eBPF filesystem"
mount -n -t bpf -o ${sysfs_opts} bpffs /sys/fs/bpf
eend $?
# Setup Kernel Support for bpf file system
if [ -d /sys/fs/bpf ] && ! mountinfo -q /sys/fs/bpf; then
if grep -qs bpf /proc/filesystems; then
ebegin "Mounting eBPF filesystem"
mount -n -t bpf -o ${sysfs_opts} bpffs /sys/fs/bpf
eend $?
fi
fi
fi
```

Be careful that the format of the script `/etc/init.d/sysfs` must be fine, or `sysfs` service will be failed.
Be careful that the format of the script `/etc/init.d/sysfs` must be correct, or `sysfs` service will be failed.

## Install dae

Expand All @@ -70,13 +61,13 @@ This installer offered an OpenRC service script of dae, after installation, you
chmod 640 /usr/local/etc/dae/config.dae
```

If your config file is OK, then you can start dae service:
If your config file is ready to work, then you can start dae service:

```sh
rc-service dae start
```

## Start at boot
## Start dae at boot

Use `rc-update` to enable dae service:

Expand Down
76 changes: 76 additions & 0 deletions docs/zh/tutorials/run-on-alpine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 在 Alpine Linux 上运行

**注意:**
1. Alpine Linux 3.18 或更新版本已完全支持开箱即用的 eBPF,旧版本的 Alpine Linux 需要自己构建内核。
2. 从 3.20 版开始,由于 Alpine Linux 的跨 CPU 架构兼容性问题,官方禁用了 dae 所需的一些功能,因此默认情况下只能使用 `linux-virt` 运行 dae。对于 `linux-lts` 或 `linux-edge`,你应该自己构建内核。
3. 本教程适用于 Alpine Linux 3.20 及更新版本。

## 启用 Community Repo

运行 `setup-apkrepos` 命令,然后你会看到这样的菜单列表:

```
(f) Find and use fastest mirror
(s) Show mirrorlist
(r) Use random mirror
(e) Edit /etc/apk/repositories with text editor
(c) Community repo enable
(skip) Skip setting up apk repositories
```

然后输入 ``c` 启用社区仓库。

## 启用 CGgroups

启用 `cgroups` 服务:

```sh
rc-update add cgroups boot
```

## 挂载 bpf

编辑 `/etc/init.d/sysfs`:

```sh
vi /etc/init.d/sysfs
```

在 `mount_misc` 部分添加以下内容:

```sh
# Setup Kernel Support for bpf file system
if [ -d /sys/fs/bpf ] && ! mountinfo -q /sys/fs/bpf; then
if grep -qs bpf /proc/filesystems; then
ebegin "Mounting eBPF filesystem"
mount -n -t bpf -o ${sysfs_opts} bpffs /sys/fs/bpf
eend $?
fi
fi
```

请注意,脚本 `/etc/init.d/sysfs` 的格式必须正确,否则 `/etc/init.d/sysfs` 将被删除。

## 安装 dae

安装程序: <https://github.com/daeuniverse/dae-installer/>

此安装程序提供了一个 dae 的 OpenRC 服务脚本,安装后,您需要在 `/usr/local/etc/dae/config.dae` 中添加一个配置文件,然后将其权限设置为 600 或 640:

```sh
chmod 640 /usr/local/etc/dae/config.dae
```

如果配置文件已准备就绪,那就可以启动 dae 服务了:

```sh
rc-service dae start
```

## 随系统启动

使用 `rc-update` 启用 dae 服务:

```sh
rc-update add dae
```