返回介绍

Docker GUI 之 Shipyard+Swarm

发布于 2023-07-12 13:02:37 字数 7659 浏览 0 评论 0 收藏 0

Shipyard(github)是建立在 docker 集群管理工具 Citadel 之上的可以管理容器、主机等资源的 web 图形化工具。包括 core 和 extension 两个版本,core 即 shipyard 主要是把多个 Docker host 上的 containers 统一管理(支持跨越多个 host),extension 即 shipyard-extensions 添加了应用路由和负载均衡、集中化日志、部署等

1. 几个概念

engine

一个 shipyard 管理的 docker 集群可以包含一个或多个 engine(引擎),一个 engine 就是监听 tcp 端口的 docker daemon。shipyard 管理 docker daemon、images、containers 完全基于 Docker API,不需要做其他的修改。另外,shipyard 可以对每个 engine 做资源限制,包括 CPU 和内存;因为 TCP 监听相比 Unix socket 方式会有一定的安全隐患,所以 shipyard 还支持通过 SSL 证书与 docker 后台进程安全通信。

rethinkdb

RethinkDB 是一个 shipyard 项目的一个 docker 镜像,用来存放账号(account)、引擎(engine)、服务密钥(service key)、扩展元数据(extension metadata)等信息,但不会存储任何有关容器或镜像的内容。一般会启动一个 shipyard/rethinkdb 容器 shipyard-rethinkdb-data 来使用它的/data 作为数据卷供另外 rethinkdb 一个挂载,专门用于数据存储。

官方网站:

http://shipyard-project.com/
https://docs.docker.com/swarm/install-w-machine/
https://github.com/shipyard/docker-private-registry

国内镜像源:

https://hub.alauda.cn/
https://hub.tenxcloud.com/

2. 启动 Swarm Manager

docker run -tid \
    -p 3375:3375 \
    --restart=always \
    --name shipyard-swarm-manager \
    swarm:latest \
    manage --host  tcp://0.0.0.0:3375  consul://[consul server ip]:8500

3. 启动 Swarm Agent

docker run -tid \
    --restart=always \
    --name shipyard-swarm-agent \
    swarm:latest \
    join --addr [local ip]:2375 consul://[consul server ip]:8500

4. 查看集群状态

[root@node1 ~]# docker -H 127.0.0.1:3375 info
Containers: 9
 Running: 8
 Paused: 0
 Stopped: 1
Images: 22
Server Version: swarm/1.2.4
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint
Nodes: 2
 node1.docker.com: 192.168.20.113:2375
  └ ID: HXUI:TQ3U:RMGP:5Q2W:V4L5:6JDM:4DB6:LEKK:4JBU:GQVP:NV2C:P72Y
  └ Status: Healthy
  └ Containers: 7 (7 Running, 0 Paused, 0 Stopped)
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 1.883 GiB
  └ Labels: kernelversion=3.10.0-327.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-08-11T03:04:21Z
  └ ServerVersion: 1.12.0
 node2.docker.com: 192.168.20.112:2375
  └ ID: U6ZN:GZ5O:O3QQ:TMFD:CVHR:4GAX:BVTC:HE7D:XRGD:GC24:HBSZ:ZBEL
  └ Status: Healthy
  └ Containers: 2 (1 Running, 0 Paused, 1 Stopped)
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 1.015 GiB
  └ Labels: kernelversion=3.10.0-327.el7.x86_64, operatingsystem=CentOS Linux 7 (Core), storagedriver=devicemapper
  └ UpdatedAt: 2016-08-11T03:04:39Z
  └ ServerVersion: 1.12.0
Plugins:
 Volume: 
 Network: 
Swarm: 
 NodeID: 
 Is Manager: false
 Node Address: 
Security Options:
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: linux
Architecture: amd64
CPUs: 2
Total Memory: 2.898 GiB
Name: 390a6e318641
Docker Root Dir: 
Debug Mode (client): false
Debug Mode (server): false
WARNING: No kernel memory limit support

