离线安装K3S

离线安装K3S

一、 安装docker

参照《DOCKER环境部署手册V1.docx》

二、 导入k3s镜像及安装文件准备

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

 

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

 

Loaded image: coredns/coredns:1.6.3

Loaded image: traefik:1.7.14

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

Loaded image: rancher/klipper-lb:v0.1.1

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

 

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  //赋予文件可执行权限

三、 部署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

 

四、 添加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         

 

posted on 2020-05-20 15:05  Cooper_73  阅读(3038)  评论(7编辑  收藏  举报

导航