$ show next-hat/nanocl
Nanocl is a distributed container orchestration system designed as a Kubernetes alternative, focusing on simplicity and declarative state management. The system manages workloads termed 'Cargoes' (containers), 'VMs', and 'Jobs' using Docker as the underlying runtime. It features a client-server architecture with a CLI (`nanocl`), a central daemon (`nanocld`), and auxiliary sidecar services for proxying (`ncproxy`) and DNS (`ncdns`). The architecture relies on Rust for performance and safety, utilizing `ntex` for async HTTP handling and `diesel` for database persistence. The core operational model is driven by declarative Statefiles (YAML/TOML/JSON) processed with Liquid templating. These files define the desired infrastructure state, which the daemon reconciles against the actual runtime state. The system integrates directly with the Docker daemon via the `bollard` library to manage container lifecycles, networking, and images. It features a robust event-driven architecture where state changes trigger sidecar updates, such as Nginx configuration regeneration for routing. The codebase demonstrates a modular design with shared crates for error handling, stubs, and utilities. It implements a generic repository pattern for database access and abstract lifecycle traits for resource management. The API is versioned and documented via OpenAPI/Swagger, supporting RESTful CRUD operations and real-time event streaming. While the project shows strong architectural patterns, it carries medium technical drift due to API versioning fragmentation and heavy dependency on Docker API behavior.
The LLM identified 3 files worth highlighting for reuse:
Implements a generic `RepositoryReadBy` trait for Diesel ORM interactions. This component abstracts database queries across different resource types (Cargo, VM, Job), allowing for consistent CRUD operations without repeating SQL logic. It demonstrates high craftsmanship by providing a reusable abstraction for data access that can be applied to new resource types with minimal modification.
Defines the `ObjCreate` trait and its implementation for resource lifecycle management. This component encapsulates the logic for creating resources within the system, separating the creation logic from the specific resource types. It demonstrates non-obvious skill by providing a standardized interface for resource instantiation that handles validation and state transitions uniformly.
Provides a middleware for handling API versioning in the NTex web framework. This component allows the daemon to support multiple API versions simultaneously, ensuring backward compatibility while enabling feature evolution. It is a standalone utility that can be extracted and reused in other Rust web services requiring versioned API endpoints.