How mrsauravsahu/kube-homelab works
Main Components
a. Infrastructure Layer (Physical/Network):
• Hardware nodes: Raspberry Pi 4 and Raspberry Pi 5, Ubuntu Server running Docker.
• Operating system and prerequisites (systemd, key-based SSH, Docker).
b. Cluster Provisioning (Molecule: k3s):
• The “molecules/k3s” directory contains Terraform scripts for setting up k3s—a lightweight Kubernetes distribution.
• This module configures the control plane and node configuration.
c. Cluster Resources (Molecule: cluster-resources):
• The “molecules/cluster-resources” directory holds Terraform modules that define applications and other Kubernetes resources.
• It includes submodules for specific apps (e.g., Jellyfin, Nocodb, OwnCloud) and configuration for external services (Ingress controllers, databases, monitoring tools, etc.).
• It also makes use of Helm charts (e.g., in the “lib” and “apps” directories) for deploying some cluster applications.
d. Configuration & Deployment:
• Global configuration files (in “config”) and environment files (such as “.envrc” and “template.envrc”) for configuring Terraform backends or local state.
• CI/CD or deployment pipeline aspects might be implied by the segregation of modules/molecules.
Relationships and Interactions
• The system is structured in a layered manner where each layer depends on the components deployed in the prior, lower layer:
• The infrastructure layer (physical nodes) provides the underlying hardware and OS requirements.
• The k3s module sets up the Kubernetes cluster using Terraform.
• Once the cluster is ready, the cluster-resources module deploys various applications and service configurations on top of the running Kubernetes cluster.
• How Terraform orchestrates each molecule.
• The dependency of “cluster-resources” on the successful deployment of the “k3s” cluster.
• Interactions between external components (such as ingress controllers, databases, and external access endpoints) and the applications running inside the Kubernetes cluster.
Architectural Patterns and Key Principles
• Layered Architecture: Each deployment step (from infrastructure to cluster provisioning to running applications) is clearly separated.
• Modularity & Reusability: The use of “atoms” (small reusable pieces) and “molecules” (composed Terraform modules) allow for modular deployments.
• Infrastructure as Code (IaC): All configurations are defined in Terraform scripts with emphasis on structured module usage, environment segregation via separate backend state files, and clear file organization.
• Declarative Configuration: Both Kubernetes configurations (YAML files for pods, services, ingress, etc.) and Terraform definitions represent the desired state of the infrastructure.