24.9 Publishing Charts to a Repository

Right, so you’ve got a chart. It’s a beautiful, finely-tuned machine of YAML, templating magic, and pure willpower. But right now, it’s just sitting on your laptop, which is about as useful as a race car in a living room. We need to get it on the track. We need to publish it to a repository so other people (or, let’s be honest, your CI/CD system) can actually use it.

24.8 Dependencies: requirements.yaml and Sub-Charts

Right, so you’ve built a chart. Congratulations, it’s a beautiful, self-contained snowflake. Now, let’s get real. Almost nothing useful in the Kubernetes ecosystem lives in total isolation. Your app probably needs a database, a redis cache, or maybe it depends on some other internal service. You could just tell the user to install those first, but we’re not barbarians. We’re engineers. We automate things. This is where Helm chart dependencies come in, and you’ve got two main ways to handle them: the old way (requirements.yaml) and the more modern, integrated way (sub-charts).

24.7 Chart Tests: Validating a Release Works

Right, so you’ve built a Helm chart. It looks beautiful. The templates are elegant, the values.yaml is a model of clarity. But let’s be honest: you have absolutely no idea if it will actually work when someone runs helm install. Pushing a broken chart is the Helm equivalent of showing up to a black-tie event with your fly down. It’s unprofessional, and everyone will see it. This is where chart tests come in—they’re your automated fly-check.

24.6 Helm Hooks: pre-install, post-upgrade, pre-delete

Now, let’s talk about Helm Hooks, the Swiss Army knife of Helm chart automation and, occasionally, the source of your most baffling “why is that pod just sitting there?” debugging sessions. You use these when you need something to happen around your main deployment process—not as part of the main application’s lifecycle, but as a supporting act. Think of them as the stagehands that set up the scenery before the play, adjust things between acts, and clean up after the final curtain.

24.5 Flow Control: if, range, with

Right, let’s talk about making your Helm charts less like a static to-do list and more like a dynamic, context-aware application. This is where the real power—and the real headaches—begin: flow control with if, range, and with. These are your fundamental building blocks for logic within your chart templates. They’re not some fancy add-on; they’re the core tools you use to say, “If this thing exists, do this,” or “For each of these things, make a chunk of YAML.” They’re powered by Go’s text/template library, which means they’re powerful but occasionally feel like they were designed by someone who thinks parentheses are for the weak. We’ll get to that.

24.4 Named Templates: _helpers.tpl and include vs template

Right, let’s talk about the part of Helm that feels like you’re learning a secret handshake: named templates and the _helpers.tpl file. This is where you stop being a chart user and start being a chart author. You’re not just filling in values; you’re crafting the very logic that generates your Kubernetes manifests. It’s powerful, and honestly, a little bit fun once you get the hang of it. We keep these reusable code snippets in templates/_helpers.tpl by convention. Helm doesn’t require this filename, but if you name it anything else, every other Helm developer who looks at your chart will immediately know you’re a psychopath. Don’t be that person. The _ prefix is Helm’s cue that these files don’t contain Kubernetes manifests themselves; they’re just a library of templates to be included elsewhere.

24.3 Sprig Functions in Helm Templates

Right, let’s talk about Sprig. This is where Helm templates go from being a simple placeholder replacement system to a genuinely powerful templating engine. Sprig is a library of over 100 template functions baked directly into Helm, and it’s our Swiss Army knife for manipulating strings, numbers, lists, dictionaries, and dates. Without it, we’d be writing a lot more Go code and stuffing it into tpl functions, which is a path I don’t recommend unless you enjoy pain.

24.2 Go Templating Basics: Variables, Pipelines, and Functions

Alright, let’s get our hands dirty with Go’s templating language, the engine that makes your Helm charts dynamic. Forget dry, academic explanations. We’re going to talk about this like engineers who have been burned by it before and have learned to respect its power (and its quirks). At its heart, templating is about taking a YAML structure, which is mostly static, and injecting life into it. You do this with three core concepts: variables to hold data, pipelines to pass that data around, and functions to actually do something with it.

24.1 Chart Directory Structure: Chart.yaml, values.yaml, templates/

Right, let’s get our hands dirty. You’re about to build a Helm chart, which is essentially a fancy package for your Kubernetes manifests. The structure isn’t just a formality; it’s the entire skeleton of your application deployment. Get this wrong, and you’ll be fighting your own creation. Get it right, and you have a powerful, reusable artifact. Think of a Helm chart directory as a house with three crucial rooms: the legal deed (Chart.yaml), the interior design plans (values.yaml), and the raw, buildable framework (templates/). You can’t have one without the others.

— joke —

...