惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
W
WeLiveSecurity
O
OpenAI News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
N
News | PayPal Newsroom
H
Hacker News: Front Page
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Last Watchdog
The Last Watchdog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Heimdal Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Schneier on Security
宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
GbyAI
GbyAI
Cloudbric
Cloudbric
TaoSecurity Blog
TaoSecurity Blog
人人都是产品经理
人人都是产品经理
P
Palo Alto Networks Blog
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY
C
Check Point Blog
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
T
Troy Hunt's Blog
L
Lohrmann on Cybersecurity
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
量子位
博客园 - 聂微东
S
Securelist
博客园 - 三生石上(FineUI控件)
F
Full Disclosure
G
Google Developers Blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
AI
AI
PCI Perspectives
PCI Perspectives

Mereith's Blog

记一次代理转发问题的排查与解决 PVE DataCenter Manager 端口号跳转错误修复 k8s + jenkins + gitlab 触发器 【转载】没有编程生产力这样的东西 【后续】居然被 ddos 了 居然被 ddos 了 Tagger - 让版本标签管理更简单 openclash 开启后端口转发失效 nextjs 启动时执行代码 买了太多VPS不知道干什么,干脆做个网站 juhost Level-1 测评 VMISS CN - Hong Kong VMISS JP - Tokyo - BGP 测评 VMISS CN - Hong Kong - BGP HomeLab 的终点是 最近在做的事情 因为选择艰难症,自己写了一套开源博客系统 手撸一个nodejs分布式爬虫,还要可视化 HomeLab 分享 我的个人工作流——开源项目推荐 动手写一个超简单的编译器 safari 插件开发 Safari Extensions Preferences 按钮无响应 设置移动端软键盘回车按钮文案 nginx proxy manager 非标准端口反代 Host 不对 监控 k8s ingress 自动添加域名 DNS 解析 使用 ingress 注解给 traefik ingress 添加中间件 使用流水线功能为文章添加固定结尾 为 VanBlog 添加一个小挂件 基于React/umi/egg自建博客系统 如何正确停止 NodeJS 子进程 k8s pod 替换策略 让威联通、pve 共享 ups 实现断电关机 Ubuntu 配置 samba pve 无法启动 grub lvmid not found error antd Password 关闭自动补全 code-server node not found pve no quorum 错误 || 无法登录 pve Cannot Initiate CMAP Service pve 节点删不干净 PVE 指针(鼠标)漂移 pve 重启网络 Proxmox VE 直通显卡 ProxmoxVE (PVE) 7.0 换源升级 用 SOCAT 端口转发 git 无法 pull 仓库refusing to merge unrelated histories 用 vuepress 搭建私人知识库 js 防抖节流中的 this 与箭头函数 Dockerfile 给 Ubuntu 换源 docker 内访问宿主机 docker 删除无用镜像 css 实现展开收起动画 nginx 301 问题 Node.js 流式编程 关于我重写了三次博客项目这件事 css flex 布局超出隐藏 css 隐藏滚动条 css 文字超出隐藏并显示省略号 css 填充 svg 颜色 css 黑白滤镜 nginx 反代丢端口 docker-compose 部署 matomo 分析系统 基于 strapi 开发应用 strapi 关闭 Content Security Policy nginx 反代 rewite url ssh 通过跳板机访问目标机器 Cent os 7 安装 zsh 5.6 以上版本 win11 任务栏不合并 bash 数组操作 vim 修改文件格式为 unix k8s 集群 control-plane-endpoint 主机名 git https 保存密码 Bash 判断命令存在 & 重定向 python 导出项目依赖 cent os 7 安装 gcc 版本 9 System limit for number of file watchers reached cent os 7 安装 git 2.x css 下划线中间向两边滑动效果 linux 挂载 SMB/CIFS linux 清除 ACL windows 命令行安装 inf 驱动 css 文字不可选择 iperf3 网络测速工具 cent os 换源 k8s 1.21.3 从 docker 迁移到 containerd 解决Nginx安装错误:No package nginx available 问题 从pve的硬盘里导出数据 Errors were encountered while processing adguardhome配合clash pve中使用LXC容器安装OMV LXC直通硬盘 nginx反代模版 docker常用开启容器的命令 PVE的LXC容器中安装Docker ProxmoxVE系统分区相关 基于clash搭建旁路网关 Portainer添加节点 linux声卡设置及录音音 OpenWrt用VLAN PVE换源及去掉订阅提示和改端口 adguardhome踩坑
混合云部署k3s集群(基于wireguard)
wanglu@mereith.com (mereith) · 2022-08-09 · via Mereith's Blog

