prefapp / formacion

4 stars 4 forks source link

Create basic and advanced recipes section on helm course #106

Open frmadem opened 2 years ago

frmadem commented 2 years ago

A basic and advance section of Helm recipes could be really useful for our developers.

Every recipe should have a common structure such as:


# Title
## Description (What you want to do or accomplish)
## Helm code
## Caveats

An example:


# Named templates

## Description

We want to have a callable unit of template that we can use wherever we want. 

A [named template](https://helm.sh/docs/chart_template_guide/named_templates/) is a way to define code that we can call on and pass parameters to. 

## Helm code

{{ define "foo" }}
test:
  a: 1
  b: 2
{{ end }}

Then we can call it in our code

artifact: {{ include "foo" . | nindent 2}}

Having the output

artifact:
  test:
    a: 1
    b: 2

## Caveats

1. Beware of newlines!
2. We need always to pass at least one argument ( normally the context "." )
3. In order to pass complex args we should prefer a render cachet. 
frmadem commented 2 years ago

As a list of basic recipes:

  1. Named templates ( improve the basic example)
  2. Loops
  3. Render methods