Helm Chart Dependencies and ArtifactHub

Illustration of an animated character cheerfully juggling colorful cargo containers, expressing a sense of playfulness and control amidst logistics or supply chain management. Illustration of an animated character cheerfully juggling colorful cargo containers, expressing a sense of playfulness and control amidst logistics or supply chain management.

This is the final lesson of the Helm Lightning Course. In this lesson, we will learn how to specify chart dependencies, and we will also use external charts.

At the moment, the Helm Chart we wrote only deploys PGAdmin. Wouldn’t it be cool to deploy PostgreSQL database in addition to PGAdmin?

To achieve this, we could extend our chart with many more templates to handle the deployment of the database. And while there is nothing wrong in writing your own Helm Charts, it is even better if we could just re-use the chart that someone else already wrote.

Luckily, one of the core features of Helm is the ability to publish your charts and re-use them within other charts. There are plenty of well maintained, production-ready charts created by other people. The best way to discover those charts is to go to Artifact Hub — the biggest registry of Kubernetes packages, including Operators and Helm Charts.

I am going to search for postgresql. There are 89 community Helm Charts published here. It’s the best practice to select the most maintained and popular chart, that is ideally published by some company and not a single individual — in this case, Bitnami Postgresql Chart seems to tick all the boxes for us.

If I open the page of this chart, I can see all the values that I can specify to configure my PostgreSQL deployment, as well as plenty of other information about how to use this chart.

One way to install this Bitnami chart would be to follow the documentation and just run helm install. But we will do something different — we will specify this chart as a dependency for our PGAdmin chart. Let me show you how to do that.

Dependencies are specified in a Chart.yaml. We need to specify the chart name, chart version and the repository where the chart comes from. Note that ArtifactHub does not store the charts - chart owners need to provide the repository themselves.

To install Chart dependencies we need to run helm dep update. Running this command will create a Chart.lock file, with fixed dependency versions in it. It will also create a charts/ subdirectory with packages dependencies in it — it’s good idea to add this directory to a .gitignore.

Before we upgrade our chart, we should provide some values to the dependency chart. To do this, we need to define a top-level key with the same name as that chart name — in this case postgresql — and then override any of the default values that this chart has.

For example, let me set the password to be “secrets”, username to be “mkdev”, and the database name to be this course name.

Now let’s run helm template — and we see that there are many more resources to be created, all coming from the dependency chart. Finally, let’s upgrade our chart.

If we check the list of running pods, we will see that the postgresql pod is being created. Let’s forward the pgadmin port and open it in the browser. I am going to login to the pgadmin itself.. and now I will add a new server, pointing to the postgresql service, with username and password that I’ve specified in the values.yaml. As expected, it worked just fine - I can now perform any database operations from this pgadmin.

One of the main benefits of using Helm is this exact ability to package and share the charts. Almost any possible software that you can think of probably has a well maintained, solid community Helm chart — you can deploy your complete infrastructure by simply using this charts and passing some values overrides. You can then upgrade this software by simply updating the chart version, similar to how you would update regular software packages — and this is the reason why Helm is positioned as a Kubernetes package manager.

And that was the last lesson of Helm Lightning Course. I hope you’ve got the idea of what Helm is and how to use it, and ready to create your first real Charts.

Cloud Native consulting: regardless if you are just getting started, or looking for a big shift from the old ways to the future, we are here to help. About consulting

Here's the same article in video form for your convenience: