helm NOTES.txt file

1. NOTES.txt file

When we used the helm installcommand before, Helm will print out a lot of introduction information for us, so that when other users use our chart package, they can quickly understand how to use our chart package according to these annotation information. The information is written in the NOTES.txtfile , which is plain text, but has all the normal template functions and objects available, like any other template.

Now we create a NOTES.txt file under the templates directory in the previous example:

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 }}

We can see that NOTES.txtwe also use Chartand Releaseobjects in the file, and now we mychartexecute the installation command under the package root directory to see if we can get the above comment information:

$ helm install .
Error: release nomadic-deer failed: ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap: Data: ReadString: expects " or n, but found [, error found in #10 byte of ...|rselist":[{
    
    "0":"K8s"|..., bigger context ...|:{
    
    "app":"mychart","chart":"mychart","courselist":[{
    
    "0":"K8s"},{
    
    "1":"Python"},{
    
    "2":"Search"},{
    
    "3":"Go|...

We can see that the above error message appears, but if we execute the debug command to debug, there is no problem, and it can be rendered normally, but why did the problem occur during the official installation? This is because we only check whether the template can be rendered normally in the debug debugging stage, and do not check the format requirements of the corresponding kubernetes resource object for the yaml file, so we say that the debug test is passed, it does not mean that the chart is really available. For example, here is a ConfigMap resource object. ConfigMap has strict requirements on the content of the data area. For example, we have the following content here:

web: true
courselist:
- 0: "K8s"
- 1: "Python"
- 2: "Search"
- 3: "Golang"

This is indeed a legal yaml file format, but it is ConfigMapnot legal. It needs to truebe turned into a string, and the following dictionary array becomes a multi-line string, so it is ConfigMapa : ( templates/config.yaml)

apiVersion: v1
kind: ConfigMap
metadata:
  name: {
    
    {
    
     .Release.Name }}-configmap
  labels:
{
    
    {
    
    - include "mychart.labels" . | indent 4}}
data:
  app: mychart
  myvalue: {
    
    {
    
     .Values.hello | default  "Hello World" | quote }}
  {
    
    {
    
    - $releaseName := .Release.Name }}
  {
    
    {
    
    - with .Values.course }}
  k8s: {
    
    {
    
     .k8s | upper | quote }}
  python: {
    
    {
    
     .python | repeat 5 | quote }}
  release: {
    
    {
    
     $releaseName }}
  {
    
    {
    
    - if eq .python "django" }}
  web: "true"
  {
    
    {
    
    - end }}
  {
    
    {
    
    - end }}
  courselist: |
    {
    
    {
    
    - range $index, $course := .Values.courselist }}
    {
    
    {
    
     $course | title | quote }}
    {
    
    {
    
    - end }}
  {
    
    {
    
    - range $key, $val := .Values.course }}
  {
    
    {
    
     $key }}: {
    
    {
    
     $val | upper | quote }}
  {
    
    {
    
    - end }}
{
    
    {
    
    - include "mychart.labels" . | indent 2 }}

Now let's execute the installation command again:

$ helm install .
NAME:   nosy-pig
LAST DEPLOYED: Sat Sep 29 19:26:16 2018
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                DATA  AGE
nosy-pig-configmap  11    0s


NOTES:
Thank you for installing mychart.

Your release is named nosy-pig.

To learn more about the release, try:

  $ helm status nosy-pig
  $ helm get nosy-pig

Now that the installation is successful, and the comment section below is rendered, we can NOTES.txtsee that the template objects used in it are rendered correctly.

It is very necessary to provide a clear NOTES.txtdocumentation , which can provide users with chartdetailed information on how to use the new installation, which is a very friendly way.

Guess you like

Origin blog.csdn.net/xixihahalelehehe/article/details/123520111