Skip to content

Commit 30a0755

Browse files
committed
k3s+cilium
1 parent 50f0bed commit 30a0755

File tree

7 files changed

+128
-3
lines changed

7 files changed

+128
-3
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- [K8s](linux/Kubernetes/README.md)
2222
- [权限与用户](linux/Kubernetes/权限与用户.md)
2323
- [OKG(OpenKruiseGame)](linux/Kubernetes/OpenKruiseGame.md)
24+
- [在k3s中安装cilium并使用eBPF路由](linux/Kubernetes/20251130-在k3s中安装cilium并使用eBPF路由.md)
2425
- [NAS的一些记录](HomeNetwork/NAS/README.md)
2526
- [群晖](HomeNetwork/NAS/DSM/README.md)
2627
- [改群晖DSM的默认端口](HomeNetwork/NAS/DSM/ChangeSynologyNginxPoint.md)

src/linux/ArchLinux备忘录.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
## 配置Bitwarden为系统SSH Agnet
1111
1. 设置里开启
12-
![启用SSH Agent](/assets/linux/20251027-Bitwarden启用SSHAgent.png)
12+
![启用SSH Agent](../assets/linux/20251027-Bitwarden启用SSHAgent.png)
1313
2. 配置环境变量
1414
- rc文件
1515
```sh
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# 在k3s中安装cilium并使用eBPF路由 <!-- omit in toc -->
2+
3+
> **本文环境:**
4+
> * k3s version v1.32.10+k3s1 (1c5d65ce)
5+
go version go1.24.9
6+
> * debian 13.2 (trixie)
7+
6.12.57+deb13-amd64
8+
9+
- [安装 k3s 集群](#安装-k3s-集群)
10+
- [安装 Cilium](#安装-cilium)
11+
- [](#用)
12+
13+
14+
## 安装 k3s 集群
15+
16+
根据 [K3s 安装选项介绍][k3s/install-options][K3s Server 配置参考][k3s/server-config][Cilium 安装文档][install-cilium] 得来
17+
```sh
18+
TOKEN=`dd if=/dev/urandom bs=4M count=1 | md5sum | xargs printf "%s\n" | head -1`
19+
ARGS=(
20+
--write-kubeconfig-mode=0644
21+
--flannel-backend=none
22+
--disable-network-policy
23+
--disable-kube-proxy
24+
--disable-cloud-controller
25+
# 下面这些组件按需禁用
26+
--disable=servicelb
27+
--disable=traefik
28+
--disable=metrics-server
29+
--disable=local-storage
30+
)
31+
echo $TOKEN
32+
33+
# 第一个节点
34+
curl -sfL https://get.k3s.io | K3S_TOKEN=${TOKEN}\
35+
INSTALL_K3S_EXEC="${ARGS[@]}"\
36+
INSTALL_K3S_CHANNEL=v1.32\
37+
sh - --cluster-init
38+
39+
# 其他控制平面节点
40+
curl -sfL https://get.k3s.io | K3S_TOKEN=${TOKEN}\
41+
INSTALL_K3S_EXEC="${ARGS[@]}"\
42+
INSTALL_K3S_CHANNEL=v1.32\
43+
sh - --server https://${第一个节点IP}:6443
44+
45+
# Agent节点
46+
curl -sfL https://get.k3s.io | K3S_TOKEN=${TOKEN}\
47+
INSTALL_K3S_EXEC="${ARGS[@]}"\
48+
INSTALL_K3S_CHANNEL=v1.32\
49+
K3S_URL=https://${第一个节点IP}:6443\
50+
sh -
51+
```
52+
53+
安装完成后除了第一个节点以外,其他节点都是`NotReady`,这是正常现象,毕竟现在没有网络
54+
55+
| NAME | STATUS | ROLES | AGE | VERSION |
56+
| :---- | :------- | :------------------------ | :--- | :------------ |
57+
| k3s-1 | Ready | control-plane,etcd,master | 1h | v1.32.10+k3s1 |
58+
| k3s-2 | NotReady | control-plane,etcd,master | 1h | v1.32.10+k3s1 |
59+
| k3s-3 | NotReady | control-plane,etcd,master | 1h | v1.32.10+k3s1 |
60+
61+
## 安装 Cilium
62+
63+
1. 安装 Helm
64+
参考 [Installing Helm][install-helm] 安装
65+
2. 配置仓库
66+
```sh
67+
helm repo add cilium https://helm.cilium.io/
68+
```
69+
3. 安装 Cilium
70+
```sh
71+
helm install cilium cilium/cilium --version 1.18\
72+
--namespace kube-system\
73+
--set ipam.operator.clusterPoolIPv4PodCIDRList="10.42.0.0/16"\
74+
--set routingMode=native\
75+
--set bpf.datapathMode=netkit\
76+
--set bpf.masquerade=true\
77+
--set bpf.distributedLRU.enabled=true\
78+
--set bpf.mapDynamicSizeRatio=0.08\
79+
--set ipv4.enabled=true\
80+
--set enableIPv4BIGTCP=true\
81+
--set kubeProxyReplacement=true\
82+
--set bpfClockProbe=true\
83+
--set ipv4NativeRoutingCIDR="10.42.0.0/16"
84+
```
85+
86+
每一项的作用
87+
88+
| 项目 | 作用 |
89+
| :----------------------------------------- | :------------------------------------------ |
90+
| `ipam.operator.clusterPoolIPv4PodCIDRList` | 设定集群的Pod地址池与K3s配置一致 |
91+
| `routingMode=native` | 使用原生路由模式 |
92+
| `bpf.datapathMode=netkit` | 使用 [netkit](https://www.netkit.org/) 网卡 |
93+
| `bpf.masquerade` | 使用 eBPF 来做 NAT |
94+
| `bpf.distributedLRU.enabled` | 启用分布式 LRU 后端内存 |
95+
| `bpf.mapDynamicSizeRatio` | 设定动态映射内存百分比 |
96+
| `ipv4.enabled` | 启用IPv4 |
97+
| `enableIPv4BIGTCP` | 开启IPv4高吞吐能力 |
98+
| `kubeProxyReplacement` | 替代 kube-proxy |
99+
| `bpfClockProbe` | 启用 eBPF 时钟源探测 |
100+
| `ipv4NativeRoutingCIDR` | 设定可以路由的IPv4地址段 |
101+
4. 等待完成
102+
103+
##
104+
现在所有节点都是`Ready`
105+
106+
| NAME | STATUS | ROLES | AGE | VERSION |
107+
| :---- | :----- | :------------------------ | :--- | :------------ |
108+
| k3s-1 | Ready | control-plane,etcd,master | 1h | v1.32.10+k3s1 |
109+
| k3s-2 | Ready | control-plane,etcd,master | 1h | v1.32.10+k3s1 |
110+
| k3s-3 | Ready | control-plane,etcd,master | 1h | v1.32.10+k3s1 |
111+
112+
113+
[k3s/install-options]: https://docs.rancher.cn/docs/k3s/installation/install-options/
114+
[k3s/server-config]: https://docs.rancher.cn/docs/k3s/installation/server-config/
115+
[install-cilium]: https://docs.cilium.io/en/stable/gettingstarted/k8s-install-default/#install-cilium
116+
[install-helm]: https://helm.sh/zh/docs/intro/install/

src/linux/Kubernetes/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# K8s
22

33
- [权限与用户](权限与用户.md)
4-
- [OKG(OpenKruiseGame)](OpenKruiseGame.md)
4+
- [OKG(OpenKruiseGame)](OpenKruiseGame.md)
5+
- [在k3s中安装cilium并使用eBPF路由](20251130-在k3s中安装cilium并使用eBPF路由.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 在k3s中安装cilium并使用eBPF路由
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
```sh
3+
set -euo pipefail
4+
```

src/linux/日常使用/20251027-Wayland-Plasmashell-Nvidia.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ Qt 版本: 6.10.0
1818

1919
## 2. 方法
2020
~/.config/systemd/user/plasma-plasmashell.service.d/override.conf
21-
```conf
21+
```ini
2222
[Service]
2323
Environment=__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json
2424
Environment=__GLX_VENDOR_LIBRARY_NAME=mesa
2525
```
26+
### 缺点
27+
- 无法获取窗口预览图

0 commit comments

Comments
 (0)