配置

配置种子、配置的保存位置、git 和 ytt

  1. 示例
  2. config.yaml 的读取位置
  3. 变量

修改这些变量,以决定配置的来源:配置种子、数据库、git 或 ytt 模板。


示例

应用一个挂载的配置种子,每五分钟检查一次,并将 config.yaml 保存在数据库中。在 docker-compose.yml 中:

    environment:
      - CONFIG_SEED_PATH=/seed/seed.yaml
      - CONFIG_SEED_RELOAD_SECONDS=300
      - ENABLE_CONFIG_IN_DATABASE=1
      - ALLOW_ENV_EDIT=0              # the environment is declared here, not on the settings pages
    volumes:
      - ./seed:/seed:ro

无效的种子会导致服务器无法启动。文件格式参见 配置种子。


config.yaml 的读取位置

类别、角色和常量来自磁盘上的 config.yaml 或其在数据库中的副本,按以下顺序决定:

  1. ENABLE_CONFIG_IN_DATABASE,当它在环境中或在设置页面的 配置 选项卡中设置时:1 读取数据库,0 读取文件。
  2. 否则,使用数据库中保存的配置来源(file 或 database),即 6.3.0 之前搭建的实例 在设置页面上所作的选择。
  3. 否则,使用文件:启用了 用于配置 的仓库中的 config.yaml;没有时使用启用了 用于表单 的仓库中的;再没有时使用 CONFIG_PATH 处的文件。

显式设置的 ENABLE_CONFIG_IN_DATABASE 始终优先,即使是 0 也优先于保存的 database。每次加载 配置时都会读取它,因此更改无需重启即可生效。状态 页面的 信息 选项卡显示正在使用的来源。


变量

本组的所有变量,包括其类型、默认值和描述:

变量 可选值/默认值 说明
CONFIG_SEED_PATH
string
added in version 6.3.0
默认值:

Config seed file
a valid file path

Path to a declarative config seed. When set, the yaml file it points to is applied at startup and the admin objects it declares become read-only in the interface, so a whole instance can be rebuilt from git on an empty database. Secrets are referenced as ${ENV_VAR} and resolved from the environment, so the file itself holds none. Unrelated to CONFIG_PATH, which holds the forms configuration. An invalid seed makes the server refuse to start, and so does a path whose file is missing (a mounted file may only be late). Leaving it empty turns the seed off: the next start releases every object an earlier seed made read-only, keeping its values, so it can be changed in the interface again. See the Config seed page in the documentation.

CONFIG_SEED_RELOAD_SECONDS
integer
added in version 6.3.0
默认值:
60

Config seed reload interval (seconds)
0 or a number of seconds

How often the config seed file is checked and re-applied when its content has changed, in seconds. This is what lets a seed edited in git take effect without restarting: on kubernetes a ConfigMap is remounted under the running pod within about a minute and the change is picked up from there. A reload that fails is never fatal, unlike the one at startup: the configuration already in force is kept and the Status page reports it. Set it to 0 to check only at startup, leaving POST /api/v2/config-seed/apply and SIGHUP. Takes effect at once, without a restart. Ignored when CONFIG_SEED_PATH is empty.

ALLOW_ENV_EDIT
boolean
added in version 6.3.0
默认值:
1

Allow editing these settings
0, 1

Whether the settings pages may write persistent/.env. Set it to 0 in a declarative deployment (kubernetes, docker-compose, ArgoCD): there the file is either ephemeral, so a save is silently lost at the next restart, or durable, so it drifts away from the manifest that is meant to be authoritative. With 0 every variable is shown with its value in force but cannot be changed, and the save endpoint refuses.

ENABLE_CONFIG_IN_DATABASE
number
added in version 6.1.0
可选值:
  • 0 (默认)
  • 1

Store the configuration in the database
0, 1

If you use git repositories to store the forms, you can choose to store the master config.yaml in git as well.
Or, you can choose to have the config.yaml in the database instead. Having a clean separation: master config.yaml in database, and the actual forms in git.

This gives the config.yaml in the database the highest priority in the loading order.

GIT_CLONE_COMMAND
string
added in version 6.0.2
默认值:
git clone

Git clone command
a valid git clone command

The command used to clone git repositories. Note that branch and repository will be auto added.

GIT_PULL_COMMAND
string
默认值:
git pull

Git pull command
a valid git pull command

The command used to pull git repositories. Note that branch and repository will be auto added.

GIT_PUSH_COMMAND
string
默认值:
git push

Git push command
a valid git push command

The command used to push git repositories (used by the designer’s sync to git feature). Note that -u origin HEAD will be auto added.

USE_YTT
number
added in version 5.0.2
可选值:
  • 0 (默认)
  • 1

Enable the ytt interpreter
0, 1

https://github.com/carvel-dev/ytt is a tool for yaml templating. It can be activated by this variable.

YTT_ALLOW_SYMLINK_DESTINATIONS
string
added in version 5.0.8
默认值:

ytt allowed symlink destinations
valid paths

Ytt disables templating with symlinks by default. If you want to allow symlink use on specific directories, this variable can be set to the path(s) where the symlinks are allowed (multiple paths separated by Node’s path.delimiter). Note: enabling this may come with some risks, see ytt FAQ for more info.

YTT_DANGEROUS_ALLOW_ALL_SYMLINK_DESTINATIONS
number
added in version 5.0.8
可选值:
  • 0 (默认)
  • 1

ytt dangerous allow-all symlink destinations
0, 1

Ytt disables templating with symlinks by default. If you want to allow all symlink use EVERYWHERE, you can set this variable to 1. Note: enabling this comes with some risks (hence the ‘DANGEROUS’ part), see ytt FAQ for more info.

YTT_VARS_PREFIX
string
added in version 5.0.8
默认值:

ytt vars prefix
a valid prefix

Environment variable prefix for ytt to get data values from. For example, when set to MY_PREFIX, MY_PREFIX_my_var=value results to the ytt data value my_var=value.

YTT_LIB_DATA_{dynamic}
string
added in version 5.0.8
默认值:

ytt lib data
a valid lib data value

This is not a single variable but rather an infinite amount of variables. You can set as many as you want. The dynamic part is the name of the lib data. For example YTT_LIB_DATA_MYLIB=values.yml results in the contents of values.yml to be used by ytt in the mylib library.