5. 启动 Datastore(rethinkdb)

https://hub.tenxcloud.com/repos/docker_library/rethinkdb
https://hub.alauda.cn/repos/library/rethinkdb

提示:可以使用国内源 index.tenxcloud.com/docker_library/rethinkdb

docker run -tid \
     --restart=always \
     --name shipyard-rethinkdb \
     -p 28015:28015 \
     -p 29015:29015 \
     -v /data/rethinkdb:/data \
     index.tenxcloud.com/docker_library/rethinkdb

6. 部署 shipyard 镜像

docker run -tid \
    --restart=always \
    --name shipyard-controller \
    --link shipyard-rethinkdb:rethinkdb \
    --link shipyard-swarm-manager:swarm \
    -p 80:8080 \
    shipyard/shipyard:latest \
    server \
    -d  tcp://swarm:3375 

提示:

shipyard 这里使用了--link 和别名

rethinkdb 默认监听 28015、29015、8080,支持集群

[root@node1 data]# docker logs -f 3717177be520
Recursively removing directory /data/rethinkdb_data/tmp
Initializing directory /data/rethinkdb_data
Running rethinkdb 2.3.4~0jessie (GCC 4.9.2)...
Running on Linux 3.10.0-327.el7.x86_64 x86_64
Loading data from directory /data/rethinkdb_data
warn: Cache size does not leave much memory for server and query overhead (available memory: 944 MB).
warn: Cache size is very low and may impact performance.
Listening for intracluster connections on port 29015
Listening for client driver connections on port 28015
Listening for administrative HTTP connections on port 8080
Listening on cluster addresses: 127.0.0.1, 172.17.0.3, ::1, fe80::42:acff:fe11:3%252
Listening on driver addresses: 127.0.0.1, 172.17.0.3, ::1, fe80::42:acff:fe11:3%252
Listening on http addresses: 127.0.0.1, 172.17.0.3, ::1, fe80::42:acff:fe11:3%252
Server ready, "3717177be520_uhp" 624aac86-1dc9-4846-9e89-848e64cb077f

[root@node1 data]# docker logs -f 90ad377398b8
INFO[0000] shipyard version 3.0.5                       
INFO[0000] checking database                            
INFO[0002] created admin user: username: admin password: shipyard 
INFO[0002] controller listening on :8080

这个就是 web GUI 控制台 http://localhost

可以实现容器、镜像、集群节点、registry、账号、事件的管理、非常简洁

注意:shipyard 控制台默认的用户名和密码为 admin/shipyard

4. 其它管理工具 shipyard 命令行接口

docker run -it shipyard/shipyard-cli
shipyard cli> shipyard login
URL:  http://192.168.192.10:8080 
Username: admin
Password: 
shipyard cli> shipyard 
NAME:
   shipyard - manage a shipyard cluster

USAGE:
   shipyard [global options] command [command options] [arguments...]

VERSION:
   2.0.8

COMMANDS:
   login                login to a shipyard cluster
   change-password      update your password
   accounts             show accounts
   add-account          add account
   delete-account       delete account
   containers           list containers
   inspect              inspect container
   run                  run a container
   stop                 stop a container
   restart              restart a container
   scale                scale a container
   logs                 show container logs
   destroy              destroy a container
   engines              list engines
   add-engine           add shipyard engine
   remove-engine        removes an engine
   inspect-engine       inspect an engine
   service-keys         list service keys
   add-service-key      adds a service key
   remove-service-key   removes a service key
   extensions           show extensions
   add-extension        add extension
   remove-extension     remove an extension
   webhook-keys         list webhook keys
   add-webhook-key      adds a webhook key
   remove-webhook-key   removes a webhook key
   info                 show cluster info
   events               show cluster events
   help, h              Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h                   show help
   --generate-bash-completion   
   --version, -v                print the version

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文