Helm Template Function Default: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * https://helm.sh/docs/chart_template_guide/#using-the-default-function =Internal= * Helm Templates =Overview= {{ default <''de...")
 
 
(3 intermediate revisions by the same user not shown)
Line 10: Line 10:
  &#123;{ default <''default-value''> <''actual-value''> }}
  &#123;{ default <''default-value''> <''actual-value''> }}


&#123;{ default "blue" .Values.color }}


&#123;{ default "blue" .Values.color }}
<syntaxhighlight lang='yaml'>
metadata:
  name: {{ .Values.myApp.clusterRole | default "my-app:cluster-role" | quote }}
</syntaxhighlight>
 
In an actual chart, all static default values should live in the [[Helm_Chart_values.yaml|values.yaml]], and should not be repeated using the default command - if that happens, we will have redundantly specified values. However, the <tt>default</tt> is useful for computed values, which cannot be declared inside [[Helm_Chart_values.yaml|values.yaml]].

Latest revision as of 07:45, 25 June 2020

External

Internal

Overview

{{ default <default-value> <actual-value> }}
{{ default "blue" .Values.color }}
metadata:
  name: {{ .Values.myApp.clusterRole | default "my-app:cluster-role" | quote }}

In an actual chart, all static default values should live in the values.yaml, and should not be repeated using the default command - if that happens, we will have redundantly specified values. However, the default is useful for computed values, which cannot be declared inside values.yaml.