如何使用Postgress Helm 3.0设置多个参数

时间:2020-03-25 03:09:31

标签: kubernetes kubernetes-helm helmfile

我要设置slave.extraVolumes如下。

helm install my-db --set replication.enabled=true,slave.extraVolumes={"db-disk-1","db-disk-2"} bitnami/postgresql -n development

但是它说一个错误

Error: expected at most two arguments, unexpected arguments: bitnami/postgresql

已经测试过的方法:

helm install my-db --set replication.enabled=true,slave.extraVolumes={db-disk-1,db-disk-2} bitnami/postgresql -n development
Error: expected at most two arguments, unexpected arguments: bitnami/postgresql

helm install my-db --set replication.enabled=true,slave.extraVolumes="db-disk-1\,db-disk-2" bitnami/postgresql -n development
Error: YAML parse error on postgresql/templates/statefulset-slaves.yaml: error converting YAML to JSON: yaml: line 115: could not find expected ':'

2 个答案:

答案 0 :(得分:2)

(至少)发生了三件事:

helm install my-db \
   --set replication.enabled=true \
   --values <(echo '{
      "slave": {
        "extraVolumes": [
          {
            "name": "db-disk-1",
            "emptyDir": {}
          },
          {
            "name": "db-disk-2",
            "emptyDir": {}
          }
        ]
      }
   }') \
   bitnami/postgresql -n development

答案 1 :(得分:0)

对于其他来自Google并显示错误消息并希望解决该问题的人,而不是在公认的答案中使用晦涩的postgresql特定答案,问题几乎可以肯定是mdaniel的要点2(“您正在使用字符至少对于现代bash而言,对外壳有意义而无需引用它们”。

此答案说明了发生的情况-Stop shell wildcard character expansion?-以及如何解决此问题。在这里,您只需要转义大括号,就像这样:

helm install my-db --set replication.enabled=true,slave.extraVolumes='{"db-disk-1","db-disk-2"}' bitnami/postgresql -n development

helm install my-db --set replication.enabled=true,slave.extraVolumes=\{"db-disk-1","db-disk-2"\} bitnami/postgresql -n development

这就是您所需要的。 helm帮助对此非常恼人。