If I have a basic kubernetes helm template like below:
port: {{ .Values.Port }}
Is there a way to specify a default port if none is passed in?
In values.yaml
you put Port: <port-number>
which will be used if you don't pass the value using --set
.
You can also set default like following
port: {{ default 1234 .Values.Port }}
# You can replace 1234 with your port number
The designated place for default values according to the Helm documentation is the values.yaml. This is where to look first to peruse the default configuration of a Chart. Also, it can be overwritten if need be by providing a customized values.yaml from the command line.
Also, there is the default template function. The intention here is usage for computed default values, e.g.:
drink: {{ .Values.favorite.drink | default (printf "%s-tea" (include "fullname" .)) }}