Search code examples
kubernetes-helm

Helm charts: Are you allowed children directories within the Templates directory?


This seems like a really simple question but I couldn't find a straight answer to it.

My question is, are you allowed children directories within the templates directory of a Helm chart? i.e, something like this:

mychart/
|-- Chart.yaml
|-- charts
|-- templates/
|   |-- NOTES.txt
|   |-- _helpers.tpl
|   |-- deployment.yaml
|   |-- ingress.yaml
|   |-- service.yaml
|   |-- child-dir1/
|   |   |-- some-file-1.yaml
|   |   `-- some-file-2.yaml
|   `-- child-dir2/
|       |-- some-file-3.yaml
|       `-- some-file-4.yaml
`-- values.yaml

I already understand the most basic file structure which can be found with a simple google search:

mychart
|-- Chart.yaml
|-- charts
|-- templates
|   |-- NOTES.txt
|   |-- _helpers.tpl
|   |-- deployment.yaml
|   |-- ingress.yaml
|   `-- service.yaml
`-- values.yaml

I'm just wanting a straight answer about whether or not you can use subdirectories within the templates directory. My initial thought would be no, but I'd like confirmation and maybe an explanation on why that is not possible with the current design of Helm. Thanks!


Solution

  • I finally got around to working on some Helm charts again and decided to experiment with this and it seems that you can create as many child directories as you want. This was for a library chart however, so each yaml or tpl file has a definition at the top of the file which is called whenever it is used.

    Here's my directory structure showing that this can be done: Helm repo directory structure

    I'm still not 100% sure if this works with application charts, however, I suspect they would still work just fine.