请注意,本文编写于 1410 天前,最后修改于 1397 天前,其中某些信息可能已经过时。

之前经常撸云服务器羊毛,就想搭建 k8s集群,一开始手动搭建太折腾了还有小问题,后来用了kubekey,感觉占用资源太多。

后来发现了 k3s 这个好东西,占用资源低。

后来发现了 wireguard 这个好东西,混合云组网神器。

后来发现了 network-manager 这个好东西,wireguard 组网神器。

那就搞吧!

配置概览

为了避免烂七八糟毛病,操作系统最好统一,这里我统一采用了 ubuntu 20.04 系统。

所有服务器概览如下:

云厂商配置架构
腾讯2C4Gamd64
阿里1C2Gamd64
华为2C4Gamd64

网络搭建

首先需要搭建星状网络,参考:

# 使用 Netmaker 快速组建 WireGuard mesh 网络

wget -O docker-compose.yml https://raw.githubusercontent.com/gravitl/netmaker/master/compose/docker-compose.contained.yml sed -i 's/NETMAKER_BASE_DOMAIN/<your base domain>/g' docker-compose.yml sed -i 's/SERVER_PUBLIC_IP/<your server ip>/g' docker-compose.yml sed -i 's/COREDNS_IP/<default interface ip>/g' docker-compose.yml # 生成 master key tr -dc A-Za-z0-9 </dev/urandom | head -c 30 ; echo '' sed -i 's/REPLACE_MASTER_KEY/<your generated key>/g' docker-compose.yml # 配置 Caddy wget -O /root/Caddyfile https://raw.githubusercontent.com/gravitl/netmaker/master/docker/Caddyfile sed -i 's/NETMAKER_BASE_DOMAIN/<your base domain>/g' /root/Caddyfile sed -i 's/YOUR_EMAIL/<your email>/g' /root/Caddyfile # 启动 docker-compose up -d

emm,总之按照官方的就能很轻松的部署了。

踩坑

后面我部署集群的时候发现 k3sserviceLB 会破坏 wirguard 网络的连通性。所以部署的时候一定要禁用。。。

master

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn INSTALL_K3S_SELINUX_WARN=true \\ INSTALL_K3S_EXEC="--disable servicelb --disable traefik --node-ip '10.20.30.7' --node-external-ip '82.157.137.245' --flannel-backend wireguard --kube-proxy-arg proxy-mode=ipvs --kube-proxy-arg masquerade-all=true --kube-proxy-arg metrics-bind-address=0.0.0.0 --tls-san 'k3s.mereith.com' --tls-san '82.157.137.245' " sh - # 获取 token cat /var/lib/rancher/k3s/server/token

node

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://82.157.137.245:6443 INSTALL_K3S_EXEC="--node-ip '10.20.30.5' --node-external-ip '82.157.125.43' --kube-proxy-arg proxy-mode=ipvs --kube-proxy-arg masquerade-all=true --kube-proxy-arg metrics-bind-address=0.0.0.0 " K3S_TOKEN="05ed38e986ebf0cdeb97bec629d1b7c9" sh -

复写 ip

因为云服务器自己还有内网 ip,为了保证网络畅通性,需要:

kubectl annotate nodes tx3 flannel.alpha.coreos.com/public-ip-overwrite=10.20.30.7

测试

## curl busybox kubectl run busybox --image sequenceiq/busybox --command -- /bin/sh -c "while true;do echo hello docker;sleep 1;done" kubectl exec -it busybox -- sh ## nginx test kubectl run nginx --image nginx

卸载

/usr/local/bin/k3s-uninstall.sh /usr/local/bin/k3s-agent-uninstall.sh ip link delete kube-ipvs0

注意

  • 需要禁用 servicelb ,不然会影响跨集群的 pod 畅通
  • 禁用 traefik 是为了用自己的编排,不禁用也行。

参考

# 使用 k3s 和 WireGuard 网络部署 Kubernetes 集群