作为云原生时代的平台的底层基石与资源管理器,kubnernetes在大中小企业都完成了实践与落地。尽管很多公有云都提供了,一键部署的服务,但是天下没有免费的午餐。羊毛出在羊身上,所以快速搭建集群还得靠自己。本系列带领大家,总结下市面上的快速构建平台的工具,帮助大家快速搭建自己的私有kubernetes平台。本文给大家介绍的是sealos
sealos一个简单干净轻量级稳定的kubernetes安装工具,使用简单,命令操作即可。
curl -sfL https://raw.githubusercontent.com/labring/sealos/v4.2.0/scripts/install.sh | sh -s v4.2.0 labring/sealos
如果网速较慢,可以换成手动下载的方式,当然手动下载前,需要先看看本机的系统的架构,然后再选择下载amd64还是arm64的。
uname -m
返回x86_64,表明是amd64的,因此我们通过下面命令下载
wget https://github.com/labring/sealos/releases/download/v4.2.0/sealos_4.2.0_linux_amd64.tar.gz \
&& tar zxvf sealos_4.2.0_linux_amd64.tar.gz sealos && chmod +x sealos && mv sealos /usr/bin
sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:v3.24.1 \
--masters 192.168.64.2,192.168.64.22,192.168.64.20 \
--nodes 192.168.64.21,192.168.64.19 -p [your-ssh-passwd]
我们为了演示,仅用了一台机器,通过ifconfig命令得到内部地址172.21.0.4
[root@master0 k8s]# ifconfig
eth0: flags=4163
inet 172.21.0.4 netmask 255.255.240.0 broadcast 172.21.15.255
inet6 fe80::5054:ff:fefe:b928 prefixlen 64 scopeid 0x20
ether 52:54:00:fe:b9:28 txqueuelen 1000 (Ethernet)
RX packets 96511 bytes 18836570 (17.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 77971 bytes 15111315 (14.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
然后运行下面命令安装:
sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:v3.24.1 --masters 172.21.0.4
当然如果上面的命令出现下面的问题,需要手动把ip_forward设置成1
[ERROR FileContent–proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
[preflight] If you know what you are doing, you can make a check non-fatal with --ignore-preflight-errors=...
To see the stack trace of this error execute with --v=5 or higher
2023-06-14T12:48:06 error Applied to cluster error: failed to init init master0 failed, error: exit status 1. Please clean and reinstall
Error: failed to init init master0 failed, error: exit status 1. Please clean and reinstall
设置ip_forward完成转发
sudo vi /etc/sysctl.conf
net.ipv4.ip_forward=1
sudo sysctl -p
然后清理下之前失败的安装,只要失败,就运行下面命令,很方便,之后再次运行上面的sealos run
sealos reset
sealos : https://www.sealyun.com/docs/lifecycle-management/quick-start/