我有一个rancher-compose.yml文件,在其中使用如下环境变量设置upgrade_strategy.start_first字段:

  upgrade_strategy:
    start_first: ${START_FIRST}
    batch_size: 1


使用rancher-compose CLI运行时,出现以下错误:

ERRO[0000] Failed to open project origami-svcproxy: yaml: unmarshal errors:
  line 28: cannot unmarshal !!str `false` into bool


在调试中运行时,我看到以下yaml:

  upgrade_strategy:
    batch_size: 1
    start_first: "false"  # <-- notice the surrounding quotes, missing from the rest of the variable replacements


如何动态设置此字段?

最佳答案

我遇到了同样的问题,并使用了不同的策略来解决该问题。第一步是将docker-compose.yml转换为模板docker-compose.yml.tpl。其次,使用模板逻辑来获取布尔变量的值。

  upgrade_strategy:
    start_first: {{ .Values.START_FIRST }}
    batch_size: 1


参考:https://github.com/rancher/rancher-catalog/blob/v1.6-development/infra-templates/ipsec/9/docker-compose.yml.tpl#L21

关于yaml - 使用环境变量设置 bool 字段时出现Rancher错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37907268/

10-12 07:40