Helm install: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(159 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=
* https://helm.sh/docs/helm/#helm-install
* https://helm.sh/docs/using_helm/#helm-install-installing-a-package
* https://helm.sh/docs/using_helm/#helpful-options-for-install-upgrade-rollback


=Internal=
=Internal=
Line 9: Line 5:
* [[Helm Operations#Commands|Helm Operations]]
* [[Helm Operations#Commands|Helm Operations]]
* [[Helm Concepts#Chart|Helm Concepts]]
* [[Helm Concepts#Chart|Helm Concepts]]
* <code>[[helm upgrade]]</code>


=Overview=
=Overview=
<code>helm install</code> installs a chart, that may come from different [[#Chart_Sources|sources]], and creates a [[Helm Concepts#Release|release]]:
<font size=-1>
helm install <''release-name''> <''chart''> [options]
</font>
<span id='Specifying_a_Release_Name'></span>The release name must be specified explicitly, and it must be the first argument. If it should be generated, <code>[[#--generate-name|--generate-name]]</code> must be used instead of the release name.
=<span id='Installing_from_Different_Sources'></span>Chart Sources=
There are five types of chart sources:
# [[#Unpacked_Chart|Unpacked charts on the local filesystem]]
# [[#Packaged_Chart|tgz packaged chart on the local filesystem]]
# [[#Absolute_URL|Absolute URL of a chart archive in a remote repository]]
# [[#Chart_Reference|Chart reference in a remote repository]]
# [[#Using_a_Repository_Prefix|Chart is present in a locally cached repository, and specified by its chart name and repository prefix]]


Install a [[Helm Concepts#Chart_Archive|chart archive]], by [[Helm_Dependencies#Transitive_Dependencies_and_requirements.lock_File|discovering the transitive dependency tree]] of the chart, if the chart has dependencies, and creating a [[Helm Concepts#Release|release]] in the process.
==<span id='Installing_from_an_Unpacked_Chart_Directory'></span><span id='Unpacked_Chart'></span>Path to an Unpacked Chart==
The chart argument of the install command can be an unpacked local chart directory. [[Helm_Concepts#Chart_Name|The directory name must be identical with the chart name specified in Chart.yaml]]).
<font size=-1>
helm install simplest ./playground/helm/simplest
</font>


The chart may come from a [[Helm Concepts#Repository|repository]]:
==<span id='Installing_from_a_File'></span><span id='Packaged_Chart'></span>Path to a Packaged Chart==
helm install simplest ./simplest-1.0.0.tgz
Charts can be packaged with [[helm package]] command.


helm install <''chart-name''>
<font color=darkgray>Where is the chart expanded locally?</font>
helm install stable/mysql


or from a local directory (note that the [[Helm_Concepts#Chart_Name|directory name must be identical with the chart name specified in Chart.yaml]]):
==<span id='Installing_from_a_URL'></span><span id=''URL></span>Absolute URL==


helm install <''directory-name-that-must-match-chart-name''>
The absolute URL of a chart can be used as such:


=Dry Run=
<syntaxhighlight lang='bash'>
helm install something https://example.com/charts/something-1.0.0.tgz
</syntaxhighlight>


In this mode, we send the templates to the Tiller server, which renders them, but instead of installing the chart, it returns the rendered template so it can be inspected:
The version is built into the name of the chart, this is the [[Helm_Concepts#Chart_Versioning|default Helm versioning convention]]. The chart does not need to be cached in the local repository and the repository does not need to be cached locally with [[Helm_repo#Add_a_New_Repository|repo add]].


helm install <...> --debug --dry-run
If the remote repository is password-protected, [[#--username.2C_--password|the username and the password]] can be specified on the command line with:
<syntaxhighlight lang='bash'>
helm install something https://example.com/charts/something-1.0.0.tgz --username <username> --password <password>
</syntaxhighlight>


Note that in this mode, it is not guaranteed that Kubernetes will accept the generated manifest.
<font color=darkgray>Where is the chart expanded locally?</font>


=Specifying a Release Name=
==Chart Reference==


helm install --name <''release-name''> ...
A chart available in a [[Helm_Concepts#Repository|chart repository]] can be specified by a [[Helm_Concepts#Chart_Reference|chart reference]] (which is the same thing as the [[Helm_Concepts#Chart_Name|chart name]]) when installed. There are two ways to specify a chart reference:


=Overriding Default Configuration=
===Using an Explicit Repository URL with --repo===


==-f|--values==
A repository URL can be specified in-line in the install command line with --repo, without being previously added with [[Helm_repo#Add_a_New_Repository|helm repo add]]:


[[Helm_Concepts#Chart_Configuration|Default configuration]] - or just some values - can be overridden in bulk with:
<syntaxhighlight lang='bash'>
helm install --repo https://example.com/charts/ mynginx [--version 1.2.3] nginx
</syntaxhighlight>


If [[#--version|--version]] is not specified, the latest present version is installed.
<font color=darkgray>Where is the chart expanded locally?</font>
===Using a Repository Prefix===
If the repository was [[Helm_repo#Add_a_New_Repository|added locally]] under a specific name ("myRepository" in the example below), then the chart can be referred by <repository-name>/<chart-name>. If no version specification is provided, the latest stable version of the chart will be installed:
<syntaxhighlight lang='bash'>
helm install postgresql myRepository/postgresql
</syntaxhighlight>
A specific version can be requested with [[#--version|--version]].
<syntaxhighlight lang='bash'>
helm install postgresql --version 1.2.3 myRepository/postgresql
</syntaxhighlight>
The charts available in the repository can be listed with:
<syntaxhighlight lang='bash'>
helm search repo myRepository
</syntaxhighlight>
=helm install and Dependencies=
<font color=darkgray>
If the chart has dependencies, they must be present in the [[Helm_Concepts#charts_Directory|charts/]] subdirectory at the time of the installation. <code>helm install</code> does not manage dependencies, <code>[[helm dependency]]</code> does. <code>helm install</code> performs some sanity checks, such as comparing the content of [[Helm_Chart_requirements.yaml|requirements.yaml]] with the content of the charts/ subdirectory and failing if requirements.yaml contains dependencies that are not in charts/. However, if a dependency is present in charts/ but not in requirements.yaml, it will be installed. For more details on dependencies and how they work, see: {{Internal|Helm_Dependencies#How_Helm_Dependencies_Work|How Helm Dependencies Work}}
TODO: [[#--dependency-update|--dependency-update]].
</font>
=<span id='Helm_install#Overriding_Default_Configuration'></span>Overriding Default Configuration or Providing New Cofiguration=
==<tt>-f|--values</tt>==
Default configuration can be overridden or new configuration can be specified with:
<font size=-1>
  helm install -f|--values <''configuration-overrides-file''.yaml> <''chart name''>
  helm install -f|--values <''configuration-overrides-file''.yaml> <''chart name''>
</font>
The <code>-f|--values</code> flag can be specified multiple times on the command line, and the rightmost value will take precedence. The effective configuration actually applied to the chart is computed by using the chart's <code>values.yaml</code> as base and then logically overlaying the configuration files from left to right. An overlay step leaves configuration paths that exist in the base but are not present in the overlay unchanged, overwrites configuration paths that are present both in the base and the overlay with the value present in the overlay, and adds new configuration paths that do not exist in the base but exist in the overlay. The process is repeated from left to right for all files present on command line.


The -f|--values flag can be specified multiple time on the command line, and the rightmost value will take precedence.
For more details on Helm configuration see: {{Internal|Helm_Configuration#Values_Supplied_in_Files|Helm Configuration}}


==--set==
==<tt>--set-file</tt>==
<font size=-1>
--set-file stringArray   
</font>
"names" the content of a file, and makes it available from templates using the name. Set values from respective files specified via the command line. Multiple or separate values can be specified as <code>key1=path1,key2=path2)</code>


Individual configuration options can be specified with --set, --set-string and --set-file. If both --set and --values are used, the --set-specified configuration values are merged into the configuration values specified with --values, with higher precedence. Overrides specified with --set are persisted in a [[Kubernetes_Cluster_Configuration_Concepts#ConfigMap|ConfigMap]] and can be viewed for a given release with [[Helm_get#Get_Values|helm get value <''release-name''>]]:
<font color=darkkhaki>TODO:
<font size=-1>
--set-file certificate=/path/to/the/file
</font>
then call <code>.Values.certificate</code> in the template to access the file's data.
</font>


helm install --set size=10 ...
For more details on Helm configuration see: {{Internal|Helm_Configuration#Values_Supplied_in_Files|Helm Configuration}}


A value specified [[Helm Chart values.yaml|values.yaml]] can be effectively effectively eliminated, by setting that value to <tt>null</tt> with
==<span id='--set'></span><tt>--set, --set--string</tt>==


  ... --set <''key''>=null ...
Individual configuration options can be specified with <code>--set</code> or <code>--set-string</code>.
<font size=-1>
  helm install --set size=10 <''chart name''>
</font>
For more details on overriding or specifying configuration see: {{Internal|Helm_Configuration#--set_Command_Line_Arguments|Helm Configuration &#124; <tt>--set</tt> Command Line Arguments}}


For more details on relative precedence of different sources of configuration data, see: {{Internal|Helm_Concepts#Values_and_Chart_Configuration|Values and Chart Configuration}}
=Overriding Tags and Conditions=
Use --set to override default [[Helm Concepts#Tag|tag]] and  [[Helm Concepts#Condition|condition]] values at installation time.
 
=Options=
 
==Generic Options==
{{Internal|Helm_Operations#Generic_Options|Generic Options}}
==<tt>--generate-name</tt>==
Generate a release name:
 
helm install --generate-name <''chart''>
 
If used, the user-supplied name must be omitted from the command line, and a name based on the chart name will be generated. If the chart is named "simplest", the generated name is similar to "simplest-1-1575057340".
 
==<span id='Dry_Run'></span><tt>--dry-run</tt>==
 
In this mode, the installation is simulated, without actually modifying anything on the Kubernetes cluster. Instead of installing the chart, the rendered template are sent to stdout so they can be inspected. Note that in this mode, it is not guaranteed that Kubernetes cluster will accept the generated manifest.
 
helm install --dry-run ...
 
<code>--dry-run</code> can be combined with [[#--debug|--debug]] for more information:


===Overriding Array Elements===
helm install --dry-run --debug ...


If the value file contains array structures, individual elements of the arrays can be identified from command line and overridden using the [...] syntax. If values.yaml contains:
==<tt>--debug</tt>==
helm install --debug ...


colors:
The --debug flag displays:
  - name: 'blue'
* [[Helm_Concepts#Effective_Values|user-supplied values and computed values]]
    shade: 'dark'
  - nane: 'red'
    shade: 'light'


the "name" of the first element of the array can be overridden with:
==<tt>--verify</tt>==


--set colors[0].name=green,colors[0].shade=faded
If --verify is used, the chart must have a provenance file, and the provenance file must pass all verification steps.


{{Warn|'''Warning 1''' If an array element contains more than on key/value mapping, replacing just one key/value mapping with --set will discard the other ones, so you will need to set all key/value pairs at the same time. For the above example, --set colors[0].name to green will yield an empty shade for element 0.}}
==<tt>--atomic</tt>==


Installation process purges chart on fail. The [[#--wait|--wait]] flag will be set automatically if --atomic is used.


<font color=darkgray>TODO: https://helm.sh/docs/using_helm/#the-format-and-limitations-of-set</font>
==<tt>--version</tt>==
Specify the exact chart version to install. If this is not specified, the latest version is installed.


=Overriding Tags and Conditions=
==<tt>--dependency-update==
{{External|[https://helm.sh/docs/developing_charts/#using-the-cli-with-tags-and-conditions Using the CLI with Tags and Conditions]}}


Use --set to override default [[Helm Concepts#Tag|tag]] and  [[Helm Concepts#Condition|condition]] values at installation time.
Run [[Helm_dependency#Dependency_Update|helm dependency update]] before installing the chart. <font color=darkgray>TODO: more research here.</font>


=Installing from Different Sources=
==<tt>--name-template</tt>==


The default option for the helm install command is to install from the default repository. However, the chart may come from different sources:
<font color=darkgray>Specify template used to name the release.</font>


==Installing from a File==
==<tt>--output</tt>==
<font color=darkgray>Prints the output in the specified format. Allowed values: table, json, yaml (default table).</font>
==<tt>--wait</tt>==
If set, Helm will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as [[#--timeout|--timeout]]:
<syntaxhighlight lang='bash'>
helm instal ... --wait --timeout 60s
</syntaxhighlight>
If timeout occurs, the helm command will exit with a non-zero exit code, but the installation will continue and it may eventually succeed.


helm install something-0.1.1.tgz
==<tt>--timeout</tt>==
The time to wait for any individual Kubernetes operation. The default value is 5 minutes.
<syntaxhighlight lang='bash'>
helm install --timeout 5m0s
</syntaxhighlight>
Also see [[#--wait|--wait]] above.


==Installing from an Unpacked Chart Directory==
==<tt>--replace</tt>==
Also see [[Helm_uninstall#Keep_a_Resource_from_Being_Uninstalled|helm uninstall - Keep a Resource from being Uninstalled]] to understand implication on orphaned resources.


  helm install ./something
==<tt>--username, --password</tt>==
See [[#Absolute_URL|Absolute URL of a chart in a remote repository]] above.
==<tt>-n,--namespace</tt>==
Specifies the namespace scope for this installation.
<font size=-1>
  helm install -n test blue ./src/mian/helm/blue
</font>
Note that the namespace must exist, otherwise Helm installation will fail:
<syntaxhighlight lang='text'>
Error: create: failed to create: namespaces "test" not found
</syntaxhighlight>
The namespace specified with -n can be retrieved in templates with the [[Helm_Templates#Release.Namespace|.Release.Namespace]] built-in object.


==Installing from a URL==
==<tt>--create-namespace</tt>==
Create the release namespace if not present.


helm install https://example.com/charts/something-1.0.0.tgz
=Scenarios=
==Using External Files during Installation==
<font color=darkgray>TODO:</font>
{{External|https://github.com/helm/helm/issues/3276}}
==Accessing Arbitrary Files inside Templates==
{{Internal|Helm Accessing Arbitrary Files inside Templates#Overview|Accessing Arbitrary Files inside Templates}}

Latest revision as of 19:02, 2 March 2022

External

Internal

Overview

helm install installs a chart, that may come from different sources, and creates a release:

helm install <release-name> <chart> [options]

The release name must be specified explicitly, and it must be the first argument. If it should be generated, --generate-name must be used instead of the release name.

Chart Sources

There are five types of chart sources:

  1. Unpacked charts on the local filesystem
  2. tgz packaged chart on the local filesystem
  3. Absolute URL of a chart archive in a remote repository
  4. Chart reference in a remote repository
  5. Chart is present in a locally cached repository, and specified by its chart name and repository prefix

Path to an Unpacked Chart

The chart argument of the install command can be an unpacked local chart directory. The directory name must be identical with the chart name specified in Chart.yaml).

helm install simplest ./playground/helm/simplest

Path to a Packaged Chart

helm install simplest ./simplest-1.0.0.tgz

Charts can be packaged with helm package command.

Where is the chart expanded locally?

Absolute URL

The absolute URL of a chart can be used as such:

helm install something https://example.com/charts/something-1.0.0.tgz

The version is built into the name of the chart, this is the default Helm versioning convention. The chart does not need to be cached in the local repository and the repository does not need to be cached locally with repo add.

If the remote repository is password-protected, the username and the password can be specified on the command line with:

helm install something https://example.com/charts/something-1.0.0.tgz --username <username> --password <password>

Where is the chart expanded locally?

Chart Reference

A chart available in a chart repository can be specified by a chart reference (which is the same thing as the chart name) when installed. There are two ways to specify a chart reference:

Using an Explicit Repository URL with --repo

A repository URL can be specified in-line in the install command line with --repo, without being previously added with helm repo add:

helm install --repo https://example.com/charts/ mynginx [--version 1.2.3] nginx

If --version is not specified, the latest present version is installed.

Where is the chart expanded locally?

Using a Repository Prefix

If the repository was added locally under a specific name ("myRepository" in the example below), then the chart can be referred by <repository-name>/<chart-name>. If no version specification is provided, the latest stable version of the chart will be installed:

helm install postgresql myRepository/postgresql

A specific version can be requested with --version.

helm install postgresql --version 1.2.3 myRepository/postgresql

The charts available in the repository can be listed with:

helm search repo myRepository

helm install and Dependencies

If the chart has dependencies, they must be present in the charts/ subdirectory at the time of the installation. helm install does not manage dependencies, helm dependency does. helm install performs some sanity checks, such as comparing the content of requirements.yaml with the content of the charts/ subdirectory and failing if requirements.yaml contains dependencies that are not in charts/. However, if a dependency is present in charts/ but not in requirements.yaml, it will be installed. For more details on dependencies and how they work, see:

How Helm Dependencies Work

TODO: --dependency-update.

Overriding Default Configuration or Providing New Cofiguration

-f|--values

Default configuration can be overridden or new configuration can be specified with:

helm install -f|--values <configuration-overrides-file.yaml> <chart name>

The -f|--values flag can be specified multiple times on the command line, and the rightmost value will take precedence. The effective configuration actually applied to the chart is computed by using the chart's values.yaml as base and then logically overlaying the configuration files from left to right. An overlay step leaves configuration paths that exist in the base but are not present in the overlay unchanged, overwrites configuration paths that are present both in the base and the overlay with the value present in the overlay, and adds new configuration paths that do not exist in the base but exist in the overlay. The process is repeated from left to right for all files present on command line.

For more details on Helm configuration see:

Helm Configuration

--set-file

--set-file stringArray     

"names" the content of a file, and makes it available from templates using the name. Set values from respective files specified via the command line. Multiple or separate values can be specified as key1=path1,key2=path2)

TODO:

--set-file certificate=/path/to/the/file

then call .Values.certificate in the template to access the file's data.

For more details on Helm configuration see:

Helm Configuration

--set, --set--string

Individual configuration options can be specified with --set or --set-string.

helm install --set size=10 <chart name>

For more details on overriding or specifying configuration see:

Helm Configuration | --set Command Line Arguments

Overriding Tags and Conditions

Use --set to override default tag and condition values at installation time.

Options

Generic Options

Generic Options

--generate-name

Generate a release name:

helm install --generate-name <chart>

If used, the user-supplied name must be omitted from the command line, and a name based on the chart name will be generated. If the chart is named "simplest", the generated name is similar to "simplest-1-1575057340".

--dry-run

In this mode, the installation is simulated, without actually modifying anything on the Kubernetes cluster. Instead of installing the chart, the rendered template are sent to stdout so they can be inspected. Note that in this mode, it is not guaranteed that Kubernetes cluster will accept the generated manifest.

helm install --dry-run ...

--dry-run can be combined with --debug for more information:

helm install --dry-run --debug ...

--debug

helm install --debug ...

The --debug flag displays:

--verify

If --verify is used, the chart must have a provenance file, and the provenance file must pass all verification steps.

--atomic

Installation process purges chart on fail. The --wait flag will be set automatically if --atomic is used.

--version

Specify the exact chart version to install. If this is not specified, the latest version is installed.

--dependency-update

Run helm dependency update before installing the chart. TODO: more research here.

--name-template

Specify template used to name the release.

--output

Prints the output in the specified format. Allowed values: table, json, yaml (default table).

--wait

If set, Helm will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout:

helm instal ... --wait --timeout 60s

If timeout occurs, the helm command will exit with a non-zero exit code, but the installation will continue and it may eventually succeed.

--timeout

The time to wait for any individual Kubernetes operation. The default value is 5 minutes.

helm install --timeout 5m0s

Also see --wait above.

--replace

Also see helm uninstall - Keep a Resource from being Uninstalled to understand implication on orphaned resources.

--username, --password

See Absolute URL of a chart in a remote repository above.

-n,--namespace

Specifies the namespace scope for this installation.

helm install -n test blue ./src/mian/helm/blue

Note that the namespace must exist, otherwise Helm installation will fail:

Error: create: failed to create: namespaces "test" not found

The namespace specified with -n can be retrieved in templates with the .Release.Namespace built-in object.

--create-namespace

Create the release namespace if not present.

Scenarios

Using External Files during Installation

TODO:

https://github.com/helm/helm/issues/3276

Accessing Arbitrary Files inside Templates

Accessing Arbitrary Files inside Templates