Helm notes
Published (last updated )
# List configured repositories
helm repo list
# Add a repository
helm repo add some-name https://example.com/dev-charts
# Remove a repository
helm repo remove some-name
# List installed releases
helm list
# Show configuration for an installed release
helm get values foo-0.0.1
# Show configuration for a (not-yet-installed) chart in a repository
helm show values bitnami/postgresql
# Install a helm chart from a repository
helm install bitnami/postgresql
# Install a helm chart from a local directory
helm install foo charts/foo
# Dry-run (fake) install a chart and print the rendered output
helm install foo charts/foo --debug --dry-run
# Pass along configuration key/values to an install
echo '{postgresql.auth.database: foo, postgresql.auth.username: foo}' > values.yaml
helm install -f values.yaml bitnami/postgresql
# Uninstall
helm uninstall some-release
# Download and look at the files for a published chart, without installing
helm pull bitnami/postgresql
# Create your own chart (beginning template)
helm create my-own-thing
# Package it as a tgz
helm package my-own-thing
# Check your chart for formatting and correctness
helm lint my-own-thing
# Using chart tests
helm install demo demo --namespace default
helm test demo
Chart directory structure
postgresql/
Chart.yaml # A YAML file containing information about the chart
LICENSE # OPTIONAL: A plain text file containing the license for the chart
README.md # OPTIONAL: A human-readable README file
values.yaml # The default configuration values for this chart
values.schema.json # OPTIONAL: A JSON Schema for imposing a structure on the values.yaml file
charts/ # A directory containing any charts upon which this chart depends.
crds/ # Custom Resource Definitions
templates/ # A directory of templates that, when combined with values,
# will generate valid Kubernetes manifest files.
templates/NOTES.txt # OPTIONAL: A plain text file containing short usage notes
About dependencies
In Helm, one chart may depend on any number of other charts. These dependencies
can be dynamically managed using the dependencies field in Chart.yaml where you
would use the helm dep up command to install them to charts/ directory, or
they can be brought in to the charts/ directory manually.
About templates/NOTES.txt
This file will be printed out after installation, and when viewing the status of a release. This file is evaluated as a template, and can be used to display usage notes, next steps, or any other information relevant to a release of the chart. For example, instructions could be provided for connecting to a database, or accessing a web UI. Since this file is printed to STDOUT when running helm install or helm status, it is recommended to keep the content brief and point to the README for greater detail.
Chart notes
- Starting with Helm v 3.3.2, additional unsupported fields are not allowed in the Chart.yaml file
- Charts have a type, which is either application or library
- You can have the same dependency multiple times in the dependencies of your Charts.yaml, using the alias field to give them unique names. You would do that when you want two nginx’es alias’ed as foo and bar, for example
- Using –set when installing to set arbitrary name/value pairs, overrides any values named identically in a provided values.yaml.
- A chart with dependencies is considered a single “release” after install; charts in the charts/ subdirectory won’t show up as separate releases after installation. This means that a chart and its dependencies are agregated into a single set, sorted by type followed by name and then created/updated in that order. Hence a single release is created with all the objects for the chart and its dependencies.
- Helm Chart templates are written in the Go template language, with addition of 50 or so add-on template functions from the Sprig library and a few other specialized functions.
- An included values.yaml coming with the chart would contain default values. Users can provide their own (partial) values.yaml as a parameter or via stdin. User-provided values override any values specified in the values.yaml file that comes with the chart.
- Values that are supplied via a values.yaml file or via the –set flag are accessible from the .Values object in a template. There are also a set of pre-defined values: https://helm.sh/docs/topics/charts/#predefined-values
- Values files can declare values for the top-level chart, as well as for any of the charts that are included in that chart’s charts/ directory. Or, to phrase it differently, a values file can supply values to the chart as well as to any of its dependencies.
- Helm supports special unnamespaced “global” value. things in there are available to the chart and its sub-charts under the same name.
- If a subchart declares a global variable, that global will be passed downward (to the subchart’s subcharts), but not upward to the parent chart. There is no way for a subchart to influence the values of the parent chart.
- Be smart and use values.schema.json to constrain possible values/combinations in supplied values.
- CRDs are never deleted by helm. The reason is that deleting a CRD will also automatically delete all of the CRD’s contents across all namespaces in the entire k8s cluster.
- Be aware that you can use hooks to handle things before/after installation of a release: https://helm.sh/docs/topics/charts_hooks/
- Note that if you create resources in a hook, you cannot rely upon helm uninstall to remove those resources (need to verify if this still is the case in helm v3.x).
- However, It is possible to define policies that determine when to delete corresponding hook resources. Hook deletion policies are defined using the annotations.helm.sh/hook-delete-policy.
- In the templates/ directory, any file that begins with an underscore(_) is not expected to output a Kubernetes manifest file. So by convention, helper templates and partials are placed in a _.tpl or _.yaml files.
About library charts
- The .Files object references the file paths on the parent chart, rather than the path local to the library chart
- The .Values object is the same as the parent chart, in contrast to application subcharts which receive the section of values configured under their header in the parent.
Chart tests
- is any template of a Kubernetes manifest, under the templates/ directory, with a helm.sh/hook: test annotation.
- You can nest your test suite under a tests/ directory like templates/tests/ for more isolation.
- A test is a Helm hook, so annotations like helm.sh/hook-weight and helm.sh/hook-delete-policy may be used with test resources.