Konubinix' opinionated web of thoughts

K8s Templating Solutions

Fleeting

k8s templating solutions

When playing with kubernetes, you can do whatever you want, but you quickly feel like you could automate most of the definition of the resources.

kustomize appears to be the good candidate, since it is

  • suggested by the official documentation
  • included in kubektl

After trying to use kustomize for a while, I was disappointed by the lack of templating. Indeed, I needed to use the same value at several locations of my stack, like listen="https://{myip}" somewhere and api="{myip}" somewhere else.

I naturally came to helm that provides a templating engine. Also, helm provides a package manager, allowing to reuse charts made by other people. And this is kind of cool.

The package manager is indeed very cool, but using gotemplate to template yaml files results easily in unreadable files. Also, I prefer the logic of kustomize inheritance.

Also, the package management stuff suggests that helm thought about the charts composition, while there are several clear impediments to do so.

When you package a chart, all its dependencies are copied in the packaged, so you are not describing dependencies anymore but gluing several charts together. You cannot then (by design) use pin intervals.

Also, it does not update the dependencies of subcharts, making difficult developing a multi charts application.

But the worst was the fact it does not allow to template the values.yaml file. This breaks the promise of templating stuff. Because in my use case, I need to compose several charts by passing the same value.

Then, even the simple example that convinced my to go to helm is not doable in helm.

So far, people use ad-hoc solutions with bash scripts calling kustomize and helm and moving files around.

Yes, this is a lot more work than just running helm install, however, the transparency you gain is worth it. As in any system, you don’t want any unknowns lurking in the dark.

https://blog.container-solutions.com/using-helm-and-kustomize-to-build-more-declarative-kubernetes-workloads

I like this approach, but moving from docker-compose to k8s is a change of paradigm, and even if I understand the concepts and how to do what I want to achieve, teaching k8s to my colleagues by orchestrating several tools with overlapping responsibilities in ad-hoc bash scripts is a difficult task.

I like the idea of avionix to build helm charts. This fixes the problem of templating values.yaml. Unfortunately, it does not fixes the subchart issue.

Also, helm could integrate natively kustomize to render templates before.