在本节中,我们将看到可以向你的 chart 用户提供说明的Helm工具。在 helm install
或 helm upgrade
命令的最后,Helm会打印出对用户有用的信息。这些信息是可以使用模板高度定制的。同时我们也会介绍 .helmignore
文件,该文件用来指定你不想包含在你的helm chart中的文件。
1、NOTES.txt 文件
要将安装说明添加到 chart,只需创建一个 templates/NOTES.txt 文件即可。这个文件是纯文本的,但是它像一个模板一样处理,并且具有所有可用的普通模板函数和对象。
我们来创建一个简单的 NOTES.txt
文件:
Thank you for installing {{ .Chart.Name }}.
Your release is named {{ .Release.Name }}.
To learn more about the release, try:
$ helm status {{ .Release.Name }}
$ helm get {{ .Release.Name }}
现在,如果我们运行 helm install ./mychart
我们会在底部看到这条消息:
RESOURCES:
==> v1/Secret
NAME TYPE DATA AGE
rude-cardinal-secret Opaque 1 0s
==> v1/ConfigMap
NAME DATA AGE
rude-cardinal-configmap 3 0s
NOTES:
Thank you for installing mychart.
Your release is named rude-cardinal.
To learn more about the release, try:
$ helm status rude-cardinal
$ helm get rude-cardinal
使用
NOTES.txt
这种方式是一种很好的方式,可以为用户提供有关如何使用新安装chart的详细信息。强烈建议创建一个NOTES.txt
文件,尽管这不是必需的。
2、.helmignore
文件
.helmignore
文件用来指定你不想包含在你的 helm chart
中的文件。如果该文件存在,helm package
命令会在打包应用时忽略所有在 .helmignore
文件中匹配的文件(包括文件和文件夹)。
-
这有助于避免在 helmchart 中添加不需要或敏感的文件或目录。
-
.helmignore
文件支持 Unix shell 的全局匹配,相对路径匹配,以及反向/否定匹配(以!作为前缀)。每行只考虑一种模式。
以下是一个示例 .helmignore 文件:
# comment
# Match any file or path named .git
.git
# Match any text file
*.txt
# Match only directories named mydir
mydir/
# Match only text files in the top-level directory
/*.txt
# Match only the file foo.txt in the top-level directory
/foo.txt
# Match any file named ab.txt, ac.txt, or ad.txt
a[b-d].txt
# Match any file under subdir matching temp*
*/temp*
*/*/temp*
temp?
一些值得注意的和
.gitignore
不同之处:
不支持'**'语法
。globbing库是Go的 'filepath.Match',不是fnmatch(3)
末尾空格总会被忽略(不支持转义序列)
不支持'!'作为特殊的引导序列
评论区