Rancher()是一个容器管理平台,可以添加、删除容器,查看容器运行状态,也可以批量启动和停止docker compose组成的多个docker组合而成的应用服务,可以支持多台服务节点,支持云服务器,支持多种授权管理方式。Rancher具有Web GUI,操作很方便,入门比较快。
1、快速安装
Rancher本身也是容器服务,快速安装参考:
Rancher可以直接启动Docker的镜像,也可以从“应用商店”里快速启动一个应用服务。
2、应用商店
Rancher“应用商店”实质是docker compose支持的docker image集合,包括官方的应用服务和社区库,都采用git库的方式存储在github中()。我们也可以按照类似的格式创建github库,然后将其添加到Rancher的“应用商店”目录列表中。
3、自建应用商店
在github.com中创建一个新项目,如rancher-catalog。
- 然后添加templates目录,自己的应用放到这个目录下面。
- 以kafka为例,在templates下创建kafka目录。
- 在kafka目录下创建config.yml,内容为:
name: Apache Kafkadescription: | Kafka clusterversion: 1.0.0-rancher1category: Clusteringmaintainer: "Raul Sanchez"minimum_rancher_version: v0.59.0license: projectURL: https://github.com/rawmind0/alpine-kafka
- 创建一个图标:
- 再创建一个版本目录,命名为0,进入目录。
- 创建文件 rancher-compose.yml,内容为:
.catalog: name: Kafka version: 0.9.0-rancher1 description: | (Experimental) Apache Kafka cluster. minimum_rancher_version: v0.56.0 maintainer: "Raul Sanchez" uuid: kafka-0 questions: - variable: "kafka_scale" description: "Number of brokers nodes. Note: Recommended an odd number" label: "Broker Nodes:" required: true default: 3 type: "int" - variable: "kafka_mem" description: "Amount of memory to config brokers." label: "Broker Memory (mb):" required: true default: 1024 type: "string" - variable: "kafka_interval" description: "Interval to poll/apply configuration changes. 0 to disable" label: "Broker Interval (s):" required: true default: 60 type: "int" - variable: "zk_link" description: | Choose the Zookeeper service to use. It's really recommended a dedicated zookeeper service just for Kafka. label: "Zookeeper stack/service" default: "kafka-zk/zk" required: true type: "service"broker: scale: ${kafka_scale} health_check: port: 9092 interval: 5000 unhealthy_threshold: 3 request_line: '' healthy_threshold: 2 response_timeout: 5000
- 创建文件 docker-compose.yml,内容为:
broker: tty: true image: rawmind/rancher-kafka:0.9.0 volumes: - /opt/kafka/data environment: - JVMFLAGS=-Xmx${kafka_mem}m -Xms${kafka_mem}m - CONFD_INTERVAL=${kafka_interval} - ZK_SERVICE=${zk_link} external_links: - ${zk_link}:zk
按照上面的流程,可以在一个gihub项目中创建多个应用服务。
- 我完成后的Rancher“应用商店”模版:
现在,进入Rancher,在“添加应用商店”,将github库添加到Rancher的“应用商店”目录列表中。
如果没有显示出来,尝试到“系统管理->系统设置”中添加,然后到“应用商店”中点击刷新按钮。
4、高级参考
应用商店的详细格式:
自动创建应用商店参考: