離線安裝K3S

離線安裝K3S

1、 安裝dockernode

參照《DOCKER環境部署手冊V1.docx》linux

2、 導入k3s鏡像及安裝文件準備git

wget  https://github.com/rancher/k3s/releases/download/v0.9.0/k3s-airgap-images-amd64.targithub

 

docker load < k3s-airgap-images-amd64.tardocker

 

Loaded image: coredns/coredns:1.6.3url

Loaded image: traefik:1.7.14spa

Loaded image: rancher/klipper-helm:v0.1.5.net

Loaded image: rancher/klipper-lb:v0.1.13d

Loaded image: k8s.gcr.io/pause:3.1rest

 

wget https://github.com/rancher/k3s/releases/download/v0.9.0/k3s

 

wget https://github.com/rancher/k3s/blob/master/install.sh

 

 

mv k3s /usr/local/bin        //將k3s二進制文件移動到k3s安裝目錄

chmod +x install.sh    //賦予文件可執行權限

chmod +x k3s  //賦予文件可執行權限

3、 部署k3s server

export INSTALL_K3S_SKIP_DOWNLOAD=true     //設置跳過下載k3s二進制文件

export INSTALL_K3S_BIN_DIR=/usr/local/bin       //設置k3s安裝目錄

直接執行./install.sh 遇到以下報錯,按照提示安裝依賴包便可。

[root@xxxxx k3s]# ./install.sh

[INFO]  Skipping k3s download and verify

[ERROR]  Failed to find the k3s-selinux policy, please install:

    yum install -y container-selinux selinux-policy-base

rpm -i https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm

 

修改配置

vi /etc/systemd/system/k3s.service

ExecStart=/usr/local/bin/k3s server --docker --no-deploy traefik

 

systemctl daemon-reload    //刷新服務配置文件

systemctl restart k3s     //啓動k3d

 

4、 添加k3s agent

 

K3S_TOKEN是server端的,位於/var/lib/rancher/k3s/server/node-token下

cat /var/lib/rancher/k3s/server/node-token

 

在node節點執行命令,格式爲

K3S_URL=${k3s_url} K3S_TOKEN=${k3s_token}  ./install.sh

 

執行以下命令

K3S_TOKEN=xxxxxx K3S_URL=https://serverIP:6443 ./install.sh

 

啓動失敗,編輯配置文件/etc/systemd/system/k3s-agent.service

內容以下:

ExecStart=/usr/local/bin/k3s \

    agent --docker         

相關文章
相關標籤/搜索