What does HackerNews think of dhall-kubernetes?

Typecheck, template and modularize your Kubernetes definitions with Dhall

Language: Dhall

#3 in Kubernetes
I hate yaml with a passion. It marginally better than xml for reading (wins huge on comment syntax) and worse for everything else. It makes zero sense we somehow ended up with it as standard configuration serialization format.

Note yaml is not a DSL. It's a tree serialization format! Everything interesting is happening after it is parsed. Extreme examples point to e.g. github actions conditions.

Anyway, back on topic - maybe not prolog for CDK, but still quite interesting: Dhall-kubernetes - https://github.com/dhall-lang/dhall-kubernetes

At this point, if it’s painful enough, why isn’t compiling-to-yml tools more popular?

Example: https://github.com/dhall-lang/dhall-kubernetes

Haven’t used dhall myself but I’d definitely prefer a DSL on top of yaml.

k8s is a pretty good one. I would not touch k8s without Dhall:

https://github.com/dhall-lang/dhall-kubernetes

Dhall is my favorite configuration language that I never get around to using.

I manage DNS in Terraform, and since every Terraform provider uses different objects definitions, and every object definition is rather verbose, Dhall would be a way to specify my own DRY types and leave the provider-specific details in one place. Adding new DNS entries and moving several domains between providers would be a matter of changing fewer lines.

Dhall also has Kubernetes bindings:

https://github.com/dhall-lang/dhall-kubernetes

Although I'm tempted to just stick to Helm here: even though it's less type-safe, Dhall's verbosity makes me reconsider.

I'd like to hear if anyone has used dhall-kubernetes if they like it.

Best thing is Dhall that I am aware of. Same situation, working as a consultant, forced to use broken things.

https://github.com/dhall-lang/dhall-kubernetes

It's great if the system is built directly on top of it, e.g. spago. Not so much if you're trying to type yaml. Dhall is very opinionated, so trying to use it like TypeScript to type an untyped structure is... interesting.

E.g. for Kubernetes: https://github.com/dhall-lang/dhall-kubernetes

There's a Kubernetes plugin/package for Dhall [0] that can do this [1], it's very neat. I've played with it briefly, and whilst a tiny bit verbose (mostly as a function of the K8s specs themselves I suspect), the ability to have it validate everything before you even touched K8s was worth it imo.

[0] https://dhall-lang.org/ [1] https://github.com/dhall-lang/dhall-kubernetes

Huh, why build an entirely proprietary language for this? There are existing toolchains that bend existing rich configuration languages, like Nix [0] or Dhall [1], to produce Kubernetes object definitions. In this way, not only can existing libraries be leveraged, but no new semantics have to be learned, and no third party needs their palms crossed.

This had to be pointed out; Pulumi's docs repeat the adjective "real", as if its competitors aren't real. "real code", "real package management" [2], "real languages" [3], "real programming model" [4]... Nix and Dhall are quite real, though. So is this an incomplete survey, or are Pulumi's docs unrealistically self-aggrandizing? TBH even just this one paragraph of yours is pretty tough to stomach, as if loops and functions in a configuration language were a novel concept.

[0] https://github.com/xtruder/kubenix

[1] https://github.com/dhall-lang/dhall-kubernetes

[2] https://www.pulumi.com/docs/intro/vs/k8s_yaml_dsls/

[3] https://www.pulumi.com/docs/intro/vs/chef_puppet_etc/

[4] https://www.pulumi.com/docs/intro/vs/custom/

I'm trying to use it for Kubernetes since it can both work like helm (paramerizing functions) and kustomize (using the merge // operator). Moreover it has (safe) imports which make defining constants quite easy.

There are already kubernetes bindings available https://github.com/dhall-lang/dhall-kubernetes .

The syntax in the examples looks a bit more verbose and less readable than yaml but I think building sensible abstractions on top of it will alleviate the pain (abstractions here are innocuous since you can 'normalize' the code and they disappear)

I'm not too happy with the default formatting though. I think if the formatter indented nested values similar to yaml that would look better to the human eye.

Also check out https://dhall-lang.org

It's GCL but with a strong type system and termination guarantees.

I personally like the syntax a bit more than jsonnet. It's a bit less noisy.

I'm also a bit biased because I work on https://github.com/dhall-lang/dhall-kubernetes . We're currently working on a 2.0 release so the current state of the repo is a bit in turmoil.

Programmable configuration language like dhall an jsonet are very powerful and I like them way more than for example helm charts, where templating happens on the string level instead of at the data level.

This is a great analysis, but it's missing a fundamental point: why do we have a problem with these approximations of a programming language or just using a programming language to template stuff?

Because your build then becomes an actual program (i.e. Turing complete) and you have to refactor and maintain it! This is the common problem of using a "programming language as configuration" (e.g. gulp?)

Dhall solves exactly this problem: https://dhall-lang.org

It has the same premises of Pulumi, but without the Turing completeness (I don't know if/how Pulumi avoids that, but if it does it should be part of the pitch), so you cannot shoot yourself in the foot by building an abstraction castle in your build system/infrastructure config.

We use it at work to generate all the Infra-as-Code configurations from a single Dhall config: Terraform, Kubernetes, SQL, etc.

And there is already an integration with Kubernetes: https://github.com/dhall-lang/dhall-kubernetes

I didn't see this mentioned anywhere else, so another alternative (that I've seen and really like conceptually, but haven't used so far) to all this wildness with YAML and JSON -> https://github.com/dhall-lang/dhall-lang, and for kubernetes specifically -> https://github.com/dhall-lang/dhall-kubernetes
Dhall and its Kubernetes support are another potential option [1]. I am not using them yet, but looking to switch from helm templates to something that isn't just text mash-up but has modules and type-safety. Skycfg looks like a nice option to have: more main-stream for those used to Python or Bazel even if it is missing some of Dhall's interesting features (such as reduction).

[1]: https://github.com/dhall-lang/dhall-kubernetes

Dhall was such a godsend to make our infra configs more safe & modular (we jointly configure Kubernetes & Terraform with it).

If you need some example of use cases to see if it might help you, check out "Dhall in Production" [0]

So far I'm a maintainer of dhall-kubernetes [1] and we'll soon open source some of our integration with Terraform.

And because it's absolutely safe to distribute Dhall code I'm toying with the idea of making some kind of Dhall-Kafka pubsub, in which you can safely distribute Dhall code and data, with automatic version migrations (check this out for more info on why this is possible [2])

[0]: https://github.com/dhall-lang/dhall-lang/wiki/Dhall-in-produ...

[1]: https://github.com/dhall-lang/dhall-kubernetes

[2]: http://www.haskellforall.com/2017/11/semantic-integrity-chec...