4 ms·
Highly recommend trying Jsonnet (via https://github.com/bitnami/kubecfg https://github.com/bitnami/kubecfg and https://github.com/bitnami-labs/kube-libsonnet ht
by q3k 6y ago
Highly recommend trying Jsonnet (via https://github.com/bitnami/kubecfg https://github.com/bitnami/kubecfg and https://github.com/bitnami-labs/kube-libsonnet https://github.com/bitnami-labs/kube-libsonnet) as an alternative. It makes writing Kubernetes manifests much more expressive and integrates better with Git/VCS based workflows. Another language like Dhall or CUE might also work, but I'm not aware of a kubecfg equivalent for them.
Jsonnet in general is a pretty damn good configuration language, not only for Kubernetes. And much more powerful than HCL.
- kraig 6y agoFunny, I thought jsonnet was an even worse experience than templating yaml
- q3k 6y agoMy experience with jsonnet varied: there's good jsonnet code, and there's bad one, too. Just like with any programming language, you have to apply good software engineering practices. Text templated YAML, however, is terrible by design.
- p_l 6y agoThe problem with templating YAML is that you're templating text, in a very sensitive to whitespace syntax. By definition, Jsonnet avoids that because it operates on the data structure, not on their stringified representation.
- threentaway 6y agoIf you like those, I'd take a look at Grafana's Tanka [0]. It also uses jsonnet but has some additional features such as showing a diff of your changes before you apply, easy vendored libraries using jsonnet-bundler, and the concept of "environments" which prevents you from accidentally applying changes to the wrong namespace/cluster. [0] https://github.com/grafana/tanka https://github.com/grafana/tanka
- q3k 6y agoI looked at it, I don't like it for the same reason as I dislike many other tools in this space: it imposes its own directory structure, abstraction (environments) and workflow. I'm a fan of the kubecfg-style approach, where it lets you use whatever sort of structure makes sense for you and your project. It's a 'framework' vs 'library' thing, but in the devops context.
- dilyevsky 6y agoI worked on this at previous gig - https://github.com/cruise-automation/isopod https://github.com/cruise-automation/isopod Same use-case but uses Starlark dsl instead of jsonnet
- AlphaSite 6y agoIve found the whole k14s eco system is pretty great to (ytt + kbld + kapp).
- q3k 6y agoytt is even more templating-yaml-with-yaml, so it all ends up being a bargain bin Helm. There's no reason to do this over just serializing plain structures into YAML/JSON/...
- AlphaSite 6y agoIt avoids the whole set of issues you get with templating yaml with helm since its structure aware. Also you can actually write pure code libraries in starlark (basically a subset of Python)
- q3k 6y agoI'm aware, but I just don't understand the point of it. How is it in any way better than a purpose-specific configuration language like Dhall/CUE/Jsonnet? What's the point of having it look like YAML at all?