rancher主机
docker run -d --privileged -p 80:80 -p 443:443 -v /data/rancher/data/:/var/lib/rancher --restart always --name rancher rancher/rancher:latest
设置主机名
hostnamectl set-hostname master1
hostnamectl set-hostname node1
hostnamectl set-hostname node2
浏览器打开rancher-ui
docker logs rancher 2>&1 | grep "Bootstrap Password"
echo "4ipSDwFMDaVWkjMw" > password
mkdir ~/.kube
vim .kube/config # 写入下载的配置文件
去官方下载kubectl二进制文件
root@master1:~# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
debian NotReady,SchedulingDisabled control-plane,etcd,master,worker 4h38m v1.28.10+rke2r1 192.168.100.166 <none> Debian GNU/Linux 12 (bookworm) 6.1.0-18-amd64 containerd://1.7.11-k3s2
master1 Ready control-plane,etcd,master 20m v1.28.10+rke2r1 192.168.100.166 <none> Debian GNU/Linux 12 (bookworm) 6.1.0-18-amd64 containerd://1.7.11-k3s2
node1 Ready worker 4h1m v1.28.10+rke2r1 192.168.100.167 <none> Debian GNU/Linux 12 (bookworm) 6.1.0-18-amd64 containerd://1.7.11-k3s2
node2 Ready worker 4h1m v1.28.10+rke2r1 192.168.100.168 <none> Debian GNU/Linux 12 (bookworm) 6.1.0-18-amd64 containerd://1.7.11-k3s2
可以看到可以正常获取集群状态了