Ale*_*lex 1 terraform kubernetes-helm
我见过这个问题和另一个类似的问题,但无法让它工作使用 Terraform 的 helm_release,如何设置数组或列表值?
\n我的列表来自 json 文件,它是允许的组列表
\nlocals {\n app_groups = jsondecode(file("../../work/resources/gke/params/access_auths.json")).accessgroups[var.project][0].app_group\n}\noutput "app_groups" {\n value = local.app_groups\n}\n
Run Code Online (Sandbox Code Playgroud)\n给出 -
\napp_groups = [\n "bigquery-team",\n "devops-team",\n]\n
Run Code Online (Sandbox Code Playgroud)\n主.tf-
\nresource "helm_release" "oauth2proxy" {\n name = "oauth2proxy"\n chart = "../charts/oauth2proxy"\n namespace = kubernetes_namespace.oauth2proxy.metadata.0.name\n set {\n name = "app_groups[0]"\n value = "${local.app_groups}"\n }\n values = [\n templatefile("../charts/oauth2proxy/oauth2proxy_values.yaml", {\n projectID = var.project\n clusterName = var.clusterName\n })\n ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n在 helm deployment.yml 中,启动容器时需要进入 -args -
\n {{ range $v := .app_groups }}\n - --allowed-group="{{ $v }}"\n {{ end }}\n
Run Code Online (Sandbox Code Playgroud)\n但我明白了
\nError: Incorrect attribute value type\n on main.tf line 129, in resource "helm_release" "oauth2proxy":\n 129: value = "${local.app_groups}"\n \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n \xe2\x94\x82 local.app_groups is tuple with 2 elements\n \xe2\x94\x82 Inappropriate value for attribute "value": string required.\n
Run Code Online (Sandbox Code Playgroud)\n问题是,它是一个元组,并且希望它成为一个元组,但我不知道如何告诉 terraform 或 helm 它应该是一个元组。
\n我尝试过各种不同的“设置”和“动态设置”,但没有取得任何进展。
\nvalue
需要一个字符串。在 Helm 中,您可以使用语法提供数组{a, b, c}
。要构建此语法,您可以使用join()
:
set {
name = "app_groups"
value = "{${join(",", local.app_groups)}}"
}
Run Code Online (Sandbox Code Playgroud)
这应该可以解决问题并app_groups
以{bigquery-team, devops-team}
. 我不确定是否需要引用,但这可以很容易地添加。
归档时间: |
|
查看次数: |
1121 次 |
最近记录: |