【问题标题】:How to replace helm values.yaml by using the kustomize configMapGenerator generated name?如何使用 kustomize configMapGenerator 生成的名称替换 helm values.yaml?
【发布时间】:2021-06-12 09:28:08
【问题描述】:

我使用kustomize生成各种configMap,如下例:-

# kustomization.yaml

configMapGenerator:
- name: my-config-path # <-- My original name.
  files:
  - file1.txt
  - file2.txt
  - ...
  - fileN.txt

输出如下示例:-

# my-configmap.yaml

apiVersion: v1
data:
  file1.txt: |
  ...
  file2.txt: |
  ...
  fileN.txt |
  ...
kind: ConfigMap
metadata:
  name: my-config-path-mk89db6928 # <-- There is a hashed value appended at the end.

另一方面,我有一个第三方helm,它需要覆盖values.yaml,如下所示:-

# third-party-chart-values.yaml

customArguments:
  - --config.dir=/config
...

volumes:
  - mountPath: /config
    name: my-config-path # <--- Here, I would like to replace with `my-config-path-mk89db6928`.
    type: configMap

我们有什么方法可以将third-party-chart-values.yaml 处的my-config-path 替换为从名为my-configmap.yaml 的文件中生成的值my-config-path-mk89db6928? (注意,如果 configMap 更改了哈希值,例如 mk89db6928 也将更改。)

【问题讨论】:

    标签: kubernetes-helm kustomize


    【解决方案1】:

    你想保留哈希吗?因为您可以通过以下方式阻止它:

    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    generatorOptions:
      disableNameSuffixHash: true
    

    那么你就有了一个可预测的名字。尽管如果您在同一个命名空间中多次安装同一个 helm chart 会导致冲突。

    【讨论】:

      猜你喜欢
      • 2022-08-23
      • 2021-12-06
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 2020-04-15
      • 2020-03-31
      • 2021-12-18
      • 2021-06-17
      相关资源
      最近更新 更多