Sub topic 9
Using OCI charts as dependencies
This chapter assumes you can push and pull a chart with oci:// references and have run helm registry login. It also assumes you know how a parent chart lists subcharts in Chart.yaml. You need Helm 3.8 or later.
How an OCI dependency is declared
A dependency entry has three key fields: name, version and repository. For an OCI chart, repository is the registry path that contains the chart. It does not include the chart name, because name supplies that. Helm joins the two to get oci://registry.example.com/charts/myapp.
apiVersion: v2
name: platform
description: Parent chart that bundles myapp
type: application
version: 1.0.0
dependencies:
- name: myapp
version: 0.1.0
repository: oci://registry.example.com/chartsThis differs from helm pull and helm install. There you write the full path with the chart name and pass --version separately. Here the name and version live in their own fields.
Fetching dependencies
Run these commands from the parent chart directory:
helm registry login registry.example.com --username alice
helm dependency update ./platform
helm dependency list ./platformhelm dependency update resolves each dependency, downloads the chart into charts/ as a .tgz file, and writes Chart.lock. The lock file records the exact version and a digest of the dependency list. helm dependency build skips resolution and installs exactly what Chart.lock says. Use build in CI and update when you want to change versions.
Version ranges
An OCI registry has no index.yaml, so Helm cannot read a catalog of versions. When you use a range, Helm lists the tags of the repository and picks the highest one that matches.
dependencies:
- name: myapp
version: ">=0.1.0 <0.2.0"
repository: oci://registry.example.com/chartsRanges make builds less predictable. Chart.lock fixes this: commit it, and helm dependency build reproduces the same versions each time.
Alias, condition and values
OCI dependencies accept the same optional fields as any other dependency:
dependencies:
- name: myapp
version: 0.1.0
repository: oci://registry.example.com/charts
alias: frontend
condition: frontend.enabledWith alias, you configure the subchart under frontend: in the parent's values.yaml. With condition, the subchart is only rendered when frontend.enabled is true.
Packaging a parent chart
helm package includes the contents of charts/, so the published parent chart carries its dependencies inside it. Consumers of the parent do not need access to the dependency's registry at install time. Run helm dependency build before helm package. Recent Helm versions can do this for you with helm package --dependency-update.
Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| Chart not found at `.../charts/myapp/myapp` | The chart name was added to `repository` | Remove the name from `repository` and keep it in `name` |
| `unauthorized` during update | Not logged in to the registry | Run `helm registry login` first |
| `no repository definition` or a missing repo warning | A `repository` value without a valid scheme | Use `oci://` followed by the path |
| Different versions on different machines | A range is used and `Chart.lock` is not committed | Commit `Chart.lock` and use `helm dependency build` |
Exercise
A parent chart declares a dependency with name: myapp and repository: oci://registry.example.com/charts/myapp. The update fails because the chart cannot be found. What is wrong, and what should the entry be?
Show answer
The repository value contains the chart name, and Helm appends name again, so it looks for charts/myapp/myapp. The entry should be repository: oci://registry.example.com/charts, with name: myapp and version: 0.1.0 as separate fields.
Exercise
In CI, you want every build to use exactly the dependency versions you tested locally. Which file do you commit, and which command do you run?
Show answer
Commit Chart.lock and run helm dependency build. It installs the versions recorded in the lock file instead of resolving ranges again.