在 Helm 图表中使用包含文件的本地版本

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

我创建了一个 Helm 图表,并从我的组织的私有 Helm 存储库托管它。我希望该图表可供我组织中的几个不同小组使用。该图表创建一个如下所示的 ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Chart.Name }}
data:
  config.yaml: |-
{{ .Files.Get "config.yaml" | indent 4}}

图表如下:

mychart/
  Chart.yaml
  values.yaml
  config.yaml  ** The ConfigMap content **
  templates/

也就是说,ConfigMap是一个YAML文件,其内容正是

content.yaml
的内容。

文件

content.yaml
由图表提供,包含几十行。此图表的用户需要能够用他们的自己的版本的
config.yaml
替换图表附带的版本。

这可能吗?如果是的话,怎么办?

kubernetes-helm configmap
1个回答
0
投票

我不相信你可以通过将其保存为 yaml 文件来解决这个问题。我们做了与您的用例类似的事情,并通过将 ConfigMap 存储在单独的 helm 图表中来解决它。然后,将该图表添加为 Chart.yaml 的依赖项,但不要在定义中使用 URL:

dependencies:
  - name: my-config-map
    repository: "@artifactory"

现在,您可以按团队更改拉取 ConfigMap 图表的位置。 IE。每个团队都会以不同的方式定义存储库位置以提取不同的图表:

helm repo add artifactory-dev https://artifactory.mycompany.com/artifactory/helm-dev-local

-vs-

helm repo add artifactory-dev https://artifactory.mycompany.com/artifactory/helm-qa-local
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.