From ec31c1fa175719d6b7ee6153654df38f8ed7b3ab Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Fri, 29 Oct 2021 20:06:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20useful=20debug=20helpers?= =?UTF-8?q?=20for=20Helm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- slides/k8s/helm-create-basic-chart.md | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/slides/k8s/helm-create-basic-chart.md b/slides/k8s/helm-create-basic-chart.md index 79d80a84..79a72147 100644 --- a/slides/k8s/helm-create-basic-chart.md +++ b/slides/k8s/helm-create-basic-chart.md @@ -190,6 +190,47 @@ have details about recommended annotations and labels. ] +--- + +## Tips when writing charts + +- It is not necessary to `helm install`/`upgrade` to test a chart + +- If we just want to look at the generated YAML, use `helm template`: + ```bash + helm template ./my-chart + helm template release-name ./my-chart + ``` + +- Of course, we can use `--set` and `--values` too + +- Note that this won't fully validate the YAML! + + (e.g. if there is `apiVersion: klingon` it won't complain) + +- This can be used when trying things out + +--- + +## Exploring the templating system + +Try to put something like this in a file in the `templates` directory: + +```yaml +hello: {{ .Values.service.port }} +comment: {{/* something completely.invalid !!! */}} +type: {{ .Values.service | typeOf | printf }} +### print complex value +{{ .Values.service | toYaml }} +### indent it +indented: +{{ .Values.service | toYaml | indent 2 }} +``` + +Then run `helm template`. + +The result is not a valid YAML manifest, but this is a great debugging tool! + ??? :EN:- Writing a basic Helm chart for the whole app