离线安装方法 https://blog.csdn.net/weixin_38889300/article/details/120928924

  • 安装前初始化
设置主机名:hostnamectl set-hostname nodeXXX
关闭swap:swapoff -a && sudo sed -i 's/^.*swap/#&/g' /etc/fstab
安装docker: url -sSL https://get.docker.com/ | sh
设置 /etc/docker/daemon.json
{
    "log-driver":"json-file",
    "log-opts": {"max-size":"5m", "max-file":"5"},
    "registry-mirrors": [
       "https://mirror.ccs.tencentyun.com"
    ]
}
sudo systemctl daemon-reload
sudo systemctl restart docker

安装-下载文件

  • master
下载 https://github.com/k0sproject/k0sctl/releases
mv k0sctl-linux-x64 /usr/local/bin/k0sctl
chmod +x /usr/local/bin/k0sctl

下载k0s(注意k0sctl.yaml最后的版本号)
https://github.com/k0sproject/k0s/releases
mv k0s-v1.23.8+k0s.0-amd64  /usr/local/bin/k0s
chmod 755 -- /usr/local/bin/k0s
#复制k0s到其它服务器
scp k0s 192.168.110.35:/root/
#复制镜像包到其它服务器
scp bundle_file 192.168.110.35:/root/


k0sctl init > k0sctl.yaml #生成配置文件
* 添加每台服务器的免密登录
* 下载k0s文件 >上传到各个服务器/root/
* 拉取k8s.gcr.io的镜像包,并打成bundle_file,上传到各个服务器的 /root/
* 修改配置文件
k0sctl apply -c k0sctl.yaml 或者 k0sctl apply --config k0sctl.yaml 

k0s kubectl get nodes
k0s kubectl get node -o wide

ssh免密登录配置

cd ~/
mkdir .ssh
cd ~/.ssh
ssh-keygen -t rsa  如果存在可以直接使用 id_rsa.pub 一路回车
将公钥文件上传至免登录主机B
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.110.35 
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 9022 root@172.17.214.108 #有端口
或者复制k0s_rsa.pub的内容到其它机子的authorized_keys
重启远程 systemctl restart sshd
测试免密登录
ssh "root@192.168.110.36" 或者 ssh -p "9022" "root@172.17.214.107"