Skip to content

Install Helm Charts

The cub helm commands install a Helm chart as a ConfigHub Component. The chart is rendered on your machine, as helm template renders it, and the rendered Kubernetes YAML becomes the component's base, one Unit per resource. From there the chart's output is configuration like any other: you create deployments from the base, change them with functions, and promote and release them. The chart reference and the values you gave are kept in ConfigHub, and an upgrade renders the chart again from them and merges the result into the base, so changes made in ConfigHub survive an upgrade of the chart.

The commands come from the cub-helm plugin. Install it once:

cub plugin install confighub/cub-helm

Installing a chart

cub helm install takes a release name and a chart reference, which is an oci:// reference, a local chart directory, or a chart name resolved against --repo:

cub helm install podinfo oci://ghcr.io/stefanprodan/charts/podinfo --version 6.9.0

This creates the Component podinfo, named after the release unless --component names another, and two Spaces:

  • podinfo-base is the base: the rendered Units, with the Variant label base and no Target. It exists to create deployments from.
  • podinfo-helm holds a HelmSource Unit for each release, which records the chart reference, the version, and the values. An upgrade renders the chart from it. It is not a variant of the component, since there is nothing in it to promote or release.

A workload's Unit is named after the workload, and any other resource's after its name and kind; a leading <component>- is dropped, so Helm's usual <release>-<name> names read as their short form when the release and the Component have the same name. A Deployment podinfo-backend would become the Unit backend, and its Service the Unit backend-service. Each Unit records the template it was rendered from in its UploadFile annotation, such as podinfo/templates/deployment.yaml, and carries the labels HelmChart, HelmRelease, HelmChartVersion and HelmAppVersion.

cub helm template takes the same arguments and reports the Units an install would create, or on a release already installed, update or empty, and writes nothing. To see the rendered YAML itself, use helm template.

Values

--values (-f) files and --set overrides work as they do for helm install: later files override earlier ones, and --set overrides the files. The values are stored in the HelmSource Unit, so you don't supply them again to upgrade.

Namespaces

The chart is rendered into its release namespace, --namespace, which defaults to the release name. The base keeps that namespace, rather than a placeholder, because charts write .Release.Namespace into places that set-namespace can't rewrite after rendering, such as ConfigMap data and command-line flags. --create-namespace adds a Namespace Unit for the release namespace, as helm install --create-namespace does, unless the chart renders its own or the namespace is one every cluster has, such as kube-system.

To run a chart in more than one namespace, install it once per namespace, under a different Component with --component, rather than creating deployments with cub variant create --namespace, which rewrites only the references to the namespace that it knows.

CRDs, hooks, and what a chart can't do here

CRDs in a chart's crds/ directory become Units named <name>-crd, unless --skip-crds is given, as for helm install --skip-crds.

Because the chart is rendered without a cluster, Helm's lifecycle doesn't run. Manifests annotated helm.sh/hook, such as test Pods and pre-install Jobs, are dropped, and the install lists each one it dropped; --include-hooks keeps them as plain resources instead. The lookup template function returns nothing, and .Capabilities has Helm's defaults rather than a cluster's. Most application charts render fully without them; a chart that needs them for correct output should be delivered another way.

Creating and changing deployments

A deployment is a variant of the component created from the base and bound to a Target, as for any other component:

cub variant create dev podinfo/base --target dev/target
cub release publish podinfo/dev

Customize where the change belongs:

  • For every deployment, change the chart's values or version with cub helm upgrade, or edit the base's Units, with cub unit edit or a function. Either way the change lands in the base, and reaches the deployments when they are promoted.
  • For one deployment, change its Units with --protect, which records the value as the deployment's own, so that a later promotion from the base leaves it alone. See protecting a variant's own values.
cub function set --variant podinfo/dev --resource Deployment/podinfo --protect set-replicas 3

Upgrading

cub helm upgrade changes the HelmSource Unit with its flags, renders the chart again from it, and uploads the result into the base:

cub helm upgrade podinfo --version 6.9.1
cub helm upgrade podinfo -f values.yaml

-f and --set replace the stored values, rather than adding to them, as helm upgrade does when it is given values without --reuse-values. To change one value and keep the rest, edit the HelmSource Unit, with cub unit data-edit --space podinfo-helm podinfo, and run cub helm upgrade podinfo with no flags, which renders it again as it is.

The render is merged into the base as an upgrade from upstream is: a resource that changed is merged into its Unit, so an edit made in ConfigHub is kept unless the chart changed the same field; a new resource gets a new Unit; and a resource the chart no longer renders has its Unit emptied rather than deleted, so it keeps its history and Links and the next Release removes the object. --dry-run reports what an upgrade would do and writes nothing.

The upgrade stops at the base. Preview what it would do to a deployment, then promote it and release it:

cub variant promote podinfo/dev --dry-run -o mutations
cub variant promote podinfo/dev
cub release publish podinfo/dev

A value the deployment protected is withheld from the promotion and reported, rather than overwritten.

More than one chart in a component

A component can be made of several charts, such as an application and the database it uses. Install each into the same Component with --component:

cub helm install --component shop --namespace shop shop oci://ghcr.io/acme/charts/shop
cub helm install --component shop --namespace shop db oci://registry-1.docker.io/bitnamicharts/postgresql

Each release writes and upgrades only its own Units. When two releases render a resource with the same name, such as a CRD both charts ship, the later one's Unit gets a numbered slug, and the install warns that both define the same object.