192.168.8.8 rancher
192.168.8.21 Master
192.168.8.23 node1
192.168.8.25 node2
不论在线安装还是离线安装,首先必须install docker。详情可参考文章
菜单
方法一:在线安装
Master节点安装K3s server
国内环境
shell>curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -
国外环境
shell>K3s curl -sfL https://get.k3s.io | sh –
查看K3s状态
shell>ps -ef |grep k3s
或者
shell>systemctl status k3s
查看K3s节点情况
Shell>k3s kubectl get node
上述master节点的status状态显示Ready即已安装
开放6443端口
shell>firewall-cmd --permanent --add-port=6443/tcp
shell>firewall-cmd --reload
以上是主节点在线安装,下面将进行node节点的安装
获取Master的token
shell>cat /var/lib/rancher/k3s/server/node-token
国内环境
shell>curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | K3S_URL=https://192.168.8.21:6443 INSTALL_K3S_MIRROR=cn K3S_TOKEN=K1015a754b022e082d1f886a4420f35ac932fe06052367397df437379ed91160a20::server:0789a64658e89403cca1feb385f0df7b
sh -
国外环境
shell>curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | K3S_URL=https://192.168.8.15:6443 K3S_TOKEN=K1043dac8e7eaf605b4b07810197088ac1c70ed93e93b230dfc68da08d1d3e27a81::server:88e2a4d6d3fea8e6918d1296a65c1421 sh –
运行完毕后,在Master节点再查看node
Shell>k3s kubectl get node
最后把rancher的代码复制到主节点上运行即可
日志
shell>k3s kubectl get pods -A
shell>k3s kubectl logs cattle-cluster-agent-675c994dbb-ffg96 -n cattle-system