How datalite/kube_build_app works
Project type and purpose
• This is an open-source, command-line Ruby gem whose sole purpose is to generate Kubernetes manifest files (Deployments, Services, Ingresses, ConfigMaps, etc.) from a simple directory of YAML “application” and “asset” descriptions. It is not a full-stack app but a focused CLI tool/library.
File structure
• bin/kube_build_app – the executable CLI stub
• lib/kube_build_app/main.rb – the top-level orchestrator that processes CLI args, reads environment/app descriptors, and invokes the generators
• lib/kube_build_app/application.rb – model for an application, holds metadata and references to containers, assets, service, ingress
• lib/kube_build_app/container.rb – models a container definition (image, env vars, ports, resources, probes)
• lib/kube_build_app/asset.rb – handles asset files, creates ConfigMaps
• lib/kube_build_app/service.rb & ingress.rb – model Service and Ingress resources
• lib/kube_build_app/env.rb – reads CLI “-e” environment descriptor, locates apps & assets directories
• lib/kube_build_app/kube_utils.rb & utils.rb – helper functions for marshaling to JSON/YAML, naming conventions, file I/O
• lib/kube_build_app/encjson.rb – JSON encoding helper
README for architectural clues
• Describes how a user populates environments/<env>/apps and environments/<env>/assets, then runs kube_build_app -e <env> -t <target_dir> to populate deployments/<env>/deploy with generated manifests.
• Implicit flow: parse YAML → build in-memory resource models → serialize to YAML → write to file system.
Main components & interactions
a. User/CLI layer
– User runs kube_build_app with flags
– OptionParser in main.rb
b. Core application layer (Ruby classes)
– Env: locates and parses input directories
– Application: aggregates Container + Asset + Service + Ingress
– Container: defines pod spec
– Asset: reads static files, builds ConfigMaps
– Service & Ingress classes: define networking specs
– KubeUtils/Utils: YAML serialization and file output
c. File-system abstraction
– Input: environments/<env>/apps/*.yml and environments/<env>/assets/*
– Output: deployments/<env>/deploy/{assets/,deployments/,services/}
d. (Optional) External integration
– Generated manifests are consumed by kubectl apply or CI/CD pipeline
Architectural patterns and design principles
• Single Responsibility: one Ruby class per Kubernetes resource type
• Modular layering: CLI entrypoint → environment loader → resource builders → file writers
• Convention over configuration: directory structure drives behavior
• Extensibility points: new resource generators can be added by following the existing class pattern