You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Step-05: Add one Builtin Object Chart.Name to labels
{{/* Common Labels */}}
{{- define "helmbasics.labels"}}
app: nginx
chartname: {{ .Chart.Name }}
{{- end }}
Step-06: Test the output with template action
# Change to Chart Directory
cd helmbasics
# Helm Template Command
helm template myap101 .
# Helm Install with dry-run command
helm install myapp101 . --dry-run
Observation:
1. Chart name filed should be empty
2. Chart Name was not in the scope forourdefined template.
3. When a named template (created with define) is rendered, it will receive the scope passed in by the template call.
4. No scope was passed in, so within the template we cannot access anything in "."
5. This is easy to fix. We simply pass a scope to the template
Step-07: Pass scope to the template call
Add dot "." (Root Object or period) at the end of template call to pass scope to template call
Step-10: Test the output when template action + pipe + upper function
# Change to Chart Directory
cd helmbasics
# Helm Template Command
helm template myap101 .
# Helm Install with dry-run command
helm install myapp101 . --dry-run
Observation:
1. Should fail with error. What is the reason for failure ?
2. Template is an action, andnot a function, there is no way to pass the output of a template call to other functions;
Step-11: Replace Template action with Special Purpose include function
# Change to Chart Directory
cd helmbasics
# Helm Template Command
helm template myap101 .
# Helm Install with dry-run command
helm install myapp101 . --dry-run
Observation:
1. Call include "helmbasics.labels" -- should be successful
2. Should show all labels in upper case
Step-11: Underscoe file (_helpers.tpl)
Move the named template helmbasics.labels to _helpers.tpl file
But files whose name begins with an underscore (_) are assumed to not have a kubernetes manifest inside.
These files are not rendered to Kubernetes object definitions, but are available everywhere within other chart templates for use.
These files are used to store partials and helpers.
{{/* Common Labels */}}
{{- define "helmbasics.labels"}}
app: nginx
chartname: {{ .Chart.Name }}
{{- end }}
Step-12: Test the output after moving named template to _helpers.tpl
# Change to Chart Directory
cd helmbasics
# Helm Template Command
helm template myap101 .
# Helm Install with dry-run command
helm install myapp101 . --dry-run
Observation:
1. call include "helmbasics.labels" -- should be successful
2. Should show all labels in upper case