您的位置:首页 > 运维架构 > Docker

生产环境的开源容器管理平台--Rancher入门教程(5):自定义Catalog工具

2016-09-28 21:30 1196 查看


Rancher是一个用于部署和管理生产环境的容器的开源平台,它与Kubernetes/Mesos/Docker Swarm进行集成。使得在任何硬件环境上容器化应用变得触手可及。在这个系列的教程中我们将会学习如何使用rancher, 上篇文章介绍了如何在rancher中添加自定义的catalog,由于较为繁琐,本文介绍一下相关自动化工具。

yo rancher-catalog

在上篇文章中介绍了自定义catalog的方法,但是文件较多,限制很多,从文件名到内容很小的地方都可能造成不能正常显示,使用npm的rancher-catalog这个小工具可以绕开一部分问题。

安装

npm install -g yo
npm install -g generator-rancher-catalog


执行方法

yo rancher-catalog


demo

生成



设定



确认





rancher-cattle-autocatalog

使用npm的yo,前提是还必须要安装npm,所以也可以使用rancher-cattle-autocatalog进行处理。

使用例

[root@liumiaocn rancher]# pwd
/tmp/rancher
[root@liumiaocn rancher]# ll
total 0
[root@liumiaocn rancher]# git clone https://github.com/liumiaocn/rancher-cattle-autocatalog Cloning into 'rancher-cattle-autocatalog'...
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 18 (delta 1), reused 14 (delta 0), pack-reused 0
Unpacking objects: 100% (18/18), done.
[root@liumiaocn rancher]# cd rancher-cattle-autocatalog/scripts/
[root@liumiaocn scripts]# ll
total 8
-rw-r--r--. 1 root root 2525 Sep 28 20:39 create_rancher_cattle_catalog.sh
drwxr-xr-x. 3 root root   22 Sep 28 20:39 DEMO
-rw-r--r--. 1 root root  401 Sep 28 20:39 init.conf
[root@liumiaocn scripts]# cat init.conf
DEMO                @ nginx
DEMONAME            @ nginx
DEMODESCRIPTION     @ nginx image
DEMOVERSION         @ 1.0.0
DEMOCATAGORY        @ WEB
DEMOMAINTAINER      @ liumiaocn@outlook.com
DEMOLICENSE         @ Apache 2
DEMOURL             @ liumiaocn\/rancher-cattle-autocatalog
DEMOIMAGE           @ nginx
DEMOPORTMAPPING     @ 80:80
DEMOUUID            @
DEMOMINIMUM_VERSION @
DEMOQUESTIONS       @
[root@liumiaocn scripts]#
[root@liumiaocn scripts]# sh create_rancher_cattle_catalog.sh  init.conf
[root@liumiaocn scripts]# ll
total 8
-rw-r--r--. 1 root root 2525 Sep 28 20:39 create_rancher_cattle_catalog.sh
drwxr-xr-x. 3 root root   22 Sep 28 20:39 DEMO
-rw-r--r--. 1 root root  401 Sep 28 20:39 init.conf
drwxr-xr-x. 3 root root   22 Sep 28 20:39 nginx
[root@liumiaocn scripts]# mv nginx/templates/ ..
[root@liumiaocn scripts]# rm -rf nginx/
[root@liumiaocn scripts]# cd ..
[root@liumiaocn rancher-cattle-autocatalog]# ll
total 16
-rw-r--r--. 1 root root 11357 Sep 28 20:39 LICENSE
-rw-r--r--. 1 root root    64 Sep 28 20:39 README.md
drwxr-xr-x. 3 root root    72 Sep 28 20:44 scripts
drwxr-xr-x. 3 root root    18 Sep 28 20:44 templates
[root@liumiaocn rancher-cattle-autocatalog]# git add *
[root@liumiaocn rancher-cattle-autocatalog]# git commit -m "add nginx rancher catalog"
[master e64daec] add nginx rancher catalog
5 files changed, 1701 insertions(+)
create mode 100644 templates/nginx/0/docker-compose.yml
create mode 100644 templates/nginx/0/rancher-compose.yml
create mode 100644 templates/nginx/README.md
create mode 100644 templates/nginx/catalogIcon-nginx.svg
create mode 100644 templates/nginx/config.yml
[root@liumiaocn rancher-cattle-autocatalog]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': liumiaocn
Password for 'https://liumiaocn@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/liumiaocn/rancher-cattle-autocatalog/'
[root@liumiaocn rancher-cattle-autocatalog]#


上篇文章的例子即为使用这种方法自动生成。熟悉格式之后不用任何工具也是一样。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息