k3s架构
机器准备
[root@demo k3s]# uname -a
Linux demo 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
两台机器
ip | 角色 |
---|---|
192.168.1.102 | server |
192.168.1.105 | agent |
二 进制准备
下载安装脚本install.sh
三安装master节点
1.创建镜像目录并把镜像复制到 /var/lib/rancher/k3s/agent/images/目录
mkdir -p /var/lib/rancher/k3s/agent/images/
cp k3s-airgap-images-$ARCH.tar /var/lib/rancher/k3s/agent/images/
2.安装
chmod +x k3s
cp k3s /usr/local/bin/
INSTALL_K3S_SKIP_DOWNLOAD=true ./install.sh
3.查看节点信息
4.查看服务是否正常
服务不正常的话,那就是镜像的问题
可以通过ctr
命令修改镜像
例子
[root@demo k3s]# ctr images tag docker.io/library/traefik:1.7.19 docker.io/rancher/library-traefik:1.7.19
和docker相关指令对比,如下图
安装agent
1.在master节点上查找token
[root@demo k3s]# cat /var/lib/rancher/k3s/server/node-token
K10bc1b860845c709d9ca29a9997bb28abc9ae4baf51ae7a48e24cfa669f062f6fd::server:6985a3b11e7b4c38479ccd06ad9cf669
2.安装
chmod +x k3s
cp k3s /usr/local/bin/
[root@promote ~]# cp k3s-airgap-images-amd64.tar /var/lib/rancher/k3s/agent/images/
[root@promote ~]# INSTALL_K3S_SKIP_DOWNLOAD=true K3S_URL=https://192.168.1.102:6443 K3S_TOKEN=K10bc1b860845c709d9ca29a9997bb28abc9ae4baf51ae7a48e24cfa669f062f6fd::server:6985a3b11e7b4c38479ccd06ad9cf669 sh install.sh
[INFO] Skipping k3s download and verify
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Creating /usr/local/bin/ctr symlink to k3s
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
Created symlink from /etc/systemd/system/multi-user.target.wants/k3s-agent.service to /etc/systemd/system/k3s-agent.service.
[INFO] systemd: Starting k3s-agent
3.查看结果
[root@demo k3s]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
demo Ready master 7h15m v1.17.4+k3s1
promote.cache-dns.local Ready <none> 28m v1.17.4+k3s1
end
参考
k3s官网