對於在公司內網環境中、沒法訪問互聯網的用戶而言,離線安裝部署Rancher是解決問題的關鍵。本文是Rancher離線部署教程,專爲內網用戶排坑解難。linux
OS:Centos7.3 Docker version: 1.12.6 Rancher version: 1.6.10git
wget https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-1.12.6-1.el7.centos.x86_64.rpm wget https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-selinux-1.12.6-1.el7.centos.noarch.rpm
wget https://github.com/vmware/harbor/releases/download/v1.2.0/harbor-offline-installer-v1.2.0.tgz curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o ./docker-compose
rancher/server:v1.6.10 rancher/agent:v1.2.6 rancher/network-manager:v0.7.8 rancher/net:v0.11.9 rancher/dns:v0.15.3 rancher/metadata:v0.9.4 rancher/healthcheck:v0.3.3 rancher/lb-service-haproxy:v0.7.9 rancher/scheduler:v0.8.2 rancher/net:holder
如:github
docker pull rancher/agent:v1.2.6 docker save rancher/agent:v1.2.6 > agent126.tar
yum localinstall -y docker-engine-1.12.6-1.el7.centos.x86_64.rpm docker-engine-selinux-1.12.6-1.el7.centos.noarch.rpm 注:若有依賴使用 ISO 作 yum 源
指向docker私有鏡像庫IPdocker
vi /usr/lib/systemd/system/docker.service 如修改成: ExecStart=/usr/bin/dockerd --insecure-registry=192.168.100.1:80(私有庫地址:端口)
1.解壓: tar -zxvf harbor-offline-installer-v1.2.0.tgz 配置 harbor 2.編輯harbor.cfg vi harbor.cfg 修改 hostname = IP harbor_admin_password = Rancher123 3.運行 install.sh cp docker-compose /usr/local/bin/ chmod +x /usr/local/bin/docker-compose ./install.sh 4.添加項目 a)經過瀏覽?訪問harbor http://IP admin/Rancher123 登陸 b)添加名稱爲 'rancher' 的項目並設置爲「公開」 5.導入 images 登陸 docker login 私有倉庫 IP:端口 a) docker load -i agent126.tar b) docker tag rancher/agent:v1.2.6 192.168.100.1:80/rancher/agent:v1.2.6 c) docker push 192.168.100.1:80/rancher/agent:v1.2.6 按照以上方式將全部 Rancher image 導入私有鏡像倉庫
a) docker run -d --restart=unless-stopped -p 8080:8080 192.168.100.1:80/rancher/server:v1.6.10 b) 登陸 Rancher Server UI 「Admin」 -->「Settings」-->「Advanced Settings」編輯「registry.default=192.168.100.1:80」 c) 添加Environments 「Manage Environments」 -->"Add Environment"。 在建立完成後設置爲默認並切換到該環境。 d) 添加主機命令修改成 docker run --rm --privileged -v/var/run/docker.sock:/var/run/docker.sock - v /var/lib/rancher:/var/lib/rancher 192.168.100.1:80/rancher/agent:v1.2.6 http://192.168.100.1:8080/ v1/scripts/8EBE0FB0C3DE0AA32047:1483142400000:7Md3cXHoSIYYwHADyBpGQNZavTE e) 在主機節點上修改 agent image tag docker tag 192.168.100.1:80/rancher/agent:v1.2.6 rancher/agent:v1.2.6
配置 Rancher Server HA 請參考:《Rancher Server部署方式及Rancher HA環境部署》centos