使用 Kustomize 将变量保留在字符串中

问题描述 投票:0回答:1

我遇到了一个棘手的问题。使用 kibana,我有一个 UI 元素,在路径的所述字段中是文字值:

/var/log/containers/*${kubernetes.container.id}.log

这是我想要粘贴到字段中的最终结果。 IE伪代码:

endresult='/var/log/containers/*${kubernetes.container.id}.log'

echo $endresult

现在,当在我的 kibana yaml 中为“eck-operator-kibana”定义此内容时,我提取了一个从 UI 生成的示例 yaml,它显示它就像

paths:
  - '/var/log/containers/*${kubernetes.container.id}.log'

但是,当将其添加到我的 kibana.yaml 时,会出错并显示“YAMLToJSON:变量替换失败”

我试图确保它不会以这些方式将其读取为变量,但都失败了:

paths:
  - "'/var/log/containers/*${kubernetes.container.id}.log'" #double quotes around single
paths:
  - "/var/log/containers/*${kubernetes.container.id}.log" #double quotes
paths:
  - '/var/log/containers/*\\${kubernetes.container.id}.log' # using \\ to not pay attention to the $
paths:
  - '/var/log/containers/*"${kubernetes.container.id}".log' #double quotes around the variable
#at this point im losing my mind and questioning my sanity

那么,我该如何制作才能使字段中填充的最终结果很简单 /var/log/containers/*${kubernetes.container.id}.log

将 Flux 与 kustomizations 一起使用,并且在 k9s 中的 kustomizations 下,它会因该错误而失败。是什么赋予了?任何见解表示赞赏!

kubernetes variables flux kustomize gitops
1个回答
0
投票

只是对此的更新,有人在不同的论坛中提到要使用

paths:
  - >
  '/var/log/containers/*${kubernetes.container.id}.log'

当这不起作用时,它确认有一个外部“力”作用在它上面,这是一个试图填充变量的 shell lint。有效的是两个 $ 符号:

paths:
  - '/var/log/containers/*$${kubernetes.container.id}.log'
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.