13 ms·
Kubernetes YAML Generator
- Ciantic 6y agoLooks very useful. In my opinion the configuration format should have been built like this from the get go. Clear schema (like TypeScript interfaces or something similar) which allows generating an UI.
- q3k 6y agoAll of the standard Kubernetes resource definitions have a schema [1] [2] which is already used to, for instance, generate Go code [3] and documentation [4]. [1] - https://kubernetes.io/docs/concepts/overview/kubernetes-api/#api-specification https://kubernetes.io/docs/concepts/overview/kubernetes-api/... [2] - https://github.com/kubernetes/kubernetes/blob/release-1.19/api/openapi-spec/swagger.json https://github.com/kubernetes/kubernetes/blob/release-1.19/a... [3] - https://godoc.org/k8s.io/client-go/kubernetes/typed/core/v1 https://godoc.org/k8s.io/client-go/kubernetes/typed/core/v1 [4] - https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/ https://kubernetes.io/docs/reference/generated/kubernetes-ap...
- Ciantic 6y agoOf course there is schema at some level, but it feels like it's not utilized. This UI seems like very good use of schema. Another would be if I open up an VSCode, there should be a way to autocomplete / or give error squiggles if I write something wrong, in realtime.
- q3k 6y agoRight, but that's not as much of a Kubernetes issue as a VSCode issue. Everything's there for you to write something like this for your text editor, open source code doesn't grow on trees :).
- Ciantic 6y agoMy point being if k8s configuration was developed UI centrically, this problem would not exist in the first place. Because there would be official K8s GUI for configuration, one would not hunt and beg bits and pieces of docs every time editing a config file. As a side note, usually the schema languages fail at some point, thus I referred to TypeScript interfaces, which are very flexible way to write validation. There is already a schema support for JSON validation in VSCode, one can use it using `{ "$schema" : "https://example.com/url/toschema" https://example.com/url/toschema" }` but it uses JSON Schema format, which I think is not accurate enough in edge cases for UI generation.
- p_l 6y agoIf it was developed UI-centric, it would have failed much earlier to do anything useful. The real power of Kubernetes is that it has very simple basic model that allows building complex constructs out of simple pieces, and in fact basic help (which is even used for UI in kubectl explain. All the bits for good UI support are there.
- johncolanduoni 6y agoVSCode actually has such a plugin, though it has the hard to discover name “Kubernetes” and is maintained by the little-known “Microsoft”
- Schatel 6y agoAwesome! Was waiting for someone to build it :-)
- Niksko 6y agoOoooh nice! When I saw the title I was hoping this is what it would be. I'd dreamed of building something like this, but never had the time or the buy in. Aside from making it easy to generate k8s manifests, this could also be a great learning tool. If you allowed this to generate multiple resources that are linked, it could be a great illustration of how different resources fit together.
- 1ba9115454 6y agoWe're using Pulumi https://www.pulumi.com/ https://www.pulumi.com/ to do our K8 configuration. We can use TypeScript interfaces (which give us nice ide code completion) to define our yaml. we can then create functions where we would normally duplicate Yaml. Really nice. https://www.pulumi.com/kubernetes/ https://www.pulumi.com/kubernetes/
- throwaway894345 6y ago> we can then create functions where we would normally duplicate Yaml. This is the way to go for sure. I've done similar by generating CloudFormation from Python (I wrote my own library because I felt Troposphere was not very friendly nor a significant improvement over YAML). Typing turns out to be pretty useful when you're generating YAML. While my library was fully typed, Python's type checking left a lot to be desired--many stupidly common things still can't be expressed (JSON, kwarg callbacks, etc), getting mypy to find/accept type annotations for libraries is stupidly hard, and the IDE integrations are pretty awful at this point. TypeScript users would enjoy a real leg-up here since its type system isn't half baked.
- lima 6y ago> This is the way to go for sure. I've done similar by generating CloudFormation from Python (I wrote my own library because I felt Troposphere was not very friendly nor a significant improvement over YAML). Yes and no. Typing is a must, but a full-blown programming language is too powerful and all abstraction layers start to leak sooner rather than later. I always ended up with a "deployment" function that exposed almost all underlying functionality. We're big fans of the Cue (https://cuelang.org https://cuelang.org) approach instead: https://cuelang.org/docs/about https://cuelang.org/docs/about
- throwaway894345 6y agoIt depends. If you can reasonably trust your team to not to do I/O in the scripts, then you're fine. If you can't, then you should use something like Starlark (a subset of Python running in a constrained environment that precludes I/O, unbounded loops, etc); however, Starlark doesn't support types yet. I've looked at Cue a few times (principally out of frustration with the lack of types in Starlark), but I don't really "get it". What I want is a typed embeddable scripting language--specifically the ability to expressively generate YAML, and I'm pretty sure that's not what Cue is. I'm open to the argument that Cue is better than what I want (a la "if Henry Ford asked people what they really want, they'd've said faster horses"), but the value proposition isn't clear to me from perusing the docs. Maybe you can correct me?
- gravypod 6y agoSuper cool to see these sorts of tools. They're great for learning the kube API. For production-y things however, some meta-config language that allows deterministic templateing would be a huge improvement. It allows you to make sweeping/uniform infrastructure changes from a single library or tool change. Kubecfg is a good example of the basics one could implement [0] although it's examples aren't as fully fledged and organized as they could be. [0] - https://github.com/bitnami/kubecfg/blob/master/examples/guestbook.jsonnet https://github.com/bitnami/kubecfg/blob/master/examples/gues...
- q3k 6y agoI can second using jsonnet and kubecfg for this. Not only you start out with some very useful abstraction from kube.libsonnet, but are also able to build your own abstractions easily, ones that are specific to you organization/codebase/release cycle. All from a declarative, lazily evaluated, pure language.
- baq 6y agoheard good things about https://dhall-lang.org/# https://dhall-lang.org/#
- zingplex 6y agoI've used Dhall in production, pushed it fairly hard and can say with utmost certainty it's be an absolute pleasure. We use it as our application configuration format and derive fairly intricate Kubernetes resources from our app config. Although it is still in it's early days, it still is excellent to use and will only get better with additional tooling.
- k__ 6y agoHow does it differ from the CDK/CDK8s/terraform-cdk?
- zingplex 6y agoCDK uses existing fully featured programming languages that can preform side effecting actions thus lacking reproducibility and that are may not terminate. Dhall is a total language, meaning it will always terminate and a pure language, meaning that a function given an input will always yield the same output. That makes the output extremely predictable.
- paulstovell 6y agoWe built this internally to test that the UI we built for Kubernetes deployments was producing the expected YAML. Thought it would be useful to share.
- WalterSobchak 6y agoThanks for sharing this useful resource! Paul, as an aside, we absolutely love how feature packed Octopus is nowadays. We have been using it since 2.0, and I don't think we will ever give it up. Thanks for making one of the best tools we use a daily basis!
- paulstovell 6y agoThanks for the kind words!
- mfer 6y agoIf you print out the API docs for all the resources you might deal with for running apps at A4 (8.5 x 11) it comes in at over 1,000 pages. There is just so much and few really know it. A UI like this is useful to so many. It makes the experience of creating these YAML files easier. Thanks for sharing it.
- andendau 6y agoAny plans on open sourcing this or making the code available?
- burgerquizz 6y agoThis is awesome. It is so easy to make mistakes when configuring your k8s services
- Hamish156 6y agoWe built a similar thing and used in our graphical k8s designer : https://k8od.io/ https://k8od.io/.
- 1f60c 6y agoI don’t know how to feel about Kubernetes configuration apparently being so complicated that you need a generator for it, instead of just having the docs and your IDE open in split screen like with Docker Compose. That said, this still looks cool. I just hope we won’t need a Kubernetes configuration generator generator anytime soon.
- someguy101010 6y agoIts not complicated, which makes it easy to generate. No reason not to make things easier to work with if you can.
- p_l 6y agoIt's actually conceptually simpler than docker compose given what it does. The bigger issue is that there's a lot of things you can do with it, and editing text YAML/JSON serialization of the objects is probably one of the least efficient ways of dealing with it, but it's also the "default" way people know. It's much easier when your editor actually understands the object you're editing instead of at best helping you write correct YAML.
- deleted 6y ago[deleted]
- cmckn 6y agoKubernetes manifests are no different from any code one would write. The first few times you need to accomplish something, you consult the docs. After a while, you know what you need. If you find yourself doing the same thing over and over again, automate it. I don't understand the hand-wringing over k8s YAML.
- tn890 6y agoI wonder what the need for tools such as this or other "Kubernetes-by-example" type pages tell us about the complexity of configuring Kubernetes resources. Do we need a better layer of abstraction, i.e. better adoption and tighter integration for something like kustomize? Have we fucked up completely with Kubernetes due to it being outrageously complicated for simple tasks? How we redesign this to be simpler? Is the complexity even a problem for the target audience? I've no idea. I just know I'm a kubernetes admin and I can't write a deployment yaml without googling or copy/pasting.
- runbsd 6y agoA lot of other "bleeding edge" technologies that blow up and become difficult to use end up with new abstractions, and then abstractions for the abstractions, and the original problem the tool was meant to solve is now not the focus any longer.
- throwaway894345 6y agoI've always felt that Kubernetes isn't appropriate for most businesses to use directly, but rather it's a platform for simpler platforms--someone like Heroku would build on top of Kubernetes and expose a much simpler interface for their users so they don't have to think about SSL, DNS, logging, load balancing, auto-scaling, etc. Alternatively, maybe the problem is solved with "distributions" of Kubernetes analogous to Linux distros--preconfigured Kubernetes installations so you don't have to figure out how to configure your own Kubernetes service (arguably this is also what cloud providers give us with their managed k8s offerings). I'm curious to hear what others think.
- x87678r 6y agoWould be nice to have a linter or something that you know is best practice. Eg if you check your yaml and its more complex than it could be.
- programd 6y agoThere are a number of such tools out there. Here's a short list. I'd be interested in any experiences people have had with them in largish production environments. https://www.kubeval.com/ https://www.kubeval.com/ https://github.com/zegl/kube-score https://github.com/zegl/kube-score https://stelligent.github.io/config-lint/#/ https://stelligent.github.io/config-lint/#/ https://github.com/cloud66-oss/copper https://github.com/cloud66-oss/copper https://www.conftest.dev/ https://www.conftest.dev/ https://github.com/FairwindsOps/polaris#cli https://github.com/FairwindsOps/polaris#cli
- zegl 6y agoHey, I'm the author of kube-score, and originally built the tool to support an organization using Kubernetes at a fairly large scale as measured in number of engineers, services, and Kubernetes clusters. I'm obviously biased, but it's been hugely successful! kube-score is working very well out of the box, and there's only a handful of cases where the "ignore" annotation has been used to disable a check that's too strict for the particular use case. Feel free to reach out if you have any questions or comments.
- rglover 6y agoThis is great, thank you!
- turkenh 6y agoSelim
- turkenh 6y agoTürken
- emaildanwilson 6y agoAwesome work for the deployment resource! Now do this for all the other native k8s types and popular custom resources. :)
- elcritch 6y agoThat looks super handy! It seems like it'd be possible to "port" to VSCode. Some other comments mention autocomplete in VSCode, but it'd be nifty to run something like this directly in the VSCode UI.
- laurensr 6y agoIt would be nice if the tool could "import" an existing YAML and show the resulting configuration in the GUI.
- phyxx 6y agoThis exists with the "EDIT YAML" button now.