舵图中的变量值作为Yaml键 [英] Variable value as yaml key in helm chart

查看:58
本文介绍了舵图中的变量值作为Yaml键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过在helm命令行中设置一个变量来从values.yaml中选择配置部分.

I want to choose config section from values.yaml by setting a variable in helm command line.

values.yaml的示例部分:

example part of values.yaml:

aaa:
  x1: "az1"
  x2: "az2"
bbb:
  x1: "bz1" 
  x2: "bz2"

configmap.yaml的示例部分

example part of configmap.yaml

data: 
  {{ .Values.outsideVal.x1 }}

预期结果应如下所示

   data:
     az1

测试头盔输出

helm template --set outsideVal=aaa mychart

并收到此错误

Error: render error in "./templates/configmap.yaml": template: ./templates/configmap.yaml:21:12: executing "./templates/configmap.yaml" at <.Values.outsideVal.x...>: can't evaluate field x1 in type interface {}

所以问题是如何获得预期的结果?

So the question is how get the result as expected?

推荐答案

我怀疑您正在寻找文本/template index函数,该函数可以通过变量键在映射中查找值.

I suspect you're looking for the text/template index function, which can look up a value in a map by a variable key.

{{ (index .Values .Values.outsideVal).x1 }}

这篇关于舵图中的变量值作为Yaml键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