docs(homelab): overhaul operational guides and author core runbooks
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s
- Reclassify api-security-hardening into homelab/plans/ - Refactor appctl-architecture into appctl-operations-and-manifest-guide - Update dynu-ddns-troubleshooting with standalone ~/Core appliance paths - Author new guides: onboarding-a-new-service, managing-secrets-and-authelia-users, and server-maintenance-and-updates - Update homelab README catalog and repair internal plan links
This commit is contained in:
1 parent
f58d69ae9a
commit
bb6d61712f
15 files changed
+474
-309
No files matched your search
@@ -56,7 +56,7 @@ projects/
|
||||
**Key documents:**
|
||||
- [NixOS Fleet Overview](projects/nixos/README.md)
|
||||
- [Homelab Overview](projects/homelab/README.md)
|
||||
- [Dynu Monitor Overview](projects/homelab/dynu-monitor/README.md)
|
||||
- [Dynu Monitor Overview](projects/homelab/plans/dynu-monitor/README.md)
|
||||
- [New-Repo CLI Overview](projects/nixos/new-repo/README.md)
|
||||
- [MagNetFlix Overview](projects/magnetflix/README.md)
|
||||
- [Nekoweb Overview](projects/nekoweb/README.md)
|
||||
|
||||
+42
-22
@@ -11,15 +11,35 @@ This project documents the architectural roadmaps, infrastructure designs, deplo
|
||||
|
||||
---
|
||||
|
||||
## 📑 Plans & Execution Roadmaps
|
||||
---
|
||||
## 💬 Architectural Discussions ("Why & What If?")
|
||||
|
||||
Foundational inquiries, problem statements, and trade-off analyses that inform the homelab's direction:
|
||||
|
||||
1. [**NixOS Monorepo vs. Multi-Repo Architecture**](discussions/nixos-monorepo-vs-multirepo.md)
|
||||
- Evaluates coupling between workstation and server configurations; explores the trade-offs of single flake vs. standalone server appliance.
|
||||
2. [**Decoupling `nixos-config` and `homelab-core`**](discussions/nixos-monorepo-decoupling.md)
|
||||
- Analysis and file migration inventory for transferring the server definition into `homelab-core`.
|
||||
3. [**Gitea Git Credential Helper, Protocol Trade-Offs, and Backup Architecture**](discussions/gitea-credentials-and-backup-strategy.md)
|
||||
- Evaluates Git credential management, SSH vs. HTTPS, and primary (Gitea) vs. backup (GitHub) topology.
|
||||
|
||||
---
|
||||
|
||||
## 📑 Plans & Execution Roadmaps ("How & When?")
|
||||
|
||||
Phased implementation plans originating from architectural decisions:
|
||||
|
||||
### 🏛️ Core Architecture & Evolution
|
||||
1. 🟡 [**Architecture Consolidation & Hardening Roadmap**](plans/architecture-consolidation-roadmap.md) `[Active]`
|
||||
- Four-tier topology formalization, GitOps security hardening (closed dispatch enum), `app.yaml` schema contract, and invariant tests.
|
||||
2. 🟢 [**Turn `homelab-core` into a Declarative NixOS Appliance**](plans/nixos-appliance-migration.md) `[Completed]`
|
||||
- Execution plan that migrated the headless server configuration into a self-contained NixOS appliance.
|
||||
|
||||
### 🖥️ Server 24/7 & Infrastructure
|
||||
1. 🟢 [**NixOS Server & Laptop Migration**](plans/server-24-7/nixos-server-laptop-migration.md) `[Completed]`
|
||||
- Headless conversion of the server host and laptop workstation provisioning.
|
||||
- Declarative Flake management across `hosts/server` and `hosts/laptop`.
|
||||
2. 🟢 [**Domain Migration (`roadtotech.me`)**](plans/server-24-7/domain-migration-roadtotech.md) `[Completed]`
|
||||
- Cutover from legacy `arch-services.mywire.org` to apex `roadtotech.me`.
|
||||
- Wildcard SSL via Traefik ACME and Authelia cookie updates.
|
||||
3. 🟢 [**Production Folder Structure Reorganization**](plans/server-24-7/folder-structure-reorganization.md) `[Completed]`
|
||||
- Established strict production boundaries: `~/Core`, `~/Sites`, `~/Brain`, and `~/Config`.
|
||||
4. 🟡 [**LVM Storage Optimization & Partition Resizing Strategy**](plans/server-24-7/lvm-storage-optimization-and-resizing.md) `[Active]`
|
||||
@@ -27,7 +47,7 @@ This project documents the architectural roadmaps, infrastructure designs, deplo
|
||||
|
||||
### 📦 Orchestration (`appctl`)
|
||||
1. 🟢 [**Core & Sites Cutover and Testing Plan**](plans/appctl/core-sites-cutover-testing-plan.md) `[Completed]`
|
||||
- Zero-downtime, progressive cutover runbook from `~/Deployments` to decoupled `~/Core` and `~/Sites`.
|
||||
- Zero-downtime cutover runbook from `~/Deployments` to decoupled `~/Core` and `~/Sites`.
|
||||
2. 🟢 [**appctl Refactor & Decentralized `app.yaml` Metadata Architecture**](plans/appctl/refactor-and-metadata-sync.md) `[Completed]`
|
||||
- Decentralized service manifests, canonical aliasing, and Homepage `services.yaml` compilation.
|
||||
3. 🟢 [**appctl Git Synchronization & Full-Stack Lifecycle Strategy**](plans/appctl/git-sync-and-lifecycle.md) `[Completed]`
|
||||
@@ -43,25 +63,25 @@ This project documents the architectural roadmaps, infrastructure designs, deplo
|
||||
3. 🟡 [**GitHub to Gitea Automated Batch Migration Plan**](plans/gitea/github-to-gitea-migration-plan.md) `[Active]`
|
||||
- Batch migration automation (~35 repos) via `gh` and `tea` API, visibility retention, and recovery runbook.
|
||||
|
||||
---
|
||||
|
||||
## 📑 Canonical Guides & Production References
|
||||
|
||||
1. [**Homelab Architecture: Appctl & Decentralized Repositories**](guides/homelab-appctl-architecture.md)
|
||||
- The authoritative reference for `appctl`, `app.yaml` manifests, and multi-repo orchestration.
|
||||
2. [**Dynamic Decentralized GitOps Dispatcher Architecture**](guides/homelab-gitops-dispatcher-architecture.md)
|
||||
- Zero-Core-restart webhook architecture on port 9000, dynamic discovery, and deployment primitives.
|
||||
3. [**Brain GitOps & Auto-Sync Deployment Pipeline**](guides/brain-gitops-deployment-pipeline.md)
|
||||
- End-to-end knowledge graph pipeline: local pre-commit gate, post-commit push, Gitea Actions CI, and live doc2site rendering.
|
||||
4. [**Dynu DDNS Domain Configuration Troubleshooting Runbook**](guides/dynu-ddns-troubleshooting.md)
|
||||
- Root cause analysis and resolution for WAN IP rotations, SOPS key authorization, and `ddclient` updates.
|
||||
5. [**Custom API Security Hardening & Threat Analysis**](guides/custom-api-security-and-hardening.md)
|
||||
### 🔒 Security & Hardening
|
||||
1. 🟡 [**Custom API Security Hardening & Threat Analysis**](plans/api-security-hardening.md) `[Active]`
|
||||
- Attack surface review, Authelia ForwardAuth integration, rate limiting, and JWT fail-fast validation.
|
||||
6. [**WhatsApp & Telegram AI Assistant Backend Architecture**](guides/chatbot-assistant-backend-architecture.md)
|
||||
- Architecture, channel trade-offs (Telegram vs WhatsApp), APScheduler cron triggers, and Brain vault RAG integration.
|
||||
|
||||
---
|
||||
|
||||
## 🏛️ Architectural Discussions & Records
|
||||
* [Discussion: Gitea Git Credential Helper, Protocol Trade-Offs & Hybrid Backup Architecture](../../records/discussions/2026-09-gitea-git-helper-and-backup-strategy.md)
|
||||
* [Discussion: NixOS Monorepo vs. Multi-Repo Architecture for Homelab & Workstations](../../records/discussions/2026-09-nixos-monorepo-vs-multirepo-architecture.md)
|
||||
## 🛠️ Canonical Guides & Runbooks ("How to Use & Operate?")
|
||||
|
||||
Operational procedures and standard operating runbooks:
|
||||
|
||||
1. [**Onboarding a New Application Stack**](guides/onboarding-a-new-service.md)
|
||||
- Step-by-step procedure: directory setup in `~/Sites`, writing `app.yaml`, Traefik labels, and `appctl up`.
|
||||
2. [**Managing Secrets and Authelia Users**](guides/managing-secrets-and-authelia-users.md)
|
||||
- How to edit `nixos/secrets.yaml` with SOPS, generate Argon2 password hashes, and add users to Authelia.
|
||||
3. [**Server Maintenance and System Updates Runbook**](guides/server-maintenance-and-updates.md)
|
||||
- NixOS appliance upgrades, systemd post-update checklist, garbage collection, and Docker pruning.
|
||||
4. [**Appctl & Application Manifests (`app.yaml`) User Guide**](guides/appctl-operations-and-manifest-guide.md)
|
||||
- CLI reference for inspecting container health, managing stack lifecycles, and authoring `app.yaml`.
|
||||
5. [**Brain GitOps & Auto-Sync Deployment Pipeline**](guides/brain-gitops-deployment-pipeline.md)
|
||||
- How changes committed locally automatically push, validate in Gitea Actions, and deploy to `docs.roadtotech.me`.
|
||||
6. [**Dynu DDNS Domain Configuration Troubleshooting Runbook**](guides/dynu-ddns-troubleshooting.md)
|
||||
- Diagnostic steps for verifying WAN rotations, checking SOPS age keys, and forcing `ddclient` updates.
|
||||
+13
-5
@@ -9,12 +9,20 @@ tags:
|
||||
- git
|
||||
---
|
||||
|
||||
# 📦 Homelab Architecture: Appctl & Decentralized Repositories
|
||||
# 📦 Appctl & Application Manifests (`app.yaml`) User Guide
|
||||
|
||||
## 🎯 Architecture Model & Goals
|
||||
1. **Decoupled Application Repositories (`~/Sites`)**: Each application lives in an isolated, independently version-controlled Git repository containing its own Docker Compose stack and self-describing `app.yaml` manifest.
|
||||
2. **Hardened Control Plane (`~/Core`)**: Core reverse proxy (Traefik v3.6), authentication gateway (Authelia), container isolation (`socket-proxy`), management GUI (Portainer), and real-time logs (Dozzle).
|
||||
3. **Decentralized Metadata & Orchestration (`appctl`)**: Unified CLI tool powered by Python/Bash that dynamically parses `app.yaml` manifests, manages aliases, injects environment configurations, monitors Git repository synchronization, and auto-compiles the Homepage dashboard (`services.yaml`).
|
||||
This guide covers everyday operations for managing containerized applications in `~/Sites` using the `appctl` CLI and authoring self-describing `app.yaml` service manifests.
|
||||
|
||||
---
|
||||
|
||||
## 🎯 What `appctl` Does
|
||||
|
||||
`appctl` is the central orchestration CLI on the server. It:
|
||||
1. Discovers stacks in `~/Sites/` dynamically by scanning for `app.yaml`.
|
||||
2. Resolves service aliases (`appctl up docs` or `appctl up doc2site`).
|
||||
3. Injects shared environment variables and decrypted secrets from `/run/secrets/rendered/traefik-deployments.env`.
|
||||
4. Tracks real-time Git synchronization status (`ahead`, `behind`, `dirty`).
|
||||
5. Auto-compiles active services into the Homepage dashboard configuration (`homelab-dashboard/config/services.yaml`).
|
||||
|
||||
---
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- ai
|
||||
- chatbot
|
||||
- telegram
|
||||
---
|
||||
|
||||
# 🤖 WhatsApp & Telegram AI Assistant Backend Architecture
|
||||
|
||||
## 🎯 Motivation & Objectives
|
||||
Create a lightweight, self-hosted chatbot backend running on the `roadtotech.me` homelab cluster that serves as a personal AI assistant over messaging channels (Telegram / WhatsApp).
|
||||
|
||||
### Primary Capabilities:
|
||||
1. **Routine Reminders & Scheduled Alerts**: Cron-based triggers for study blocks, habits, and daily check-ins.
|
||||
2. **AI Engineering Coach & Job Advice**: Context-aware guidance drawing from the resident's curriculum notes (`~/Brain/knowledge`, `~/Brain/journal`, `~/Brain/practice`).
|
||||
3. **Quick Thought & Note Ingestion**: Send a text or voice memo to the bot to automatically append notes into `~/Brain/journal/` or `~/Brain/knowledge/parking-lot.md`.
|
||||
|
||||
---
|
||||
|
||||
## 🏛️ System Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ COMMUNICATION CLIENTS │
|
||||
│ [ Telegram Mobile App ] / [ WhatsApp Web/App ]│
|
||||
│ │ │ │
|
||||
└───────────────────┼─────────────────────────┼───────────┘
|
||||
│ (Webhook over HTTPS) │
|
||||
▼ ▼
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ TRAEFIK EDGE REVERSE PROXY (:443) │
|
||||
│ https://bot.roadtotech.me (Wildcard TLS) │
|
||||
└───────────────────────────┬─────────────────────────────┘
|
||||
│ (proxy-net)
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ HOMELAB ASSISTANT BACKEND (FastAPI / Python) │
|
||||
│ ~/Sites/homelab-assistant │
|
||||
│ │
|
||||
│ ┌────────────────────────┐ ┌────────────────────────┐ │
|
||||
│ │ APScheduler (Cron/Jobs)│ │ Auth & User Whitelist │ │
|
||||
│ │ - Daily Coaching (8am) │ │ - Reject unknown IDs │ │
|
||||
│ │ - Evening Journal Promp│ │ - Single-user security │ │
|
||||
│ └────────────────────────┘ └────────────────────────┘ │
|
||||
│ │
|
||||
│ ┌────────────────────────────────────────────────────┐ │
|
||||
│ │ Brain Vault Integration & LLM RAG │ │
|
||||
│ │ - Read access to ~/Brain │ │
|
||||
│ │ - LLM Engine: Ollama / Anthropic Claude / OpenAI │ │
|
||||
│ │ - Tool Use: Read notes, add to journal │ │
|
||||
│ └────────────────────────────────────────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚖️ Telegram Bot API vs. WhatsApp Cloud API
|
||||
|
||||
| Metric | Telegram Bot API 🌟 *(Recommended)* | WhatsApp (Cloud API / Baileys) |
|
||||
| :--- | :--- | :--- |
|
||||
| **Setup Friction** | ⚡ **30 Seconds**: Chat with `@BotFather`, get API token | ⚠️ High: Requires Meta Developer Account, Business Verification |
|
||||
| **Cost & Quotas** | 🆓 **100% Free**, unlimited messages | ⚠️ Paid conversation tiers after free monthly threshold |
|
||||
| **Formatting** | Full Markdown, inline buttons, audio, custom keyboards | Limited markdown, strict template rules for outbound messages |
|
||||
| **Outbound Cron Messages** | Send messages anytime without pre-approved templates | Requires pre-approved WhatsApp message templates |
|
||||
| **Security** | Simple user ID whitelist (only responds to your Telegram ID)| Phone number whitelist |
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Step-by-Step Implementation Roadmap
|
||||
|
||||
### Phase 1: Microservice Scaffolding (`~/Sites/homelab-assistant`)
|
||||
* FastAPI application with `python-telegram-bot` (or `aiogram`).
|
||||
* Secure webhook endpoint: `POST https://bot.roadtotech.me/webhook/telegram`.
|
||||
* User ID whitelist middleware: Ignore and drop any message not originating from your authorized Telegram User ID.
|
||||
|
||||
### Phase 2: APScheduler Proactive Notifications
|
||||
* Schedule recurring cron jobs:
|
||||
- **08:00 AM**: Daily focus milestone + morning coaching question.
|
||||
- **09:00 PM**: Evening reflection reminder.
|
||||
|
||||
### Phase 3: Brain Vault Tools & RAG
|
||||
* Connect the assistant with read/write access to `/home/kiskaadee/Brain`:
|
||||
- `/note <text>`: Appends entry to `~/Brain/journal/daily/YYYY-MM-DD.md`.
|
||||
- `/ask <question>`: RAG search across `~/Brain/knowledge` to answer questions about past study notes.
|
||||
@@ -174,37 +174,28 @@ creation_rules:
|
||||
# Store the server's private age key (-t allows interactive sudo password prompt)
|
||||
ssh -t server-local "sudo nix run nixpkgs#ssh-to-age -- -private-key -i /etc/ssh/ssh_host_ed25519_key"
|
||||
|
||||
SOPS_AGE_KEY=<previous output> sops updatekeys hosts/server/secrets.yaml
|
||||
SOPS_AGE_KEY=<previous output> sops updatekeys nixos/secrets.yaml
|
||||
```
|
||||
|
||||
**4. Edit Encrypted Secrets**:
|
||||
```shell
|
||||
sops hosts/server/secrets.yaml
|
||||
sops nixos/secrets.yaml
|
||||
```
|
||||
Set `dynu_domain` to:
|
||||
Ensure `dynu` credentials match your account:
|
||||
```yaml
|
||||
dynu_domain: roadtotech.me
|
||||
dynu:
|
||||
domain: roadtotech.me
|
||||
user: "your_username"
|
||||
password: "your_password"
|
||||
```
|
||||
|
||||
**5. Deploy and Rebuild to Server**:
|
||||
|
||||
A CI/CD pipeline has not been established yet. To apply the configuration, we'll trigger the upstream fetch via ssh and then rebuild the system.
|
||||
**5. Deploy and Rebuild Server Appliance**:
|
||||
To apply the configuration updates to the running server appliance:
|
||||
|
||||
```shell
|
||||
# Review flake status
|
||||
nix flake check
|
||||
|
||||
# Once local changes are synced with upstream
|
||||
ssh -t server-local \
|
||||
"cd Config && \
|
||||
git fetch && \
|
||||
git pull"
|
||||
|
||||
# rebuild the NixOS system
|
||||
ssh -t server-local \
|
||||
"cd Config && \
|
||||
sudo nixos-rebuild switch --flake .#server"
|
||||
|
||||
# Switch to the new generation on the server
|
||||
sudo nixos-rebuild switch --flake ~/Core#server
|
||||
# (or use the built-in alias: nix-switch)
|
||||
```
|
||||
|
||||
**6. Force One-Off DDNS Update**:
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- gitops
|
||||
- webhook
|
||||
- gitea
|
||||
- appctl
|
||||
- automation
|
||||
- architecture
|
||||
---
|
||||
|
||||
# 🚀 Dynamic Decentralized GitOps Dispatcher Architecture
|
||||
|
||||
## 🎯 Motivation & Core Invariants
|
||||
|
||||
In a modular homelab containing multiple containerized web applications (`~/Sites/*`), infrastructure control planes (`~/Core`), and data vaults (`~/Brain`), traditional centralized CI/CD configurations create unnecessary friction and blast radius.
|
||||
|
||||
The **Dynamic GitOps Dispatcher** is built around four fundamental architectural invariants:
|
||||
|
||||
1. **Zero Core Restarts (Decoupled Control Plane)**:
|
||||
Deploying a new application, onboarding a service, or updating deployment routines must **never require restarting or modifying Core infrastructure services** (Traefik, Authelia, Webhook daemon).
|
||||
2. **Decentralized Manifests (`app.yaml`)**:
|
||||
Each application repository in `~/Sites` owns and declares its own deployment lifecycle directly within its local `app.yaml` manifest.
|
||||
3. **Zero Schema Drift**:
|
||||
There are no centralized deployment tables or static hardcoded lists. The dispatcher discovers target directories and deployment strategies dynamically at runtime.
|
||||
4. **Graceful Data Vault Fallbacks**:
|
||||
Repositories without Docker Compose stacks (e.g. `second-brain` data vault) automatically execute clean fast-forward Git pulls (`git pull --ff-only origin <branch>`).
|
||||
|
||||
---
|
||||
|
||||
## 🏛️ System Architecture & Components
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph GitForge["1. Git Forge (Gitea)"]
|
||||
Push["Developer Git Push"]
|
||||
Webhook["HTTP POST (JSON Payload)\nhttp://192.168.1.36:9000/hooks/deploy"]
|
||||
Push --> Webhook
|
||||
end
|
||||
|
||||
subgraph CoreDaemon["2. Homelab Control Plane (NixOS systemd)"]
|
||||
Daemon["homelab-gitops.service\n(pkgs.webhook on port 9000)"]
|
||||
Engine["gitops_dispatcher.py\n(Dynamic Python 3 Engine)"]
|
||||
Webhook --> Daemon
|
||||
Daemon -->|Pipes JSON via stdin| Engine
|
||||
end
|
||||
|
||||
subgraph Discovery["3. Dynamic Target Resolution Engine"]
|
||||
Engine --> CheckType{"Resolve Payload"}
|
||||
CheckType -->|"second-brain"| BrainTarget["Target: ~/Brain\nAction: git pull --ff-only"]
|
||||
CheckType -->|"homelab-<app> / <app>"| SiteTarget["Target: ~/Sites/<app>\nRead local app.yaml"]
|
||||
CheckType -->|"Override Registry"| CustomTarget["Target: ~/.config/homelab/deployments.yaml"]
|
||||
end
|
||||
|
||||
subgraph Execution["4. Deployment Execution Lifecycle"]
|
||||
SiteTarget --> ReadManifest["Parse app.yaml (deployment block)"]
|
||||
ReadManifest --> Actions{"Execute Actions"}
|
||||
Actions -->|git_pull| GitPull["git pull --ff-only origin main"]
|
||||
Actions -->|compose_up| ComposeUp["docker compose up -d --remove-orphans"]
|
||||
Actions -->|compose_build| ComposeBuild["docker compose build && up -d"]
|
||||
Actions -->|compose_restart| ComposeRestart["docker compose restart"]
|
||||
Actions -->|custom| CustomCmd["Execute shell command"]
|
||||
end
|
||||
|
||||
subgraph LiveRuntime["5. Live Application State"]
|
||||
GitPull --> LiveApps["Container / Vault Updated Live (<2s)"]
|
||||
ComposeUp --> LiveApps
|
||||
ComposeBuild --> LiveApps
|
||||
CustomCmd --> LiveApps
|
||||
BrainTarget --> LiveApps
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧩 Key System Components
|
||||
|
||||
### 1. The Declarative Webhook Daemon (`pkgs.webhook`)
|
||||
The webhook listener is declared immutably via NixOS in [`Config/hosts/server/homeserver.nix`](file:///home/kiskaadee/Config/hosts/server/homeserver.nix):
|
||||
- **Port**: `9000` (Internal LAN / Tailscale only).
|
||||
- **Service Name**: `homelab-gitops.service`.
|
||||
- **Payload Handling**: Configured with `pass-arguments-to-command = [ { source = "entire-payload"; } ]`, passing the complete Gitea JSON event payload directly into the Python dispatcher arguments.
|
||||
|
||||
### 2. The Dynamic Dispatcher Engine ([`gitops_dispatcher.py`](file:///home/kiskaadee/Projects/active/homelab/homelab-core/scripts/gitops_dispatcher.py))
|
||||
A zero-dependency Python 3 engine executing on the server host:
|
||||
- Parses the repository name and ref (`branch`) from standard input.
|
||||
- Dynamically locates the target directory in `~/Sites` (matching `<repo>`, `homelab-<repo>`, or data vaults).
|
||||
- Parses `app.yaml` using a built-in lightweight YAML parser.
|
||||
- Sequentially executes declared deployment actions.
|
||||
|
||||
### 3. Application Manifest Standard (`app.yaml`)
|
||||
Placed in the root of each application repository in `~/Sites/<app>/app.yaml`:
|
||||
|
||||
```yaml
|
||||
name: "doc2site"
|
||||
aliases:
|
||||
- "docs"
|
||||
domain: "docs.roadtotech.me"
|
||||
description: "Documentation portal"
|
||||
visible: true
|
||||
auth: false
|
||||
|
||||
# Deployment Lifecycle Specification
|
||||
deployment:
|
||||
branch: "main" # Target branch to trigger on
|
||||
actions:
|
||||
- git_pull # 1. Pull latest commit via --ff-only
|
||||
- compose_up # 2. Run docker compose up -d --remove-orphans
|
||||
```
|
||||
|
||||
#### Available Deployment Actions:
|
||||
| Action | Execution Command | Use Case |
|
||||
| :--- | :--- | :--- |
|
||||
| `git_pull` | `git -C <dir> pull --ff-only origin <branch>` | Standard for code/content updates |
|
||||
| `compose_up` | `docker compose -f <file> up -d --remove-orphans` | Recreate containers with new config/env |
|
||||
| `compose_build` | `docker compose build && docker compose up -d` | Applications with local Dockerfiles |
|
||||
| `compose_restart`| `docker compose restart` | Quick container restart without recreation |
|
||||
| `custom: "<cmd>"`| `subprocess.run(cmd, shell=True)` | Custom database migrations or build scripts |
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ End-to-End Onboarding Guide for New Services
|
||||
|
||||
To onboard any new service into the automated GitOps deployment pipeline:
|
||||
|
||||
### Step 1: Create the Application Repository
|
||||
Create your repository on Gitea (e.g. `homelab-myapp` or `myapp`).
|
||||
|
||||
### Step 2: Add `app.yaml` Manifest
|
||||
In the root of your application repository, create `app.yaml`:
|
||||
```yaml
|
||||
name: "myapp"
|
||||
domain: "myapp.roadtotech.me"
|
||||
description: "My new homelab application"
|
||||
visible: true
|
||||
auth: true
|
||||
|
||||
deployment:
|
||||
branch: "main"
|
||||
actions:
|
||||
- git_pull
|
||||
- compose_up
|
||||
```
|
||||
|
||||
### Step 3: Clone to Server Host
|
||||
Clone the repository into `~/Sites` on the server:
|
||||
```bash
|
||||
git clone ssh://git@gitea.roadtotech.me:2223/kiskaadee/homelab-myapp.git ~/Sites/homelab-myapp
|
||||
```
|
||||
|
||||
### Step 4: Configure Webhook in Gitea
|
||||
1. In Gitea, navigate to **Repository Settings** $\rightarrow$ **Webhooks** $\rightarrow$ **Add Webhook** $\rightarrow$ **Gitea**.
|
||||
2. **Target URL**: `http://192.168.1.36:9000/hooks/deploy`
|
||||
3. **HTTP Method**: `POST`
|
||||
4. **Trigger On**: `Push Events`
|
||||
5. Click **Add Webhook**.
|
||||
|
||||
### Step 5: Test & Verify
|
||||
Push a commit from your workstation:
|
||||
```bash
|
||||
git commit -m "feat: initial feature release"
|
||||
git push origin main
|
||||
```
|
||||
The Gitea webhook fires $\rightarrow$ `gitops_dispatcher.py` pulls the update $\rightarrow$ Docker recreates containers $\rightarrow$ Service is updated live with zero manual SSH commands required.
|
||||
@@ -0,0 +1,130 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- sops
|
||||
- secrets
|
||||
- authelia
|
||||
- auth
|
||||
---
|
||||
|
||||
# 🔐 Managing Secrets and Authelia Users
|
||||
|
||||
This guide describes how to update encrypted runtime secrets, add or modify Authelia user accounts, and generate secure password hashes in the **Homelab Core** appliance.
|
||||
|
||||
---
|
||||
|
||||
## 🏛️ How Secrets Work in Homelab Core
|
||||
|
||||
All secrets are encrypted with [SOPS](https://github.com/getsops/sops) using [age](https://github.com/FiloSottile/age) keys and stored inside `nixos/secrets.yaml` in the `~/Core` repository.
|
||||
|
||||
At server boot, the `sops-nix` systemd module decrypts these secrets and renders them to RAM-backed environment files:
|
||||
- `/run/secrets/rendered/homeserver.env` — Consumed by Core infrastructure (Traefik, Authelia, Socket-Proxy).
|
||||
- `/run/secrets/rendered/traefik-deployments.env` — Consumed by application workloads via `appctl`.
|
||||
- `/run/secrets/rendered/users.yml` — The user database mounted into the Authelia container.
|
||||
|
||||
---
|
||||
|
||||
## 👤 Adding or Modifying Authelia Users
|
||||
|
||||
Authelia users are declared declaratively in `~/Core/nixos/modules/homeserver.nix`, while their password hashes are stored encrypted in `nixos/secrets.yaml`.
|
||||
|
||||
### Step 1: Generate an Argon2 Password Hash
|
||||
Run the official Authelia CLI in a temporary container to compute a secure Argon2id hash:
|
||||
|
||||
```bash
|
||||
docker run --rm -it authelia/authelia:latest authelia crypto hash generate argon2
|
||||
```
|
||||
Enter your password when prompted. The output will look like:
|
||||
```text
|
||||
$argon2id$v=19$m=65536,t=3,p=4$qH...
|
||||
```
|
||||
|
||||
### Step 2: Store the Password Hash in SOPS
|
||||
1. Navigate to the core repository:
|
||||
```bash
|
||||
cd ~/Core
|
||||
```
|
||||
2. Open the encrypted secrets file:
|
||||
```bash
|
||||
sops nixos/secrets.yaml
|
||||
```
|
||||
3. Add the user's password hash under `authelia.users`:
|
||||
```yaml
|
||||
authelia:
|
||||
users:
|
||||
newuser:
|
||||
password_hash: "$argon2id$v=19$m=65536,t=3,p=4$..."
|
||||
```
|
||||
4. Save and close. SOPS will re-encrypt the file automatically.
|
||||
|
||||
### Step 3: Register the User in `homeserver.nix`
|
||||
Open `nixos/modules/homeserver.nix` and add the user metadata to `autheliaUsers`:
|
||||
|
||||
```nix
|
||||
autheliaUsers = {
|
||||
# Existing users...
|
||||
|
||||
newuser = {
|
||||
displayName = "New User";
|
||||
email = "newuser@example.com";
|
||||
groups = [ "users" ]; # or [ "admins" "dev" ]
|
||||
passwordPlaceholder = config.sops.placeholder."authelia/users/newuser/password_hash";
|
||||
};
|
||||
};
|
||||
```
|
||||
Also register the secret key in `sops.secrets`:
|
||||
```nix
|
||||
sops.secrets = lib.genAttrs [
|
||||
# Existing secrets...
|
||||
"authelia/users/newuser/password_hash"
|
||||
] (name: { owner = "kiskaadee"; });
|
||||
```
|
||||
|
||||
### Step 4: Apply the Update
|
||||
Rebuild the NixOS server generation to regenerate `/run/secrets/rendered/users.yml` and reload Authelia:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch --flake ~/Core#server
|
||||
docker restart authelia
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Updating General Secrets (Tokens, DB Passwords, API Keys)
|
||||
|
||||
To update API keys or database passwords:
|
||||
|
||||
1. Open the encrypted file:
|
||||
```bash
|
||||
sops ~/Core/nixos/secrets.yaml
|
||||
```
|
||||
2. Edit the required value (e.g. `dynu/api_key`, `postgres/password`).
|
||||
3. Save and close.
|
||||
4. Apply changes to the host:
|
||||
```bash
|
||||
sudo nixos-rebuild switch --flake ~/Core#server
|
||||
```
|
||||
5. Restart affected container stacks using `appctl`:
|
||||
```bash
|
||||
appctl restart <service-name>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Troubleshooting Secret Decryption
|
||||
|
||||
If a container fails to start due to missing environment variables:
|
||||
1. Verify rendered secret files exist on the host:
|
||||
```bash
|
||||
sudo ls -la /run/secrets/rendered/
|
||||
```
|
||||
2. Inspect the content of the generated environment file:
|
||||
```bash
|
||||
sudo head /run/secrets/rendered/homeserver.env
|
||||
```
|
||||
3. Check `sops-nix` activation logs:
|
||||
```bash
|
||||
systemctl status sops-nix.service
|
||||
```
|
||||
@@ -0,0 +1,143 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- appctl
|
||||
- traefik
|
||||
- docker
|
||||
- onboarding
|
||||
---
|
||||
|
||||
# 🚀 Onboarding a New Application to the Homelab
|
||||
|
||||
This guide provides the complete, step-by-step procedure for deploying a new web service into the `roadtotech.me` homelab ecosystem, integrating it with the **Traefik** edge proxy, **Authelia SSO**, and the **`appctl`** orchestration tool.
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ The 4-Step Onboarding Workflow
|
||||
|
||||
Deploying a new application consists of 4 steps:
|
||||
1. **Create the application repository in `~/Sites/<app>`**
|
||||
2. **Author the `app.yaml` manifest**
|
||||
3. **Author the `docker-compose.yml` with Traefik routing labels**
|
||||
4. **Deploy and verify using `appctl`**
|
||||
|
||||
---
|
||||
|
||||
## Step 1: Create the Project Repository
|
||||
|
||||
All user applications reside in independent repositories under `/home/kiskaadee/Sites/`:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/Sites/homelab-myapp
|
||||
cd ~/Sites/homelab-myapp
|
||||
git init -b main
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 2: Author the `app.yaml` Manifest
|
||||
|
||||
Create `~/Sites/homelab-myapp/app.yaml`. This file describes your application metadata, CLI aliases, and presentation card for the Homepage dashboard:
|
||||
|
||||
```yaml
|
||||
name: "myapp"
|
||||
aliases:
|
||||
- "my-app"
|
||||
- "custom-app"
|
||||
domain: "myapp.roadtotech.me"
|
||||
description: "My New Self-Hosted Web Application"
|
||||
visible: true # Set to true to display on Homepage dashboard
|
||||
auth: true # Indicates Authelia protection is enabled
|
||||
|
||||
networks:
|
||||
- proxy-net
|
||||
|
||||
env:
|
||||
CUSTOM_SETTING: "standard_value"
|
||||
|
||||
homepage:
|
||||
title: "My App"
|
||||
group: "Tools & Utilities" # Dashboard category
|
||||
icon: "custom.png" # Icon name or URL
|
||||
container: "myapp"
|
||||
weight: 40 # Sort order in the dashboard
|
||||
|
||||
deployment:
|
||||
branch: "main"
|
||||
actions:
|
||||
- git_pull
|
||||
- compose_up
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 3: Author the `docker-compose.yml`
|
||||
|
||||
Create `~/Sites/homelab-myapp/docker-compose.yml`. Applications connect to Traefik via the external `proxy-net` Docker network.
|
||||
|
||||
### Example: Application with Authelia SSO Protection (`auth: true`)
|
||||
|
||||
```yaml
|
||||
services:
|
||||
myapp:
|
||||
image: myapp/image:latest
|
||||
container_name: myapp
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- proxy-net
|
||||
environment:
|
||||
- PORT=8080
|
||||
- DOMAIN_SUFFIX=${DOMAIN_SUFFIX:-roadtotech.me}
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
|
||||
# 1. Secure HTTPS Entrypoint
|
||||
- "traefik.http.routers.myapp.rule=Host(`myapp.${DOMAIN_SUFFIX:-roadtotech.me}`)"
|
||||
- "traefik.http.routers.myapp.entrypoints=websecure"
|
||||
- "traefik.http.routers.myapp.tls=true"
|
||||
- "traefik.http.routers.myapp.service=myapp-svc"
|
||||
|
||||
# 2. Attach Authelia SSO ForwardAuth Middleware
|
||||
- "traefik.http.routers.myapp.middlewares=authelia-auth@docker"
|
||||
|
||||
# 3. HTTP to HTTPS Automatic Redirect Router
|
||||
- "traefik.http.routers.myapp-red.rule=Host(`myapp.${DOMAIN_SUFFIX:-roadtotech.me}`)"
|
||||
- "traefik.http.routers.myapp-red.entrypoints=web"
|
||||
- "traefik.http.routers.myapp-red.middlewares=https-redirect@docker"
|
||||
|
||||
# 4. Target Service Port (inside the container)
|
||||
- "traefik.http.services.myapp-svc.loadbalancer.server.port=8080"
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
name: ${PROXY_NETWORK:-proxy-net}
|
||||
external: true
|
||||
```
|
||||
|
||||
> **Note on Public Apps**: If your app has its own native authentication (like Jellyfin or Gitea) or is public, simply omit the `authelia-auth@docker` middleware label.
|
||||
|
||||
---
|
||||
|
||||
## Step 4: Deploy and Verify with `appctl`
|
||||
|
||||
1. Validate the Compose syntax:
|
||||
```bash
|
||||
appctl config myapp
|
||||
```
|
||||
|
||||
2. Start the application stack:
|
||||
```bash
|
||||
appctl up myapp
|
||||
```
|
||||
*`appctl` automatically injects shared environment variables from `/run/secrets/rendered/traefik-deployments.env` and triggers `appctl sync` to register the new card in Homepage.*
|
||||
|
||||
3. Inspect running status and logs:
|
||||
```bash
|
||||
appctl info myapp
|
||||
appctl logs myapp
|
||||
```
|
||||
|
||||
4. Verify in the browser:
|
||||
Navigate to `https://myapp.roadtotech.me`. Traefik will negotiate a wildcard certificate automatically, and Authelia will prompt for credentials if gated.
|
||||
@@ -0,0 +1,125 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- nixos
|
||||
- maintenance
|
||||
- systemd
|
||||
- docker
|
||||
---
|
||||
|
||||
# 🛠️ Server Maintenance and System Updates Runbook
|
||||
|
||||
This runbook outlines routine maintenance procedures for the **Homelab Core** appliance, including NixOS system upgrades, service health verification, garbage collection, and Docker pruning.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Updating the NixOS Server Appliance
|
||||
|
||||
The server operating system is defined entirely inside `~/Core`.
|
||||
|
||||
### Step 1: Update Flake Inputs
|
||||
To fetch the latest versions of Nixpkgs and `sops-nix`:
|
||||
|
||||
```bash
|
||||
cd ~/Core
|
||||
nix flake update
|
||||
```
|
||||
|
||||
### Step 2: Validate the Build Dryly
|
||||
Always dry-build before switching to catch compilation, syntax, or package evaluation errors:
|
||||
|
||||
```bash
|
||||
nix flake check
|
||||
nix build .#nixosConfigurations.server.config.system.build.toplevel --no-link
|
||||
```
|
||||
|
||||
### Step 3: Switch to the New System Generation
|
||||
Once the dry build completes cleanly:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch --flake ~/Core#server
|
||||
# (or simply run: nix-switch)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🏥 Post-Update Health Checklist
|
||||
|
||||
Run this quick verification checklist following any system switch or server reboot:
|
||||
|
||||
1. **Systemd Daemon Health**:
|
||||
Ensure no core background units failed:
|
||||
```bash
|
||||
systemctl --failed
|
||||
```
|
||||
|
||||
2. **Core Homelab Stack**:
|
||||
Verify Traefik, Authelia, and the control plane containers are active:
|
||||
```bash
|
||||
systemctl status homeserver-core.service
|
||||
```
|
||||
|
||||
3. **Dynamic DNS (Dynu) Monitor**:
|
||||
Ensure the IP change detector timer and service are active:
|
||||
```bash
|
||||
systemctl status dynu-monitor.timer
|
||||
systemctl status dynu-monitor.service
|
||||
```
|
||||
|
||||
4. **GitOps Webhook Dispatcher**:
|
||||
Verify the webhook listener is listening on port 9000:
|
||||
```bash
|
||||
systemctl status homelab-gitops.service
|
||||
```
|
||||
|
||||
5. **Secrets Integrity**:
|
||||
Verify rendered environment files were generated in RAM:
|
||||
```bash
|
||||
sudo ls -la /run/secrets/rendered/
|
||||
```
|
||||
|
||||
6. **Application Workload Status**:
|
||||
Inspect the status of all application stacks:
|
||||
```bash
|
||||
appctl list
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧹 Disk Space Reclamation & Garbage Collection
|
||||
|
||||
Over time, older Nix generations, build artifacts, and Docker layers accumulate on disk. Follow this clean-up routine:
|
||||
|
||||
### 1. Collect Nix Garbage
|
||||
To prune unreachable store paths and older generations:
|
||||
|
||||
```bash
|
||||
# Delete older system generations (older than 7 days)
|
||||
sudo nix-env --delete-generations +7d --profile /nix/var/nix/profiles/system
|
||||
|
||||
# Prune the store
|
||||
sudo nix-collect-garbage -d
|
||||
```
|
||||
|
||||
### 2. Prune Unused Docker Resources
|
||||
Remove dangling container images, stopped containers, and build cache:
|
||||
|
||||
```bash
|
||||
# Prune dangling images and build cache safely
|
||||
docker system prune -a --volumes --filter "until=168h"
|
||||
```
|
||||
*(Only prunes containers stopped for longer than 7 days).*
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Emergency System Rollback
|
||||
|
||||
If a newly applied NixOS generation causes system issues:
|
||||
|
||||
```bash
|
||||
# Roll back to the previous generation immediately
|
||||
sudo nixos-rebuild switch --rollback
|
||||
```
|
||||
*(Or select the previous generation from the systemd-boot menu upon reboot).*
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
---
|
||||
type: guide
|
||||
type: plan
|
||||
status: active
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
@@ -93,4 +93,4 @@ appctl update --all
|
||||
---
|
||||
|
||||
## 🔗 Production Guide
|
||||
* [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/homelab-appctl-architecture.md)
|
||||
* [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/appctl-operations-and-manifest-guide.md)
|
||||
@@ -88,4 +88,4 @@ All 11 homelab applications will include an `app.yaml` defining their identity,
|
||||
---
|
||||
|
||||
## 🔗 Production Guide
|
||||
* [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/homelab-appctl-architecture.md)
|
||||
* [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/appctl-operations-and-manifest-guide.md)
|
||||
@@ -151,4 +151,4 @@ Configured under repository **Settings** $\rightarrow$ **Repository** $\rightarr
|
||||
|
||||
## 🔗 Related Production Guides
|
||||
* [Brain GitOps & Auto-Sync Deployment Pipeline](../../guides/brain-gitops-deployment-pipeline.md)
|
||||
* [Dynamic Decentralized GitOps Dispatcher Architecture](../../guides/homelab-gitops-dispatcher-architecture.md)
|
||||
* [Dynamic Decentralized GitOps Dispatcher Architecture](../../discussions/gitops-dispatcher-architecture.md)
|
||||
@@ -55,6 +55,6 @@ Rather than relying on continuous image polling via Watchtower, the homelab adop
|
||||
---
|
||||
|
||||
## 🔗 Production Guides & Specifications
|
||||
* [Dynamic Decentralized GitOps Dispatcher Architecture](../../guides/homelab-gitops-dispatcher-architecture.md)
|
||||
* [Dynamic Decentralized GitOps Dispatcher Architecture](../../discussions/gitops-dispatcher-architecture.md)
|
||||
* [Brain GitOps & Auto-Sync Deployment Pipeline](../../guides/brain-gitops-deployment-pipeline.md)
|
||||
* [GitHub to Gitea Automated Batch Migration Plan](github-to-gitea-migration-plan.md)
|
||||
@@ -19,7 +19,7 @@ Establish clear, unambiguous directory boundaries across both the Server and Lap
|
||||
## 🗺️ Realized Production Layout
|
||||
|
||||
> [!NOTE]
|
||||
> The initial proposal for a monolithic `~/Deployments` directory was superseded by the decoupled `~/Core` and `~/Sites` architecture documented in [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/homelab-appctl-architecture.md) and executed in [Core & Sites Cutover and Testing Plan](../appctl/core-sites-cutover-testing-plan.md).
|
||||
> The initial proposal for a monolithic `~/Deployments` directory was superseded by the decoupled `~/Core` and `~/Sites` architecture documented in [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/appctl-operations-and-manifest-guide.md) and executed in [Core & Sites Cutover and Testing Plan](../appctl/core-sites-cutover-testing-plan.md).
|
||||
|
||||
### 🖥️ Production Server Layout (`/home/kiskaadee/`)
|
||||
```text
|
||||
@@ -52,5 +52,5 @@ Establish clear, unambiguous directory boundaries across both the Server and Lap
|
||||
---
|
||||
|
||||
## 🔗 Related Documents
|
||||
* [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/homelab-appctl-architecture.md)
|
||||
* [Homelab Architecture: Appctl & Decentralized Repositories](../../guides/appctl-operations-and-manifest-guide.md)
|
||||
* [Core & Sites Cutover and Testing Plan](../appctl/core-sites-cutover-testing-plan.md)
|
||||
Reference in new issue
Block a user