97 points · by jmillikin · 8y ago · 35 comments
I feel it has almost limitless flexibility, without requiring either boilerplate or complexity where you don't need it. Nothing else comes close in that regard.
https://jsonnet.org/ https://github.com/ksonnet/kubecfg Example real-world usage: https://github.com/anguslees/k8s-home
Gcl is terse, dead simple in most common areas. It appears the best general purpose configuration language I’ve seen so far.
And you can bet the person to write the configs of that service you inherited did enjoy seeing quite how far they could stretch the flexibility of GCL...
Also trrseness has nothing to do with complexity. Gcl did not have much language syntax sugar intended for terseness. It’s just naturally simple in choices of right abstractions.
If you are familiar with google’s piccolo this is closer to that.
Short summary: They're different but somewhat complementary tools. Kubecfg was made by Bitnami, Ksonnet by Heptio. Kubecfg uses Jsonnet and is less opinioned than Ksonnet, but (as far as I can see) can also use Ksonnet.
I wrote (and still maintain) kubecfg. Heptio joined the project and started adding lots of great stuff. Eventually it was clear they wanted to take it in a direction that was different to the original borgcfg-like vision. I suggested we split that new functionality into a different tool so we could keep exploring both directions without trying to mash both into the same cli flags. Hence ksonnet/kubecfg and ksonnet/ksonnet.
They both use jsonnet internally, generate the same k8s resources in the end, and have that common code heritage, so have many similarities.
ksonnet/ksonnet has a bunch of extra ("rails-like") tooling to hold your hand while you generate jsonnet, and assumes it uses the k.libsonnet library (https://github.com/ksonnet/ksonnet-lib).
ksonnet/kubecfg is much dumber and really just conceptually `jsonnet | kubectl apply`. In particular kubecfg avoids having any opinion about which jsonnet libraries you use. We use it extensively with https://github.com/bitnami-labs/kube-libsonnet, but you can also use it with https://github.com/ksonnet/ksonnet-lib or anything else that is valid jsonnet.
For Kubernetes you don't really want to write a program (one that calls this library) for every single Kubernetes deploy you want to do.
Seeing as Protobuf schemes are parseable, why not just have a command line tool that parses the schema, then combines it with the Starlark declarations to generate Kubernetes manifests?
It could be an interesting competitor to Ksonnet if done right.
The specific case of a sky-to-yaml utility binary is one we want to write (and have started in the `_examples/repl/` directory). Unfortunately go-protobuf doesn't support dynamic protobuf schemas yet (https://github.com/golang/protobuf/issues/199). Until it does, every message type must be linked directly into the binary.
I'd love to see a Helm-like tool built on Skycfg.
I'm really surprised that the Go Protobuf implementation doesn't support dynamic schemas, which seems like such a core feature, but looks like work is underway.
Syntax highlighting and formatting is nice, but I think error reporting is more important for the end user.
Zaml auto-validates configuration structure, removing the need to write most boilerplate on the programmer's side.
Can you help me understand Skycfg's type safety and validation? When I see `return [pb.StringValue(value = 123)]`, does this imply the schema is written inline, alongside the values?
For example, if you had this schema:
package my.example.schema;
message Person {
string name = 1;
int32 id = 2;
string email = 3;
}
Then you could build a value using Skycfg like this: pb = proto.package("my.example.schema")
msg = pb.Person(
id = 1234,
name = "Jane Doe",
email = "jdoe@example.com",
)
print(msg)
For Kubernetes, we're using the schema at https://github.com/kubernetes/api and for Envoy we use https://github.com/envoyproxy/data-plane-api/tree/master/env...Yaml is beautiful and easy, this looks like a nightmare.
5 notations for things, unclear whitespace delimiters, graph/labels, etc.
I'd love to learn more detail about how you've use skycfg with Terraform. Do Terraform module definitions drive the proto config (something we've considered)? Or does skycfg generate JSON or HCL? Thanks!
[0] https://www.terraform.io/docs/configuration/syntax.html#json...
[1] https://www.terraform.io/docs/providers/external/data_source...
This important for Stripe because we have lots of internal security boundaries. A rich configuration language that can't break out of its sandbox is useful when a highly-trusted system needs to expose a subset of its power to less trusted agents.
[0] More specifically, the Starlark language that Skycfg extends.
If I have 100 microservices, and I want to run all of them in a production and staging cluster, but I want all the staging cluster jobs to have an extra environment variable/tag and have lower CPU limits, there's no way to do that without 200 yaml files, which quickly get out of sync and inconsistent.
People use tools like Helm and Ksonnet because they allow you to write general-purpose manifests that can be parameterized. It's an extremely powerful tool. Our charts are full of things like this for that reason:
resources:
{{ if .Values.kubernetes.resources }}
requests:
{{ if .Values.kubernetes.resources.requests.cpu }}cpu: {{ .Values.kubernetes.resources.requests.cpu }}{{ end }}
{{ if .Values.kubernetes.resources.requests.memory }}memory: {{ .Values.kubernetes.resources.requests.memory }}{{ end }}
limits:
{{ if .Values.kubernetes.resources.limits.cpu }}cpu: {{ .Values.kubernetes.resources.limits.cpu }}{{ end }}
{{ if .Values.kubernetes.resources.limits.memory }}memory: {{ .Values.kubernetes.resources.limits.memory }}{{ end }}
{{ end }}
Or stuff like dynamically built ingresses: - host: {{ .Values.host }}
http:
paths:
{{ range .Values.apps }}
- path: {{ .path }}
backend:
serviceName: {{ .name }}
servicePort: 80
{{ end }}
Admittedly, templating sucks, and a tool like Skycfg or Jsonnet would be significantly better here, but the fundamental problem to solve is the same.I'm a big fan of configurator generators. I think it's wise to let apps be simple and rely o static, pre-baked configs (JSON, YAML, whatever), but a deployment system needs to be able to generate dynamic ones.