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.

23.7 Helm Secrets: Encrypting Sensitive Values

Right, let’s talk about keeping your secrets out of your Git history, because right now, if you’re just committing your values.yaml files, you’re basically handing out your database passwords and API keys to anyone who can clone the repo. We’re better than that. Helm doesn’t handle encryption natively—it’s a package manager, not a vault—so we bring in a helper. The most common and robust tool for this job is helm-secrets, which is a Helm plugin that’s really just a slick wrapper around sops (Secrets OPerationS) or sometimes vals. We’re going to focus on the sops workflow because it’s brilliant and widely adopted.

23.6 Artifact Hub: The Public Helm Chart Repository

Right, so you’ve got Helm installed. You can run helm version without it throwing a fit. Congratulations, you now have a power tool with nothing to plug in. This is where Artifact Hub waltzes in, holding the extension cord. Think of it not as a chart repository, but as the public, searchable, sanity-checking index for pretty much every Helm chart you’ll ever need. It’s the replacement for the old Helm Charts repo, and it’s so much better it’s not even funny.

23.5 helm repo: Adding, Updating, and Searching Repositories

Alright, let’s talk about the one thing that makes Helm actually useful: repositories. Think of them as the app stores for your Kubernetes cluster. Without them, you’re just some weirdo hand-crafting YAML files in a dark room, which, don’t get me wrong, is a valid life choice, but it’s not why we’re here. We’re here to get stuff deployed. A Helm chart repository is, at its heart, a very simple web server that hosts two things: the packaged charts themselves (the .tgz files) and a single, constantly updated index file named index.yaml. This index is the menu. It tells Helm what charts are available, their versions, and where to download them from. When you run helm repo add or helm repo update, you’re essentially telling Helm, “Hey, go check that website’s menu and see what’s new.”

23.4 helm template: Rendering Charts Locally for Debugging

Right, let’s talk about helm template. This is the command you run when you’ve stared at a values.yaml file for so long that the YAML starts to look like a modern art painting, and you desperately need to see what the heck Helm is actually going to send to your cluster. It’s your debugger, your truth-teller, your escape hatch from the magic-and-spells abstraction that Helm provides. Think of it this way: helm install is the polished, final performance. helm template is the dress rehearsal where you get to see the actors in sweatpants and yell “line!” when they forget the words. It renders your charts locally, combines them with the values you provide, and then spits out the raw, unadulterated Kubernetes YAML manifests to stdout. No Tiller, no cluster, no questions asked. It’s just you, your chart, and the cold, hard truth of the generated YAML.

23.3 Values: Default Values and Override Patterns

Alright, let’s talk about Helm values. This is where Helm stops being a cute little package installer and starts to feel like the powerful, slightly terrifying configuration management tool it actually is. Think of the default values.yaml file that comes with a chart not as a complete settings menu, but as a suggestion. A very strong, “we-probably-thought-about-this-more-than-you-did” suggestion, but a suggestion nonetheless. Your job is to know how to override these suggestions without causing a multi-pod pileup.

23.2 helm install, upgrade, rollback, uninstall

Right, let’s get our hands dirty with the four commands you’ll use so often they’ll become muscle memory: install, upgrade, rollback, and uninstall. This isn’t just about slinging YAML at a cluster; it’s about managing the lifecycle of your application with something a bit more sophisticated than frantic kubectl patches. Think of a Helm chart as a blueprint and helm install as the construction crew. But you don’t just point them at the blueprint and walk away. You give them a set of parameters—--values or --set—to customize what they build. This is Helm’s superpower: taking a single, well-defined chart and deploying it a hundred different ways without touching the source code.

23.1 Helm Concepts: Charts, Releases, Repositories, and Revisions

Right, let’s talk about Helm. You’ve probably already felt the pain of deploying a multi-resource application to Kubernetes by hand. You write a dozen YAML files, carefully stringing them together with kubectl apply -f, and you pray to the scheduler gods that nothing goes wrong. Then you need to update one config value. Cue the frantic grep and sed session, followed by another prayer. It’s a mess. Helm exists to fix this. It’s not just a templating engine; it’s a full-fledged package manager for your Kubernetes cluster, and it works by introducing a few key concepts you need to wrap your head around.

— joke —

...