2026-01-14 03:16:00 +00:00
|
|
|
# Layered Template Architecture System\n\nThis workspace provides a combined **Layered Extension Architecture with Override System** and **Template-Based Infrastructure Pattern Library** that maintains PAP principles while enabling maximum reusability of infrastructure configurations.\n\n## 🏗️ Architecture Overview\n\n### Layer Hierarchy\n\nThe system resolves configurations through a three-tier layer system:\n\n1. **Core Layer (Priority 100)** - `provisioning/extensions/`\n - Base provisioning system extensions\n - Core taskservs, providers, and clusters\n\n2. **Workspace Layer (Priority 200)** - `provisioning/workspace/templates/`\n - Shared templates extracted from proven infrastructure patterns\n - Reusable configurations across multiple infrastructures\n\n3. **Infrastructure Layer (Priority 300)** - `workspace/infra/{name}/`\n - Infrastructure-specific configurations and overrides\n - Custom implementations per infrastructure\n\n### Directory Structure\n\n```\nprovisioning/workspace/\n├── templates/ # Template library\n│ ├── taskservs/ # Taskserv configuration templates\n│ │ ├── kubernetes/ # Kubernetes templates\n│ │ │ ├── base.k # Base configuration\n│ │ │ └── variants/ # HA, single-node variants\n│ │ ├── storage/ # Storage system templates\n│ │ ├── networking/ # Network configuration templates\n│ │ └── container-runtime/ # Container runtime templates\n│ ├── providers/ # Provider templates\n│ │ ├── upcloud/ # UpCloud provider templates\n│ │ └── aws/ # AWS provider templates\n│ ├── servers/ # Server configuration patterns\n│ └── clusters/ # Complete cluster templates\n├── layers/ # Layer definitions\n│ ├── core.layer.k # Core layer definition\n│ ├── workspace.layer.k # Workspace layer definition\n│ └── infra.layer.k # Infrastructure layer definition\n├── registry/ # Extension registry\n│ ├── manifest.yaml # Template catalog and metadata\n│ └── imports.k # Central import aliases\n├── templates/lib/ # Composition utilities\n│ ├── compose.k # KCL composition functions\n│ └── override.k # Override and layer utilities\n└── tools/ # Migration and management tools\n └── migrate-infra.nu # Infrastructure migration tool\n```\n\n## 🚀 Getting Started\n\n### 1. Extract Existing Patterns\n\nExtract patterns from existing infrastructure (e.g., wuji) to create reusable templates:\n\n```\n# Extract all patterns from wuji infrastructure\ncd provisioning/workspace/tools\n./migrate-infra.nu extract wuji\n\n# Extract specific types only\n./migrate-infra.nu extract wuji --type taskservs\n```\n\n### 2. Use Enhanced Module Loader\n\nThe enhanced module loader provides template and layer management:\n\n```\n# List available templates\nprovisioning/core/cli/module-loader-enhanced template list\n\n# Show layer resolution order\nprovisioning/core/cli/module-loader-enhanced layer show\n\n# Test layer resolution for a specific module\nprovisioning/core/cli/module-loader-enhanced layer test kubernetes --infra wuji\n```\n\n### 3. Apply Templates to New Infrastructure\n\n```\n# Apply kubernetes template to new infrastructure\nprovisioning/core/cli/module-loader-enhanced template apply kubernetes-base new-infra --provider upcloud\n\n# Load taskservs using templates\nprovisioning/core/cli/module-loader-enhanced load enhanced taskservs workspace/infra/new-infra [kubernetes, cilium] --layer workspace\n```\n\n## 📋 Usage Examples\n\n### Creating a New Infrastructure from Templates\n\n```\n# 1. Create directory structure\nmkdir -p workspace/infra/my-new-infra/{taskservs,defs,overrides}\n\n# 2. Apply base t
|