centos離線安裝k3s集羣

k3s架構

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

兩臺機器node

ip 角色
192.168.1.102 server
192.168.1.105 agent

二 進制準備

如下每臺機器都要執行
下載k3s
下載鏡像

git

下載安裝腳本install.shgithub

三安裝master節點

1.建立鏡像目錄並把鏡像複製到 /var/lib/rancher/k3s/agent/images/目錄docker

mkdir -p /var/lib/rancher/k3s/agent/images/
cp  k3s-airgap-images-$ARCH.tar /var/lib/rancher/k3s/agent/images/

2.安裝markdown

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相關指令對比,以下圖
command
spa

安裝agent

1.在master節點上查找token.net

[root@demo k3s]# cat /var/lib/rancher/k3s/server/node-token 
K10bc1b860845c709d9ca29a9997bb28abc9ae4baf51ae7a48e24cfa669f062f6fd::server:6985a3b11e7b4c38479ccd06ad9cf669

2.安裝code

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.查看結果server

[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官網

發佈了266 篇原創文章 · 獲贊 44 · 訪問量 71萬+
相關文章
相關標籤/搜索