返回 登录
2

【内网福音】如何离线部署Rancher

对于在公司内网环境中、无法访问互联网的用户而言,离线安装部署Rancher是解决问题的关键。本文是Rancher离线部署教程,专为内网用户排坑解难。

版本说明

OS:Centos7.3
Docker version: 1.12.6
Rancher version: 1.6.10

主机角色说明

这里写图片描述

前期准备

docker rpm

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

harbor offline

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 及各组件 image:

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

如:

docker pull rancher/agent:v1.2.6
docker save rancher/agent:v1.2.6 > agent126.tar

部署环境

安装配置 docker (所有主机)

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私有镜像库IP

vi /usr/lib/systemd/system/docker.service

如修改为:

ExecStart=/usr/bin/dockerd --insecure-registry=192.168.100.1:80(私有库地址:端口)

安装配置 Harbor

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 导入私有镜像仓库

配置 Rancher 环境

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环境部署》

原文来源:Rancher Labs

评论