How martinmares/kube_build_app works
Project type and purpose
• This is a Ruby-based CLI tool (kube_build_app) whose sole purpose is to *generate* Kubernetes manifest YAML files from a simple directory structure of environment descriptors, application definitions and asset files.
• There is no long-running service, database or external API calls—this is a single-command, file-transformer tool.
File structure
• Top-level:
• bin/kube_build_app – the CLI entrypoint
• lib/kube_build_app/*.rb – core library code
• README.md, Gemfile, LICENSE, .gitignore
• Under lib/kube_build_app you see classes/modules:
• main.rb – coordinates the build
• application.rb, container.rb, service.rb, ingress.rb, asset.rb, env.rb
• kube_utils.rb, encjson.rb, utils.rb – shared helpers
• No database or HTTP server components; everything is file-based I/O.
README for additional insights
• The workflow reads:
• env.secured.json / env.unsecured.json – JSON environment variables
• environments/<env>/apps/*.yml – application descriptors
• environments/<env>/assets/* – static files (e.g. nginx.conf)
• Outputs to deployments/<env>/deploy/… directories:
– ConfigMaps, Deployments, Services, Ingresses
Main components
a. Inputs
• File System:
– JSON config files (env.*.json)
– YAML app descriptors
– Static asset files
b. Core Processing Modules
• bin/kube_build_app (CLI)
• KubeBuildApp::Main – parses flags, initiates build
• Env – loads JSON environment
• Application – loads app YAML, owns Container + Asset definitions
• Container, Asset, Service, Ingress – build object graph
• EncJSON, KubeUtils, Utils – support for encoding and rendering
c. Output
• File System writer: emits Kubernetes YAML (ConfigMap, Deployment, Service, Ingress) to deployments/<env>/deploy
d. External Dependencies
• Ruby stdlib and any gems in Gemfile (likely yaml, json)
• No live Kubernetes API calls—only file output
Relationships & interactions
1) CLI invocation
-> Main
2) Main
-> reads JSON via Env
-> scans environments/<env> for app YAML & assets
-> instantiates one Application object per YAML
3) Application
-> uses Container, Asset classes to model each container and asset
-> builds Service + Ingress definitions
4) Rendering
-> uses EncJSON & KubeUtils to produce correctly structured manifests
5) Writer
-> writes files into deployments/<env>/deploy/{assets,deployments,services}
Architectural patterns/design principles
• Modular object model: each Kubernetes concept is its own class
• Single responsibility: parsing, modeling and rendering are separated
• File-transformer CLI: no long-lived processes, purely input→object graph→output
• Convention over configuration: fixed directory conventions drive behavior