7 ms·
Better templating, example https://github.com/emcfarlane/kubestar https://github.com/emcfarlane/kubestar which uses starlark for kubernetes config.
by edwardmcfarlane 3y ago
Better templating, example https://github.com/emcfarlane/kubestar https://github.com/emcfarlane/kubestar which uses starlark for kubernetes config.
- tdubey 3y agoThe firm I work at developed an internal library (open source soon hopefully!) that does all our templating in Python, example: import os """ Imports redacted, but this imports our library """ NAME = "my_app" PORT = 5000 DEPLOY_ENV = os.environ["DEPLOY_ENV"] deploy_all( create_stateful_service( NAME, http_port=PORT, cpu=2000, memory=500 ), create_ingress( NAME, service_name=NAME, service_port=PORT, hostnames=["myapp.internal.com"], ), ) In the background, this converts a bunch of objects to YAML, leveraging the fact that objects in Python are just dictionaries. It then takes these objects and sends them to the K8S API. Really improved our DevEx since you can do complex tasks like "define a deployment, deploy it, and then check server status" because it is all just Python at the end of the day. Edit: formatting
- deleted 3y ago[deleted]
- edwardmcfarlane 3y agoNice, I've seen similar setups like this with Go before. Maybe that's the better way to do it, use a proper language instead of yamls for config.
- adql 3y agoIt should be like that from the very beginning, any and all configuration management systems that chose YAML as base instead of DSL (even if DSL is just a subset of Python or Lua) have same problems.
- polyrand 3y agoI was tinkering with a similar approach to this, using Python objects to generate the YAML. I'm not working in it right now, but I'd love to see other tools use this approach.
- hosh 3y agoI wrote something similar using Ruby a while back. https://github.com/matsuri-rb/matsuri https://github.com/matsuri-rb/matsuri I even have a helm plugin that would let you specify all the command line options and values so that it can be tracked in git and consistently applied There’s also tools for transforms on raw manifests so you can track changes (in code) from upstream manifests
- gburiola 3y agohttps://github.com/kapicorp/kapitan https://github.com/kapicorp/kapitan is also a very powerful option for managing and generating templates.
- 0xbadcafebee 3y agoWhat do you use templating for that made you not want to use Helm? Granted it's buggy as hell, but the fact that it automates so much operational process makes it save way more time over templating, in my experience.
- edwardmcfarlane 3y agoUsing Helm made me not want to use Helm! Joking, Helm is what I would use but still think there is a better way to do templating. This tool scratches that itch.
- verdverm 3y agoWe use CUE directly to generate yaml resources Have our eyes on Timoni https://github.com/stefanprodan/timoni https://github.com/stefanprodan/timoni
- edwardmcfarlane 3y agoCUE is really interesting in comparison with protobuffers with CEL. Thanks for linking the project.
- verdverm 3y agoyou're welcome, I also maintain https://cuetorials.com https://cuetorials.com