将conf文件嵌入舵图

将conf文件嵌入舵图

本文介绍了将conf文件嵌入舵图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手.我用大量的conf文件构建了一个混乱的头盔图表.我目前在configmap中使用类似的东西.

Im new at helm. Im building a splunk helm chart with numerous conf files. I currently use something like this in a configmap ..

    apiVersion: v1
kind: ConfigMap
metadata:
  name: splunk-master-configmap
data:
  indexes.conf: |
    # global settings
    # Inheritable by all indexes: no hot/warm bucket can exceed 1 TB.
    # Individual indexes can override this setting.
    homePath.maxDataSizeMB = 1000000

但我希望将conf文件放在单独的文件夹中,例如configs/helloworld.conf并出现在"tpl"中,但是正在努力了解如何实现它. -任何人都可以建议最佳做法.附带说明一下,splunk的存在顺序为>>,因此在不同位置可能使用了许多index.conf文件.有没有人对如何最好地实现这一点有任何想法?!??!

but I would prefer to have the conf files in a seperate folder e.g. configs/helloworld.conf and have come accross "tpl" but am struggling to understand how to implement it. - can anyone advise best practices. On a side note splunk has orders of presidences >> so there may be many indexes.conf files used in various locations. does anyone have any thoughts on how best to implement this?!??!

干杯.

推荐答案

如果文件的内容是静态的,则可以在图表中创建与模板目录相同级别的文件目录(不在其中),并像这样引用它们:

If the content of the files is static then you could create a files directory in your chart at the same level as the templates directory (not inside it) and reference them like:

kind: ConfigMap
metadata:
  name: splunk-master-configmap
data:
  {{ (.Files.Glob "files/indexes.conf").AsConfig | indent 2 }}
  {{ (.Files.Glob "files/otherfile.conf").AsConfig | indent 2 }}
# ... and so on

如果您希望能够引用文件内变量的值,以便从values.yaml中控制内容,则可以在其中进行分解.如果要单独显示每个值,则在其中有一个示例使用范围的头盔文档.但我认为很适合您的情况是什么稳定的/mysql图表可以.它具有一个将值作为字符串的ConfigMap:

Where this would break down is if you want to be able to reference the values of variables inside the files so that the content is controlled from the values.yaml. If you want to expose each value individually then there's an example in the helm documentation using range. But I think a good fit or your case is what the stable/mysql chart does. It has a ConfigMap that takes values as strings:

{{- if .Values.configurationFiles }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "mysql.fullname" . }}-configuration
data:
{{- range $key, $val := .Values.configurationFiles }}
  {{ $key }}: |-
{{ $val | indent 4}}
{{- end }}
{{- end -}}

values.yaml允许图表用户设置和覆盖文件及其内容:

And the values.yaml allows both the files and their content to be set and overridden by the user of the chart:

# Custom mysql configuration files used to override default mysql settings
configurationFiles:
#  mysql.cnf: |-
#    [mysqld]
#    skip-name-resolve
#    ssl-ca=/ssl/ca.pem
#    ssl-cert=/ssl/server-cert.pem
#    ssl-key=/ssl/server-key.pem

它将内容注释掉,并留给图表用户设置,但您可以在values.yaml中设置默认值.

It comments out that content and leaves it to the user of the chart to set but you could have defaults in the values.yaml.

仅在需要进一步灵活性时才需要tpl. 稳定/密钥斗图让图表的用户创建自己的配置图并通过tpl将其指向密钥斗部署.但我认为您的情况可能与mysql最接近.

You would only need tpl if you needed further flexibility. The stable/keycloak chart lets the user of the chart create their own configmap and point it into the keycloak deployment via tpl. But I think your case is probably closest to the mysql one.

tpl函数还可用于获取文件中加载的文件的内容.获取并有效地使该内容成为模板的一部分-请参见对这个感兴趣

the tpl function can also be used to take the content of files loaded with Files.Get and effectively make that content part of the template - see How do I load multiple templated config files into a helm chart? if you're interested in this

这篇关于将conf文件嵌入舵图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 05:22