私有容器服务管理 Rancher

这里写图片描述

Rancher是进入容器服务管理中的后起之秀,后发优势也确实一览无余。但是在这个阶段还能挤进容器管理领域试图分一杯羹的,其也确实有过人之处,rancher的目标之一就是Easy to use,确实在新的技术层出不穷的出现的今天,如果缺少了这个特性势必无法得到用户的拥护。在本文中我们将会介绍如何安装和使用rancher server,同时也来看一下如何在这个开源的容器管理平台中实现私有容器服务,是不是Easy to use。

提供容器服务

提供容器服务,但什么是容器的服务呢。至少要包含以下三个方面才能称得上是一个容器的服务。

  • 容器编排:docker-compose/k8s等类似的功能
  • 容器管理:用户的管理以及镜像的管理等等
  • Infra管理:主机/网络/存储管理等

这里写图片描述

服务容器的编排,rancher和kubernetes以及mesos的定位是怎样的呢。对于这两位目前低位无法撼动的情况,看起来rancher选择的是支持,不重复造轮子,虽然多多少少造了一些,但那些是难免的。

前提条件

依赖软件 版本
docker 1.10及后续版本

docker pull

# docker pull rancher/server
  • 1

目前是842.9M的镜像,稍微有点大。

[root@host131 ~]# docker images |grep server
docker.io/rancher/server          latest              0a18f1c0ead2        2 weeks ago         842.9 MB
[root@host131 ~]#
  • 1
  • 2
  • 3

docker run

因为8080口被别的服务所占用,所以改用8888,可自行指定port

[root@host131 ~]# docker run -d --restart=always -p 8888:8080 rancher/server
475ce179145a090179d66eb03ed5885206d5947ca62fd338c07e574f1459915c
[root@host131 ~]#
  • 1
  • 2
  • 3

web access

提示追加host

这里写图片描述

设定server信息

这里写图片描述

扫描二维码关注公众号,回复: 4992548 查看本文章

添加host
创建3个host的组成的环境(Default)

机器项番 机器hostname
No.1 host132
No.2 host133
No.3 host134

这里写图片描述

将图中所提示的下列代码,到下面三台机器上分别执行,因为本文中使用root,所以sudo可以不用。

sudo docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://192.168.32.131:8888/v1/scripts/6FFA1E6826E16F541770:1473177600000:9yuG5DRzdCuDMuMSts7p4TA94
  • 1

注意事项:其实所做的事情就是在这3台机器上启动rancher的agent,要保证其所启动的container中能够联到rancher server的8888口,需要注意 防火墙/iptable/内网代理等问题的影响。详细可以通过使用rancher server的audit log页面和docker logs命令来确认信息。
添加host132

[root@host132 ~]# docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://192.168.32.131:8888/v1/scripts/6FFA1E6826E16F541770:1473177600000:9yuG5DRzdCuDMuMSts7p4TA94
Unable to find image 'rancher/agent:v1.0.2' locally
Trying to pull repository docker.io/rancher/agent ...
v1.0.2: Pulling from docker.io/rancher/agent

5a132a7e7af1: Pull complete
fd2731e4c50c: Pull complete
28a2f68d1120: Pull complete
a3ed95caeb02: Pull complete
7fa4fac65171: Pull complete
33de63de5fdb: Pull complete
d00b3b942272: Pull complete
Digest: sha256:b0b532d1e891534779d0eb1a01a5717ebfff9ac024db4412ead87d834ba92544
Status: Downloaded newer image for docker.io/rancher/agent:v1.0.2
a0e525a9e0e79a76cadfe06c084fc37ba1144739c9244a25ac57ab9e22a27a32
[root@host132 ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

添加host133

[root@host133 ~]# docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://192.168.32.131:8888/v1/scripts/6FFA1E6826E16F541770:1473177600000:9yuG5DRzdCuDMuMSts7p4TA94
Unable to find image 'rancher/agent:v1.0.2' locally
Trying to pull repository docker.io/rancher/agent ...
v1.0.2: Pulling from docker.io/rancher/agent

5a132a7e7af1: Pull complete
fd2731e4c50c: Pull complete
28a2f68d1120: Pull complete
a3ed95caeb02: Pull complete
7fa4fac65171: Pull complete
33de63de5fdb: Pull complete
d00b3b942272: Pull complete
Digest: sha256:b0b532d1e891534779d0eb1a01a5717ebfff9ac024db4412ead87d834ba92544
Status: Downloaded newer image for docker.io/rancher/agent:v1.0.2
36b020c4097fa3382fd62e71ca98bd459487b5076cb97a7f41acfc07893a5105
[root@host133 ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

添加host134

[root@host134 ~]# docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://192.168.32.131:8888/v1/scripts/6FFA1E6826E16F541770:1473177600000:9yuG5DRzdCuDMuMSts7p4TA94
Unable to find image 'rancher/agent:v1.0.2' locally
Trying to pull repository docker.io/rancher/agent ...
v1.0.2: Pulling from docker.io/rancher/agent

5a132a7e7af1: Pull complete
fd2731e4c50c: Pull complete
28a2f68d1120: Pull complete
a3ed95caeb02: Pull complete
7fa4fac65171: Pull complete
33de63de5fdb: Pull complete
d00b3b942272: Pull complete
Digest: sha256:b0b532d1e891534779d0eb1a01a5717ebfff9ac024db4412ead87d834ba92544
Status: Downloaded newer image for docker.io/rancher/agent:v1.0.2
515a85531fa406313cde12368195e80d352d5643428a4224c931ebba04294b47
[root@host134 ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

结果确认:因为这几台机器上同时设定过kubernetes,所以也被识别出来了
这里写图片描述

使用Catalog

这里写图片描述

选中gogs,然后launch

这里写图片描述

可以看到其add了一个stack

这里写图片描述

在hosts页面也可以看到增加了一个Stack: gogs。

这里写图片描述

总结:功能非常强大,确实简单易用。作为简单介绍,这里只能是冰山一角,强烈建议实际操作一下。另外Rancher还提供了一个RancherOS,是和Docker进行深度整合的一个作品,创意性的将所有的东西都跑在了容器中,分成了system container和user container,而且非常之小,也是值得稍微花点时间看看的。

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自www.cnblogs.com/firsttry/p/10294067.html
今日推荐