rimusz blog

Cloud computing, clusters, containers, Kubernetes, Helm ...

How to use ChartCenter with Helm dependency charts

ChartCenter is a free Helm chart central repository that was built to help the Helm community find immutable, secure, and reliable charts for publicly available Kubernetes apps. With ChartCenter, you have a single source of truth to proxy all public charts from one, always available location.

Without ChartCenter, you need to add each Helm chart’s repository to the Helm client for every Kubernetes app you want to install and update. When you add the ChartCenter repository to your Helm client, you’ll have immediate access to the Helm charts for over 250 public Kubernetes apps (and growing) proxied in ChartCenter. So, instead of many public Helm repositories, use just one.

When you author your own Helm charts, you can also make sure the public charts you use as dependencies are immutable and always available by referencing their proxies in ChartCenter. This avoids any unpleasant surprises that might later be caused by a force push or deletion in the chart’s original repo. When you go through ChartCenter, you’ll always know what you're getting -- even more so with ChartCenter's rich metadata on dependencies, stats, and security.

Let’s look at how to reference ChartCenter from your dependency charts, and the small plugin for Helm that enables you to do so.

Using ChartCenter

It is so easy to set ChartCenter as your central Helm repository:

helm repo add center https://repo.chartcenter.io
helm repo update

Now your Helm client can access any of the over 30,000 versioned Helm charts available in ChartCenter, and many popular app charts are featured on ChartCenter’s homepage so you can conveniently locate them.

But ChartCenter might hold several different sets of Helm charts for the same Kubernetes app from alternative repos that may contain charts for specialty, duplicate, or deprecated editions.

For example, searching for the PostgreSQL database application in ChartCenter finds several matches:

chartcenter postgresql

In ChartCenter, a namespace identifies the Helm repository where the Helm chart versions were found, and you must reference the ChartCenter Helm chart by that namespace. For example, reference the official Bitnami Helm chart for PostgreSQL as bitnami\postgresql.

To install PostgreSQL from the helm command line:

helm install postgresql center/bitnami/postgresql

Using ChartCenter for Dependency Charts

In the example above we have installed bitnami/postgresql from the Helm repo https://repo.chartcenter.io, and it works just fine.

But instead of installing PostgreSQL through the helm client’s command line, we would like to install it as a dependency in a Helm chart of our own creation.

To include Bitnami PostgreSQL in your Helm chart, your chart’s requirements.yaml or Chart.yaml file might specify under dependencies the chart from the Bitnami repository:

dependencies:
- name: postgresql
  version: 9.2.1
  repository: https://repo.chartcenter.io
  condition: postgresql.enabled

But we want to use the immutable proxy of the Bitnami chart in ChartCenter. In this case, repository would specify the URL for the ChartCenter repo, but the chart’s name must also include the namespace:

dependencies:
- name: bitnami/postgresql
  version: 9.2.1
  repository: https://repo.chartcenter.io
  condition: postgresql.enabled

The bitnami namespace enables us to address the correct chart in ChartCenter but the problem is that the helm package command doesn't understand it yet.

There is an issue opened for the Helm v3 client to support an extra namespace in the helm package command, but that could take awhile to be sorted. The Helm v2 client is not accepting any new features.

So how in the meantime we can solve the problem?

Using ChartCenter plugin

To enable the Helm client to recognize the namespace, we’ve developed a ChartCenter plugin for Helm that can be used with either the Helm v3 or v2 client.

Let's install the latest plugin version:

helm plugin install https://github.com/jfrog/chartcenter-plugin

The plugin replaces the helm dependency update and helm package commands with just one helm center command:

helm center <CHART_NAME>

This new command will run helm dependency update, pulling the sub chart(s) from the ChartCenter Helm repository and then package the main chart with sub chart(s) to the .tgz file to be ready to be uploaded to any Helm repository.

Boom, a nice and easy way to use the ChartCenter plugin as a tool to package dependency charts from the ChartCenter helm repo.

Happy ChartCenter charting

Rimas Mocevicius

Cloud Native, Kubernetes, Co-founder of Helm, CKA, CoreOS Essentials book author, Kubernaut at JFrog

Vilnius, Lithuaniahttps://rimusz.net