创建私人 catalog


Rancher catalog服务要求以特定格式构建私有 catalog,以使 catalog服务能够正常的解析。

模板文件夹

Catalog templates are displayed in Rancher based on what container orchestration type that was selected for the environment.

基于编排类型的模板

  • Cattle orchestration: cntries in the UI are from the templates folder
  • Swarm orchestration: cntries in the UI are from the swarm-templates folder
  • Mesos orchestration: cntries in the UI are from the mesos-templates folder

基础设施服务模板

The infrastructure services that are available to be enabled in an environment template, are from the infra-templates folder of any catalog enabled in Rancher.

这些服务也可从“ catalog ”选项卡中获得,即使可能无法使用所选的编排类型,您也可以查看所有基础架构服务。建议在环境模板创建期间选择基础架构服务,而不是直接从 catalog中启动它们。

catalog结构

-- templates (Or any of templates folder)
  |-- cloudflare
  |   |-- 0
  |   |   |-- docker-compose.yml
  |   |   |-- rancher-compose.yml
  |   |-- 1
  |   |   |-- docker-compose.yml
  |   |   |-- rancher-compose.yml
  |   |--  catalogIcon-cloudflare.svg
  |   |-- config.yml
...

在主 catalog中,您将需要一个templates文件夹。该templates文件夹将包含您所创建的每个 catalog项的文件夹。我们建议每个 catalog条目都有一个简单的模板名称作为文件夹名称。

在 catalog条目文件夹(例如cloudflare)中,将为您的 catalog条目创建的每个版本都有文件夹。第一个版本应该是0,并且每个后续版本将是增量值。例如,版本2将在1文件夹中。通过提供新的版本文件夹编号,它提供了一种从先前版本的模板升级堆栈的方法。或者,您可以更新0文件夹中的模板,只需重新部署该条目。

注意:每个 catalog条目将需要一个单词,所以请使用-而不是空格用于更长的 catalog名称。您可以使用该name部分的空格config.yml

Rancher catalog文件在Rancher catalog中显示

在 catalog条目文件夹中,如何在Rancher catalog中显示 catalog条目的详细信息位于两个文件中。

  • 第一个文件config.yml包含您的条目的详细信息。
name: # Name of the  catalog cntry
description: |
  # Description of the  catalog cntry
version: # Version of the  catalog to be used
category: # Category to be used for searching  catalog cntries
maintainer: # The maintainer of the  catalog cntry
liccnse: # The liccnse
projectURL: # A URL related to the  catalog cntry
  • 第二个文件是 catalog条目的图标图像。该文件必须带有前缀catalogIcon-

对于每一个 catalog条目,将有至少三个项目:config.ymlcatalogIcon-cntry.svg,和0文件夹,其中包含 catalog条目的第一个版本。

牧场主 catalog模板

docker-compose.ymlrancher-compose.yml必需的文件,以便能够使用牧场主启动服务牧场主撰写。这些文件所在的文件夹中的版本号(即内01等)。

docker-compose.yml应该是还可以使用启动文件docker-compose up。服务遵循docker-compose格式。

rancher-compose.yml将包含更多的信息,以帮助您自定义 catalog条目。在该catalog部分中,为了使您的 catalog条目正确解释,将需要一些字段。

README.md可以创建一个可选项,它提供了有关如何使用 catalog服务的冗长描述或注释。

rancher-compose.yml

version: '2'
 catalog:
  name: # Name of the versioned template of the  catalog cntry
  version: # Version of the versioned template of the  catalog cntry
  description: # Description of the versioned template of the  catalog cntry
  minimum_rancher_version: # The minimum version of Rancher that supports the template, v1.0.1 and 1.0.1 are acceptable inputs
  maximum_rancher_version: # The maximum version of Rancher that supports the template, v1.0.1 and 1.0.1 are acceptable inputs
  upgrade_from: # The previous versions that this template can be upgraded from
  questions: #Used to request user input for configuration options

因为upgrade_from,可以使用三种类型的值。

  1. 仅允许从1版本升级: 1.0.0
  2. 如果能够比某个特定版本选择更高或更低:>=1.0.0.<=2.0.0
  3. 能够定义一系列版本>1.0.0 <2.0.0 || >3.0.0

问题在 rancher-compose.yml

questions部分catalog用于允许用户更改服务的配置选项。该answers会内的填充docker-compose.yml是推出服务之前。

每个配置选项是该questions部分的列表项rancher-compose.yml

version: '2'
 catalog:
  questions:
    - variable: # A single word that is used to pair the question and answer.
      label: # The "question" to be answered.
      description: | # The description of the question to show the user how to answer the question.
      default: # (Optional) A default value that will be pre-populated into the UI
      required: # (Optional) Whether or not an answer is required. By default, it's considered `false`.
      type: # How the questions are formatted and types of response expected
  • 类型

    type部分控制问题在UI中的格式以及预期的响应类型。

    符合条件的格式有:

    • string 用户界面中将显示一个文本框来捕获答案,答案将被格式化为一个字符串。
    • int用户界面中将显示一个文本框以捕获答案,答案将被格式化为一个数字。UI将在启动模板之前验证其是否为有效的数字。
    • boolean用户界面中将显示一个单选按钮来捕获答案,答案将被格式化为truefalse。如果选择单选按钮,答案将被格式化为true
    • password 用户界面中将显示一个文本框来捕获答案,答案将被格式化为一个字符串。
    • service 将显示环境中所有服务的下拉列表。
    • cnum用户界面中将显示一个下拉菜单,下拉菜单中将显示该options部分。
version: '2'
 catalog:
  questions:
    - variable:
      label:
      description: |
      type: cnum   
      options: # List of options if using type of `cnum`
        - Option 1
        - Option 2
  • multiline 多行文本框将显示在UI中。
version: '2'
 catalog:
  questions:
    - variable:
      label:
      description: |
      type: multiline
      default: |
        Each line
        would be shown
        on a separate
        line.
  • certificate 在环境中下载所有可用的证书。
version: '2'
 catalog:
  questions:
    - variable:
      label:
      description: |
      type: certificate

基于Yeoman的 catalog生成器

有一个基于Yeoman 的开源项目,可以用于创建空 catalog条目的模板。

results matching ""

    No results matching ""