Introduction to Named Templates
Explore how to create and use named templates in Helm charts to simplify Kubernetes resource management. This lesson helps you understand extracting reusable template snippets, organizing them in _helpers.tpl files, and avoiding common errors with indentation and template inclusion in your deployments.
We'll cover the following...
Note: An interactive sandbox is located at the end of this lesson.
Named templates
We’ve got a very simple Helm chart with only two Kubernetes resources, Deployment and Service. If we take a closer look at them we would see that even though they’re two different resources, some of their parts are the same.
For instance, they have the same labels in a metadata property, as shown below:
For now, it’s rather a simple one, but that’ll change once we start to add more resources and extend the existing parts. To reduce the number of duplicated parts of a code we can extract them and define them as named templates ( a template inside a template). ...