转载自 https://www.cnblogs.com/heyongboke/p/10837503.html
Shipyard是在Docker Swarm实现对容器、镜像、docker集群、仓库、节点进行管理的web系统。
1.Shipyard功能
1
|
Shipyard是一个集成管理docker容器、镜像、Registries的系统,它可以简化对横跨多个主机的Docker容器集群进行管理. 通过Web用户界面,你可以大致浏览相关信息,比如你的容器在使用多少处理器和内存资源、在运行哪些容器,还可以检查所有集群上的事件日志。
|
2.Shipyard特点:
1
2
3
4
|
支持多节点的集成管理;
支持镜像、容器、节点管理等功能;
可视化的容器管理和监控管理;
可动态加载节点。
|
3.Shipyard几个概念
1)engine
1
|
一个shipyard管理的docker集群可以包含一个或多个engine(引擎),一个engine就是监听tcp端口的dockerdaemon。shipyard管理docker daemon、images、containers完全基于
|
2)rethinkdb
1
|
RethinkDB是一个shipyard项目的一个docker镜像,用来存放账号(account)、引擎(engine)、服务密钥(service key)、扩展元数据(extension metadata)等信息,但不会存储
|
4.Shipyard生态
shipyard是由shipyard控制器以及周围生态系统构成,以下按照deploy启动顺序进行介绍(下面几个就是shipyard使用脚本安装后,启动的几个容器名)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
1)RethinkDB
deploy首先启动的就是RethinkDB容器,shipyard采用RethinkDB作为数据库来保存用户等信息
2)Discovery
为了使用Swarm,我们需要一个外部的密钥值存储群容器,shipyard默认是采用了etcd。
3)shipyard_certs
证书管理容器,实现证书验证功能
4)Proxy
默认情况下,Docker引擎只监听Socket,我们可以重新配置引擎使用TLS或者使用一个代理容器,转发请求从TCP到Docker监听的UNIX Socket。
5)Swarm Manager
Swarm管理器
6)Swarm Agent
Swarm代理,运行在每个节点上。
7)Controller
shipyard控制器,Remote API的实现和web的实现。
|
5.Centos7.2系统下Shipyard(中文版)部署记录
查看系统版本及ip
1
2
3
4
5
|
[root@pre1 gh]
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@pre1 gh]
# ifconfig|grep 192.168.3.141
inet 192.168.3.141 netmask 255.255.255.0 broadcast 192.168.3.255
|
6.安装最新版docker
1
|
[root@pre1 ~]
# curl -fsSL https://get.docker.com/ | sh
|
修改docker配置文件,添加下面一行,进行docker加速设置
1
2
|
[root@pre1 ~]
# vim /etc/sysconfig/docker //在文件底部添加下面一行, (这里就是直接写: xxx.mirror.aliyuncs.com)
ADD_REGISTRY=
'--add-registry xxx.mirror.aliyuncs.com'
|
启动docker服务
1
|
[root@docker-218 ~]
# systemctl start docker
|
加入开机自启动
1
|
[root@pre1 ~]
# systemctl enable docker
|
7.下载相关镜像
1
2
3
4
5
|
[root@pre1 ~]
# docker pull rethinkdb
[root@pre1 ~]
# docker pull microbox/etcd
[root@pre1 ~]
# docker pull shipyard/docker-proxy
[root@pre1 ~]
# docker pull swarm
[root@pre1 ~]
# docker pull dockerclub/shipyard
|
8.下载官方一键部署脚本
1
2
|
链接: https:
//pan
.baidu.com
/s/1WHGOe6LX9-eU39vf1SzbRg
提取码: tbkf
|
一键部署
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@pre1 ~]
# chmod 755 shipyard-deploy
[root@pre1 ~]
# sh shipyard-deploy
Deploying Shipyard
-> Starting Database
-> Starting Discovery
-> Starting Cert Volume
-> Starting Proxy
-> Starting Swarm Manager
-> Starting Swarm Agent
-> Starting Controller
Waiting
for
Shipyard on 192.168.3.141:8080
Shipyard available at http:
//192
.168.3.141:8080
Username: admin Password: shipyard
|
9.查看部署好的shipyard容器
1
2
3
4
5
6
7
8
9
|
[root@pre1 ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
076c8c7bd1a9 dockerclub
/shipyard
:latest
"/bin/controller --d…"
16 hours ago Up 16 hours 0.0.0.0:8080->8080
/tcp
shipyard-controller
4fb76868ce60 swarm:latest
"/swarm j --addr 192…"
16 hours ago Up 16 hours 2375
/tcp
shipyard-swarm-agent
0eedb34ffd18 swarm:latest
"/swarm m --replicat…"
16 hours ago Up 16 hours 2375
/tcp
shipyard-swarm-manager
54751b647576 shipyard
/docker-proxy
:latest
"/usr/local/bin/run"
16 hours ago Up 16 hours 0.0.0.0:2375->2375
/tcp
shipyard-proxy
752d7adeb566 alpine
"sh"
16 hours ago Up 16 hours shipyard-certs
030228a5adcb microbox
/etcd
:latest
"/bin/etcd -addr 192…"
16 hours ago Up 16 hours 0.0.0.0:4001->4001
/tcp
, 0.0.0.0:7001->7001
/tcp
shipyard-discovery
cce83381bd72 rethinkdb
"rethinkdb --bind all"
16 hours ago Up 16 hours 8080
/tcp
, 28015
/tcp
, 29015
/tcp
shipyard-rethinkd
|
最后访问http://192.168.3.141:8080,使用admin/shipyard用户名和密码登录即可
如果想要修改web访问端口,则操作如下:
1
2
3
|
[root@pre1 ~]
# cat shipyard-deploy |grep 8080
echo
" PORT: specify the listen port for the controller (default: 8080)"
SHIPYARD_PORT=${PORT:-8080}
|
比如将脚本中默认的8080端口改为80端口
1
|
[root@pre1 ~]
# sed -i 's/8080/80/g' shipyard-deploy
|
然后重新部署即可
附:登录页面
进入之后的管理页面
10.删除Shipyard环境操作
1
2
3
4
5
6
7
8
9
10
|
[root@pre1 ~]
# cat shipyard-deploy |ACTION=remove bash
Removing Shipyard
-> Removing Database
-> Removing Discovery
-> Removing Cert Volume
-> Removing Proxy
-> Removing Swarm Agent
-> Removing Swarm Manager
-> Removing Controller
Done
|
查看验证是否删除
1
2
|
[root@pre1 ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
11.Shipyard添加其他节点主机
比如将172.16.60.220机器节点加入到上面的shipyard管理中.
则需要在被加入节点机器上如下操作:
1) 在被加入的节点上按照上面的最新地址下载shipyard-deploy
2) 执行下面操作 (注意下面etcd地址要写成shipyard部署机的ip地址. 首次执行时会自动下载镜像,需要等待一段时间)
1
2
3
4
5
6
7
8
9
10
|
[root@pre2 ~]
# cat shipyard-deploy| ACTION=node DISCOVERY=etcd://192.168.3.141:4001 bash
Adding Node
-> Starting Cert Volume
Unable to
find
image
'alpine:latest'
locally
latest: Pulling from library
/alpine
….
-> Starting Swarm Agent
Node added to Swarm: 192.168.3.142
|
查看安装好的shipyard
1
2
3
4
5
6
|
[root@pre2 ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6acbc12d72bc swarm:latest
"/swarm j --addr 192…"
About an hour ago Up About an hour 2375
/tcp
shipyard-swarm-agent
eabdf5e5d81b swarm:latest
"/swarm m --replicat…"
About an hour ago Up About an hour 2375
/tcp
shipyard-swarm-manager
3a3d104b5918 shipyard
/docker-proxy
:latest
"/usr/local/bin/run"
About an hour ago Up About an hour 0.0.0.0:2375->2375
/tcp
shipyard-proxy
eb85858f6de6 alpine
"sh"
About an hour ago Up About an hour shipyard-certs
|
注意,添加节点时,上面一键脚本需要运行在被添加的节点主机上,而不是shipyard部署节点的机器上.
然后登录http://192.168.3.141:8080,在"容器管理"-"主机节点"中看到添加的节点信息了.
12.删除节点机
1
2
3
4
5
6
7
8
9
10
|
[root@pre2 ~]
# cat shipyard-deploy |ACTION=remove bash -s
Removing Shipyard
-> Removing Database
-> Removing Discovery
-> Removing Cert Volume
-> Removing Proxy
-> Removing Swarm Agent
-> Removing Swarm Manager
-> Removing Controller
Done
|
验证是否删除成功
1
2
3
|
[root@pre2 ~]
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
-----------------------------------------要克服生活的焦虑和沮丧,得先学会做自己的主人-----------------------------------------