diff --git a/README.md b/README.md index 019affb..1384e03 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,43 @@ -This repo bootstraps a hybrid kubeadm cluster, moves Kubernetes capacity onto -Pimox VMs, keeps bootstrap services on the Debian host, and hands app delivery -to Argo CD. +Jeannie manages three mutually exclusive Kubernetes profiles, keeps recovery +and build services on the Debian laptop, and delivers apps through Argo CD. +The current migration target is native K3s on the Orange Pi 5 Plus; the hybrid +and all-Pimox kubeadm profiles remain available. ## Quick Start -From the Debian server: +From the Debian operations laptop, select the profile and its kubeconfig +explicitly. For the enrolled native Orange Pi cluster: ```bash cd ~/my-homelab-configs -./jeannie up +export LAB_CLUSTER_PROFILE=k3s +export LAB_CLUSTER_RUNTIME=k3s +export TF_VAR_cluster_runtime=k3s +export KUBECONFIG="$HOME/.kube/opi5-k3s-config" +./jeannie cluster-context check +./jeannie cluster-runtime check ``` +On a fresh native installation, run `./jeannie cluster`, review and +enroll its identity, then run `./jeannie platform all` followed by +`./jeannie apps`. For the accidental laptop K3s installation, use the +[resumable transition](docs/deployment.md#move-laptop-k3s-to-the-orange-pi) +instead. Do not start a second deployment while that transition is running. + +| Profile | Control plane | Workers | Kubeconfig under `~/.kube/` | +| --- | --- | --- | --- | +| `debian` | Debian laptop `.73`, kubeadm | Pimox VMs 9010/9011 | `config` | +| `pimox` | Pimox VM 9001 at `.65`, kubeadm | Pimox VMs 9010/9011 | `pimox-config` | +| `k3s` | Orange Pi host `.80`, native K3s | Same host | `opi5-k3s-config` | + +Native K3s requires all Pimox VMs stopped. The VM profiles require host K3s +stopped; `debian` also requires VM 9001 stopped, and `pimox` requires the laptop +control plane stopped. Pipelines refuse conflicting or unverifiable runtimes. +The inventory still defaults to `pimox`; explicit selection prevents surprises. + ## Documentation Hub The detailed technical specifications have been moved to the `/docs` directory: @@ -23,7 +47,8 @@ The detailed technical specifications have been moved to the `/docs` directory: - [Deployment Guide](docs/deployment.md) - Prerequisites, bootstrap flow, and validation. - [AI Operations](docs/ai-ops.md) - Jeannie AI tools, Evals, and Safety cases. - [Application Ops](docs/app-ops.md) - App delivery, Gitea, and Website management. -- [Service Catalog](docs/service-catalog.md) - Live inventory of all hosts and services. +- [Service Catalog](docs/service-catalog.md) - Declared inventory of hosts and services. +- [Repository Code Map](docs/code-map.md) - Graphify findings and the code behind deployment guards. ## Inventory @@ -37,15 +62,20 @@ The canonical non-secret inventory is [homelab.yml](homelab.yml). Keep LAN IPs, - Debian remains the operations host: Jeannie, Docker builds, external Gitea, GitOps mirror, local registry endpoint, Ollama, OmniRoute, and the AI tool wrappers run there outside Kubernetes. -- Kubernetes workloads run on the Pimox VM cluster where practical. The current - target is three Debian arm64 VMs on the Orange Pi 5 Plus: one control-plane VM - and two worker VMs, each exposing two Kubernetes CPUs. +- The Orange Pi native K3s control plane has bootstrapped and reported `Ready`. + Platform installation and application rollout are separate milestones; a + Ready node does not establish that every service or data migration completed. +- Pimox remains installed alongside native K3s on the Orange Pi. The two modes + use the hardware at different times, preserving VM disks and existing data. - Pimox VMs are treated as rebuildable capacity. Jeannie owns the golden image, VM clone lifecycle, KVM CPU pinning for the Orange Pi big cores, qemu guest readiness waits, containerd registry trust, and stale node cleanup. - The canonical local image endpoint is the Debian LAN IP and registry NodePort (`192.168.100.73:30500` by default). Containerd pulls through that endpoint - even when the registry pod is running on a Pimox worker. + through forwarding to the selected registry node, including the Orange Pi. +- Identity checks pin API endpoint, CA fingerprint and `kube-system` UID. + Cluster, platform and app state live under separate per-profile directories; + scheduling feasibility uses requests, selectors, volumes and host ports. ## AI Stack diff --git a/README.md.tmpl b/README.md.tmpl index c0199a4..fa16492 100644 --- a/README.md.tmpl +++ b/README.md.tmpl @@ -2,19 +2,43 @@ -This repo bootstraps a hybrid kubeadm cluster, moves Kubernetes capacity onto -Pimox VMs, keeps bootstrap services on the Debian host, and hands app delivery -to Argo CD. +Jeannie manages three mutually exclusive Kubernetes profiles, keeps recovery +and build services on the Debian laptop, and delivers apps through Argo CD. +The current migration target is native K3s on the Orange Pi 5 Plus; the hybrid +and all-Pimox kubeadm profiles remain available. ## Quick Start -From the Debian server: +From the Debian operations laptop, select the profile and its kubeconfig +explicitly. For the enrolled native Orange Pi cluster: ```bash cd ~/my-homelab-configs -./{{ main_script }} up +export LAB_CLUSTER_PROFILE=k3s +export LAB_CLUSTER_RUNTIME=k3s +export TF_VAR_cluster_runtime=k3s +export KUBECONFIG="$HOME/.kube/opi5-k3s-config" +./{{ main_script }} cluster-context check +./{{ main_script }} cluster-runtime check ``` +On a fresh native installation, run `./{{ main_script }} cluster`, review and +enroll its identity, then run `./{{ main_script }} platform all` followed by +`./{{ main_script }} apps`. For the accidental laptop K3s installation, use the +[resumable transition](docs/deployment.md#move-laptop-k3s-to-the-orange-pi) +instead. Do not start a second deployment while that transition is running. + +| Profile | Control plane | Workers | Kubeconfig under `~/.kube/` | +| --- | --- | --- | --- | +| `debian` | Debian laptop `.73`, kubeadm | Pimox VMs 9010/9011 | `config` | +| `pimox` | Pimox VM 9001 at `.65`, kubeadm | Pimox VMs 9010/9011 | `pimox-config` | +| `k3s` | Orange Pi host `.80`, native K3s | Same host | `opi5-k3s-config` | + +Native K3s requires all Pimox VMs stopped. The VM profiles require host K3s +stopped; `debian` also requires VM 9001 stopped, and `pimox` requires the laptop +control plane stopped. Pipelines refuse conflicting or unverifiable runtimes. +The inventory still defaults to `pimox`; explicit selection prevents surprises. + ## Documentation Hub The detailed technical specifications have been moved to the `/docs` directory: @@ -23,7 +47,8 @@ The detailed technical specifications have been moved to the `/docs` directory: - [Deployment Guide](docs/deployment.md) - Prerequisites, bootstrap flow, and validation. - [AI Operations](docs/ai-ops.md) - Jeannie AI tools, Evals, and Safety cases. - [Application Ops](docs/app-ops.md) - App delivery, Gitea, and Website management. -- [Service Catalog](docs/service-catalog.md) - Live inventory of all hosts and services. +- [Service Catalog](docs/service-catalog.md) - Declared inventory of hosts and services. +- [Repository Code Map](docs/code-map.md) - Graphify findings and the code behind deployment guards. ## Inventory @@ -37,15 +62,20 @@ The canonical non-secret inventory is [homelab.yml](homelab.yml). Keep LAN IPs, - Debian remains the operations host: Jeannie, Docker builds, external Gitea, GitOps mirror, local registry endpoint, Ollama, OmniRoute, and the AI tool wrappers run there outside Kubernetes. -- Kubernetes workloads run on the Pimox VM cluster where practical. The current - target is three Debian arm64 VMs on the Orange Pi 5 Plus: one control-plane VM - and two worker VMs, each exposing two Kubernetes CPUs. +- The Orange Pi native K3s control plane has bootstrapped and reported `Ready`. + Platform installation and application rollout are separate milestones; a + Ready node does not establish that every service or data migration completed. +- Pimox remains installed alongside native K3s on the Orange Pi. The two modes + use the hardware at different times, preserving VM disks and existing data. - Pimox VMs are treated as rebuildable capacity. Jeannie owns the golden image, VM clone lifecycle, KVM CPU pinning for the Orange Pi big cores, qemu guest readiness waits, containerd registry trust, and stale node cleanup. - The canonical local image endpoint is the Debian LAN IP and registry NodePort (`192.168.100.73:30500` by default). Containerd pulls through that endpoint - even when the registry pod is running on a Pimox worker. + through forwarding to the selected registry node, including the Orange Pi. +- Identity checks pin API endpoint, CA fingerprint and `kube-system` UID. + Cluster, platform and app state live under separate per-profile directories; + scheduling feasibility uses requests, selectors, volumes and host ports. ## AI Stack diff --git a/apps/demos-static/public/homelab-catalog/index.html b/apps/demos-static/public/homelab-catalog/index.html index 7786e74..3b599cc 100644 --- a/apps/demos-static/public/homelab-catalog/index.html +++ b/apps/demos-static/public/homelab-catalog/index.html @@ -45,7 +45,7 @@ public-edge

oci_edge

Address: 132.145.170.74

-

Tailscale: 100.118.255.19

+

Tailscale: 100.122.188.79

Storage: n/a

diff --git a/apps/website/README.md b/apps/website/README.md index d84ce2d..57119a5 100644 --- a/apps/website/README.md +++ b/apps/website/README.md @@ -36,6 +36,23 @@ through to PHP so the translation workflow continues to work. are served by `visitor_ideas.php` and loaded by `visitor-ideas.js`, which keeps the blog page cacheable while preserving the write path through `save_idea.php`. +## Blog content and architecture + +Keep `blog.php`, `homelab-tree.php` and `lang/en.php` aligned with +`homelab.yml` and [the code map](../../docs/code-map.md). The blog distinguishes +the three exclusive cluster profiles and the confirmed native-node readiness +milestone from still-unverified platform/app rollout completion. + +`lang_helper.php` merges localized strings over the English dictionary. Revised +operational entries currently use that fallback where old Nahuatl translations +described a topology that is no longer current. Refresh those translations +against the updated English source; do not retain stale infrastructure claims. +Adding an activity or stack entry also requires adding its key in `blog.php`. + +Website changes require the normal image build and app delivery path to refresh +pre-rendered pages and immutable OPcache. Editing these sources does not update +the running site, and a deployment should wait for the current transition to end. + ## Cache Path The website sets cache headers for pre-rendered HTML: diff --git a/apps/website/blog.php b/apps/website/blog.php index 0458a47..537ee68 100644 --- a/apps/website/blog.php +++ b/apps/website/blog.php @@ -21,6 +21,10 @@ $activityKeys = [ 'blog_activity_17', 'blog_activity_18', 'blog_activity_19', + 'blog_activity_20', + 'blog_activity_21', + 'blog_activity_22', + 'blog_activity_23', ]; $todoKeys = [ @@ -64,6 +68,8 @@ $stackKeys = [ 'blog_stack_20', 'blog_stack_21', 'blog_stack_22', + 'blog_stack_23', + 'blog_stack_24', ]; $caseStudyCards = [ @@ -202,6 +208,15 @@ $stackSourceLinks = [ ['label' => 'Pimox docs', 'path' => 'bootstrap/provisioning/README.md'], ['label' => 'containerd repair flow', 'path' => 'lib/jeannie/pipeline.sh'], ], + 'blog_stack_23' => [ + ['label' => 'runtime guard', 'path' => 'scripts/cluster-runtime-guard.py'], + ['label' => 'cluster identity', 'path' => 'scripts/cluster-context.py'], + ['label' => 'code map', 'path' => 'docs/code-map.md'], + ], + 'blog_stack_24' => [ + ['label' => 'native transition', 'path' => 'scripts/cluster-transition.py'], + ['label' => 'registry reconciliation', 'path' => 'scripts/registry-storage-reconcile.py'], + ], ]; function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $sourceBase): void { @@ -338,7 +353,7 @@ function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $so
Homelab architecture map - Git push enters Gitea, Gitea Actions validates and builds app images, OpenTofu manages cluster and provisioning layers, Debian keeps the control plane, PXE services, and Ollama translation model, Pimox app workers run Argo CD, Kyverno, Redis-backed website translation, n8n workflow automation, and app workloads on NVMe-backed VMs, OpenWrt can run as an opt-in firewall VM, and the OCI edge routes traffic into Kubernetes services. + Debian hosts Gitea, build and recovery tools, and Ollama. Jeannie selects one exclusive Kubernetes profile: laptop kubeadm with Pimox workers, an all-Pimox kubeadm cluster, or native K3s on the Orange Pi. The native Orange Pi node has reported Ready; platform and app rollout completion are separate milestones. Identity, scheduling and retained-storage checks guard deployment. The OCI edge connects through Tailscale, and OpenWrt is available only in VM mode. @@ -349,10 +364,10 @@ function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $so Source, validation, and images - Control plane and provisioning + Profiles and deployment guards - Workers, edge, and workloads + Hosts, edge, and workloads @@ -390,37 +405,37 @@ function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $so OpenTofu + jeannie - manual infra apply path - apps command for CI deploys + pinned identity and scoped state + runtime and scheduling checks - PXE + preseed service + VM profile provisioning dnsmasq TFTP, nginx HTTP Debian 13 arm64 netboot - golden-node prep scripts + skipped for native K3s - kubeadm control plane - API server and control loops - workloads pushed to app workers + One active cluster profile + debian / pimox / k3s + native K3s or kubeadm topology - GitOps mirror + Validated Git revision validated commit copied locally - Argo CD reads deploy state + Argo reads configured Git repo GitOps + policy controllers Argo CD and Kyverno - pinned to app workers + placement follows live topology @@ -448,31 +463,31 @@ function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $so Tailscale + edge routes - 30080 website, 30081 demos - 3000 Gitea on Raspberry Pi + Traefik LAN LoadBalancer + Gitea and API stay on Debian - Raspberry Pi 192.168.100.89 + Debian laptop .73 external Gitea Docker service - optional edge-app worker - repo home and backup source + Jeannie, builds, AI and backups + Raspberry Pi: DNS and uptime - Orange Pi 5 Plus Pimox - pimox-worker app nodes - template VMs; storage optional - Argo CD, Kyverno, website, n8n - Redis cache and app workloads + Orange Pi 5 Plus .80 + native K3s: opi5plus Ready + or retained Pimox VMs + never native K3s plus VMs + platform then app readiness OpenWrt firewall VM - VM 9050, opt-in only + VM mode only; opt-in vmbr0 WAN, vmbr1 LAN simple firewall path DHCP optional, VLANs later @@ -482,7 +497,7 @@ function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $so Local registry :30500 php-website and demos-static - pulled by app workers + forward to selected registry node @@ -519,7 +534,7 @@ function renderStackSourceLinks(string $stackKey, array $sourceLinks, string $so manual infra validated Git serve boot - join path + VM profiles Pimox template firewall VM policy + GitOps diff --git a/apps/website/homelab-tree.php b/apps/website/homelab-tree.php index dbbb766..ecc7fc5 100644 --- a/apps/website/homelab-tree.php +++ b/apps/website/homelab-tree.php @@ -179,9 +179,9 @@ $blogHref = 'blog.php?lang=' . urlencode($lang); - Debian - control plane - 192.168.100.73 + opi5plus + native K3s + 192.168.100.80 @@ -202,7 +202,7 @@ $blogHref = 'blog.php?lang=' . urlencode($lang); Raspberry Pi - arm64 worker + DNS + uptime @@ -245,9 +245,9 @@ $blogHref = 'blog.php?lang=' . urlencode($lang);
  • Branches: Kubernetes namespaces and workloads that carry the visible services.
  • Ornaments: external Gitea, Actions, Argo CD, Buildx, Trivy, Gitleaks, Calico, registry, website, and demos.
  • Bells: probes and health checks that make noise before users do.
  • -
  • Trunk: the Debian control-plane node that holds the platform upright.
  • +
  • Trunk: native K3s on the Orange Pi. The Debian and Pimox kubeadm layouts remain alternative profiles; only one runs at a time.
  • Roots: OpenEBS retained volumes, external SSD storage, Gitea dumps, and restore discipline.
  • -
  • Gifts: the OCI edge host, Raspberry Pi worker, monitoring ideas, and the improvement backlog.
  • +
  • Gifts: the OCI edge host, Raspberry Pi support services, monitoring, and the improvement backlog.
  • diff --git a/apps/website/lang/en.php b/apps/website/lang/en.php index c888535..efec66d 100644 --- a/apps/website/lang/en.php +++ b/apps/website/lang/en.php @@ -93,7 +93,7 @@ return [ 'blog_kicker' => 'Homelab field notes', 'blog_title' => 'I accidentally built a tiny CI/CD platform', - 'blog_subtitle' => 'A case-study style walkthrough of how a Debian operations host, all-Pimox Kubernetes VMs, external Gitea, local registry, Kyverno policy, Argo CD, monitoring, static demos, and a Debian-hosted AI stack became a repeatable delivery system.', + 'blog_subtitle' => 'A homelab delivery platform with three exclusive cluster profiles: hybrid kubeadm, all-Pimox kubeadm, and native K3s on the Orange Pi 5 Plus. Debian keeps Git, builds, AI tools and recovery available while the cluster changes.', 'case_studies_kicker' => 'Portfolio case studies', 'case_studies_title' => 'Production-shaped evidence', 'case_studies_intro' => 'These are the three proof points a hiring manager should see first: platform ownership, production reliability at scale, and the reserved MLOps path for model-serving work.', @@ -113,30 +113,30 @@ return [ 'blog_speaker_answer' => 'Me, holding coffee', 'blog_q1' => 'Be honest: why build all this instead of just running a couple containers like a normal person?', 'blog_a1' => 'Because apparently I looked at "host a website" and thought, "what if this had a control plane, GitOps, retained storage, an image registry, and several new ways to embarrass myself?" The real goal was practice: provision the infra, keep config in Git, deploy with automation, break it, fix it, and make sure I could rebuild it without relying on shell history and vibes.', - 'blog_q2' => 'Why kubeadm? Were managed clusters too emotionally stable?', - 'blog_a2' => 'Pretty much. kubeadm keeps the cluster close to the metal, which is a polite way of saying I get to see every sharp edge. The Debian node runs the control plane, the Raspberry Pi joins as an arm64 worker, and Pimox on an Orange Pi 5 Plus now gives me a repeatable way to add Debian 13 arm64 VM workers. Suddenly networking, storage, container runtimes, certs, and node recovery are not mysterious cloud magic. They are my problem.', + 'blog_q2' => 'Did the cluster really need three VMs to host a website?', + 'blog_a2' => 'The VMs taught me a lot about kubeadm, scheduling, networking and recovery. They also gave a small lab more moving parts to debug. I kept both kubeadm layouts, then added native K3s on the Orange Pi host. The profiles are debian for a laptop control plane with VM workers, pimox for the entirely virtual cluster, and k3s for the native host. One runs at a time; the laptop stays the operations machine.', 'blog_q3' => 'So where is the CI/CD part hiding?', - 'blog_a3' => 'It is small, but it is real. OpenTofu brings up the cluster, platform, apps, and edge layers. Argo CD watches Git from the app workers, Kyverno keeps policy pressure on the workloads, Docker Buildx builds amd64 and arm64 images, and the local registry feeds the cluster. No enterprise dashboard fireworks, just a clean loop: Git changed, image built, cluster updated, nobody had to kubectl-edit anything at 2 AM.', + 'blog_a3' => 'OpenTofu owns cluster, platform and app setup. Argo CD reads the configured private Git repository, Buildx creates amd64 and arm64 images, and Kyverno supplies policy checks. Before deployment, Jeannie verifies cluster identity, checks competing runtimes, and estimates scheduling from resource requests, selectors, volumes and ports. A green CPU-usage graph alone does not mean the scheduler can fit another pod.', 'blog_q4' => 'Why run your own registry and Gitea? Was the simple option unavailable?', 'blog_a4' => 'The simple option was very available, which is why I heroically ignored it. The registry means experiments do not need to go to a public image repo, and external Gitea gives the lab its own Git service without making Kubernetes responsible for its own source of truth. Together they make the setup feel less like "some containers under the stairs" and more like a tiny platform with opinions, responsibilities, and occasionally dramatic storage needs.', 'blog_q5' => 'What actually hurt the most?', 'blog_a5' => 'Storage. Always storage. Kubernetes, Docker, retained volumes, and build caches can fill a small root disk with the quiet confidence of a bad decision. Moving OpenEBS local volumes and Docker data to the external SSD turned the lab from "why is everything on fire?" into "okay, this is usable now." Growth, allegedly.', - 'blog_q6' => 'So the platform controllers finally moved off the control plane?', - 'blog_a6' => 'Yes. Argo CD and Kyverno now target the homelab.dev/node-role=app workers, including Kyverno hook jobs, so the Debian node can stay focused on control-plane duties. That one change made the lab feel less like everything was balanced on the first machine that happened to boot.', + 'blog_q6' => 'Where do the platform controllers run now?', + 'blog_a6' => 'Placement follows the selected topology. Multi-node profiles keep platform workloads on labeled workers; the single-node K3s profile labels the selected Orange Pi control plane for platform work. The pipeline must inspect the live cluster instead of insisting that a VM worker from an older deployment exists. State, identity and scheduling checks stay shared across the three profiles.', 'blog_q7' => 'Can the current cluster actually handle all that, or are we about to smoke the Pi?', - 'blog_a7' => 'The Pi survives because the demos are intentionally local-first and now ship as a separate static artifact. The website pod stays a portfolio shell, the demos-static pod serves static bundles, and the user browser does the expensive work. If I later ship real ONNX object detection, Transformers.js, or full video transcoding models, those must lazy-load in the browser or move to a beefier node. The Raspberry Pi is brave, but it is not a GPU wearing a tiny hat.', + 'blog_a7' => 'The website and demos stay deliberately small, with expensive demo work in the browser. Native K3s can use the Orange Pi host resources without a VM allocation boundary, but the OS and background services still need their share. Capacity claims come from the live node, not the size printed on the box. The node is Ready; successful platform and app rollouts are separate checks.', 'blog_q8' => 'So the lab can now build its own worker nodes?', 'blog_a8' => 'Yes, and now with fewer crossed fingers. Debian runs a provisioning layer with dnsmasq, nginx, PXE boot files, GRUB, and a Debian 13 arm64 preseed. OpenTofu talks to Pimox through qm, creates VM 9000 on local storage, boots it from the network, installs the OS, runs golden-node prep, disables swap, verifies cgroups, installs containerd and kubeadm tooling, then seals it as a template. Worker clones are idempotent by VMID when a stable non-local Pimox datastore is available.', 'blog_q9' => 'And OpenWrt is joining the story too?', - 'blog_a9' => 'Only as a simple firewall, not as a networking science project. The pipeline can create an opt-in OpenWrt ARM SystemReady VM, attach vmbr0 as WAN and vmbr1 as LAN, and configure the LAN side without rewriting Orange Pi host networking. DHCP stays optional, and VLANs wait until there is a managed switch and a local test window.', + 'blog_a9' => 'OpenWrt remains an optional VM experiment in the kubeadm modes. Native K3s requires every Pimox VM stopped, so its pipeline skips OpenWrt startup. Pimox, its VM disks and vmbr0 remain in place. Switching back is a runtime transition, not permission to erase the hypervisor or run both modes together.', 'blog_q10' => 'What changed on the observability and scheduling side?', - 'blog_a10' => 'Monitoring moved from "someday" to "running," and scheduling moved from "whatever fits" to explicit worker placement. Prometheus Stack, Grafana, Loki, Promtail, node-exporter, and kube-state-metrics give the lab useful signals; the next useful step is choosing the few alerts that would actually wake me up for the right reasons.', + 'blog_a10' => 'The scheduler cares about reservations, placement and local volumes, not only current CPU consumption. Prometheus and Grafana once remained Pending because their retained storage pointed at a fully reserved one-core worker. The pipeline now estimates feasibility before applying, handles initial operator bootstrap separately, and still waits for actual readiness afterward. Old evicted pods are cleanup targets; a live Pending pod needs its scheduling cause fixed.', 'blog_stack_title' => 'Technologies and why they are here', - 'blog_stack_1' => 'Debian Linux is the steady adult in the room: control plane host, deployment workstation, PXE/preseed server, and the place where OpenTofu, Docker, kubeadm, and the scripts do their thing.', - 'blog_stack_2' => 'Raspberry Pi keeps the external Gitea service close to the lab on SSD-backed /data, while Pimox on the Orange Pi 5 Plus can provide an app-worker pool when its VM storage is stable. The HP Debian laptop now owns the NVMe-backed data-vg storage for Kubernetes data paths.', + 'blog_stack_1' => 'The Debian laptop is the operations host: Jeannie, external Gitea, image builds, AI tools, backups and recovery stay outside Kubernetes. It is a kubeadm control plane only when the debian profile is selected; native K3s belongs on the Orange Pi.', + 'blog_stack_2' => 'The Orange Pi 5 Plus retains Pimox and its VM disks while also supporting a native K3s profile. Host K3s and the VMs do not run together. The Raspberry Pi supplies support services such as DNS and uptime monitoring; external Gitea now runs on Debian.', 'blog_stack_3' => 'OpenTofu makes the cluster, platform, apps, edge, and provisioning layers repeatable, because "I swear I remember the command" is not a disaster recovery strategy.', - 'blog_stack_4' => 'Calico handles pod networking, and OpenEBS hostpath storage keeps the important data around after rebuilds, because deleting everything by accident is only funny once.', - 'blog_stack_5' => 'Argo CD is the GitOps referee and now runs on app workers: manifests live in Git, the cluster follows along, and manual drift gets side-eyed back into place.', + 'blog_stack_4' => 'Calico supplies pod networking and OpenEBS supplies local storage. A retained local volume remains tied to its host and path: switching cluster profiles does not move its data. The native transition copies registry data explicitly and preserves other old laptop volumes for a separate restore.', + 'blog_stack_5' => 'Argo CD reconciles apps from the configured private Git repository. Its placement follows the live profile: labeled workers for multi-node clusters, or the selected native control plane for a single-node cluster.', 'blog_stack_6' => 'The OCI edge host runs nginx, HAProxy, Varnish, and Squid so TLS, routing, HTTP/2, keepalive, gzip, and caching stay outside the home network while Tailscale carries traffic back to Traefik.', 'blog_stack_7' => 'The shared theme toggle is plain CSS and JavaScript: dark mode uses an old-console green-on-black treatment, while light mode switches to black cursive on ivory across the website and demo catalog.', 'blog_stack_8' => 'The first demo keeps files in the browser. Image crunching uses native Canvas APIs today, while the fast serious path for video conversion is Rust compiled to WebAssembly with a TypeScript UI.', @@ -146,22 +146,22 @@ return [ 'blog_stack_12' => 'The Pimox worker pipeline uses qm over SSH to create an OVMF/virtio-scsi Debian 13 arm64 VM, wait for qemu-guest-agent, seal it, and convert VM 9000 into a reusable template on local storage.', 'blog_stack_13' => 'The golden image bakes in Kubernetes prerequisites: swap disabled, cgroup boot options checked, kernel modules loaded, containerd configured for systemd cgroups, kubeadm/kubelet/kubectl installed, and qemu-guest-agent enabled.', 'blog_stack_14' => 'Worker clone automation is count-based and idempotent: LAB_PIMOX_WORKER_COUNT=1 means ensure VM 9010 exists, not create a fresh worker on every run. New workers are refused if the target storage is local.', - 'blog_stack_15' => 'OpenWrt is handled separately from the Debian golden-node template. The lab downloads the upstream ARM SystemReady EFI image, imports it onto selected non-local Pimox storage, and keeps it disabled unless LAB_OPENWRT_VM=true is set.', - 'blog_stack_16' => 'The monitoring layer now includes Prometheus Stack, Grafana, Loki, Promtail, node-exporter, and kube-state-metrics, with placement guardrails so platform add-ons stop defaulting to the control plane.', + 'blog_stack_15' => 'OpenWrt is an opt-in firewall VM for VM mode. Native K3s skips it and refuses any running Pimox VM; the pipeline preserves the existing bridge and disks.', + 'blog_stack_16' => 'Prometheus Stack, Grafana, Loki, Promtail, node-exporter and kube-state-metrics make up the monitoring layer. Scheduling estimates include resource reservations and volume placement; live rollout checks determine whether the services actually started.', 'blog_stack_17' => 'The portfolio website keeps Apache at the core, runs PHP through PHP-FPM with OPcache, pre-renders read-heavy pages into static HTML during the image build, and leaves PHP for write and translation endpoints.', 'blog_stack_18' => 'The supply-chain path now uses BuildKit SBOM attestations, Cosign signatures, a cluster-published public key, and an audit-first Kyverno ImageValidatingPolicy that can be promoted to deny unsigned local-registry pods.', 'blog_stack_19' => 'The translation path now uses Redis for per-string cache hits, a custom Ollama website-translator model on the Debian server for cache misses, n8n for prewarming and batch workflow automation, and structured logs for cache, latency, JSON parse, and timeout signals.', 'blog_stack_20' => 'The AI stack is Debian-hosted by design: OmniRoute runs in Docker Compose under /data/homelab-ai-stack, seeds OpenRouter and NVIDIA keys locally, creates free/no-auth provider routes, validates real completions, and writes model hints for the tools.', 'blog_stack_21' => 'Goose, Holmes, and Hermes stay installed as bare-metal tools with Jeannie wrappers. That means doctor-k8s can collect read-only Kubernetes evidence and ask Holmes for triage even when the cluster itself is the broken component.', - 'blog_stack_22' => 'The Pimox migration turned the Orange Pi 5 Plus into rebuildable Kubernetes capacity: three Debian arm64 VMs, big-core KVM pinning, containerd 2.x registry trust, known-host refresh, imagefs cleanup, and app rollouts that do not depend on manual node edits.', + 'blog_stack_22' => 'The Pimox profiles preserve the learning path: golden-image preparation, VM lifecycle, big-core pinning, guest readiness, containerd registry trust and recovery. Native K3s offers a simpler runtime on the same Orange Pi without discarding those VM environments.', 'blog_arch_kicker' => 'Architecture map', 'blog_arch_title' => 'The homelab, end to end', - 'blog_arch_intro' => 'The current delivery path starts with a push to Gitea, runs local validation, builds arm64 images, syncs the validated commit into the GitOps mirror, and lets Argo CD reconcile from the app workers. The infrastructure path stays manual through jeannie, including the PXE/Pimox template builder, NVMe-backed worker clones, Kyverno policy placement, Redis-backed website translation, n8n workflow automation, and the opt-in OpenWrt firewall VM, while the OCI edge routes public traffic back through the private path.', - 'blog_arch_caption' => 'The diagram is intentionally operational: it shows the app delivery loop, image flow, provisioning path, worker-placement boundary, monitoring layer, Redis/n8n/Ollama translation path, OpenWrt firewall option, and public traffic path without hiding the practical bits that make a small lab behave like a platform.', + 'blog_arch_intro' => 'Git, builds, AI and recovery stay on Debian. Jeannie selects one of three Kubernetes layouts and checks identity, runtime exclusivity, scheduling and retained storage before changing it. The native Orange Pi K3s node has reported Ready; its platform and application rollout is tracked separately. The OCI edge still reaches services over Tailscale.', + 'blog_arch_caption' => 'The three profiles are alternatives, not simultaneous clusters. VM provisioning and OpenWrt belong to VM mode; native K3s uses the Orange Pi host directly. Retained disks and data survive mode changes, but storage moves require an explicit verified copy or restore.', 'blog_arch_fun_link' => 'Open the Christmas-tree version', 'blog_activity_kicker' => 'Recent activity log', 'blog_activity_title' => 'What changed since the first build', - 'blog_activity_intro' => 'The lab moved from a working Kubernetes experiment into a more complete self-hosted delivery system. The latest work focused on trust, repeatability, VM-based expansion, controller placement, measured website performance, and deploys that match the exact commit that passed validation.', + 'blog_activity_intro' => 'These entries describe successive stages of the lab, not services that all run at once. The latest milestone is native K3s reporting Ready on the Orange Pi after retiring the accidental laptop installation. Platform and apps still need their own completion checks.', 'blog_activity_1' => 'Moved Gitea out of Kubernetes and onto the Raspberry Pi as the local Git service, while keeping the public /git/ route through the edge stack.', 'blog_activity_2' => 'Installed and validated a Debian-hosted Gitea Actions runner so pushes to main can build, scan, and deploy without depending on a laptop session.', 'blog_activity_3' => 'Added a custom checkout flow for the /git/ subpath and kept a persistent Debian checkout for the deployment scripts.', @@ -184,17 +184,17 @@ return [ 'blog_todo_kicker' => 'Improvement backlog', 'blog_todo_title' => 'Todo list for the next homelab pass', 'blog_todo_intro' => 'These are improvement proposals, not chores for the sake of chores. Each item either reduces rebuild risk, tightens supply-chain hygiene, or makes the platform easier to operate when something fails.', - 'blog_todo_1' => 'Move Gitea data from the Raspberry Pi SD card to SSD-backed storage.', - 'blog_todo_2' => 'Keep the Debian bare GitOps mirror as the cluster source and add object-storage backups when OCI storage is ready.', + 'blog_todo_1' => 'Verify restore drills for the Debian-hosted Gitea data and keep recovery available while any Kubernetes profile is stopped.', + 'blog_todo_2' => 'Verify backups and restores for the configured Git source, retained local volumes and OCI object-storage targets before relying on a rebuild.', 'blog_todo_3' => 'Add a real OpenTofu remote state backend with backup, locking, and a documented recovery path.', 'blog_todo_4' => 'Replace the remaining mutable latest image references with immutable tags or digest pins for demo workloads; the website image now uses a content-hash tag.', 'blog_todo_5' => 'Move the Cosign private key into Vault or another secret manager so the runner no longer owns long-lived signing material on disk.', 'blog_todo_6' => 'Add Renovate or Dependabot-style dependency updates for base images, Helm charts, and GitHub/Gitea Actions.', 'blog_todo_7' => 'Expand Kyverno baseline policy coverage: non-root, read-only roots, resource requests, allowed registries, and documented exceptions for platform components.', - 'blog_todo_8' => 'Turn the installed observability stack into useful operations views: a few high-signal dashboards, alerts for node health, storage pressure, certificate expiry, and failed app syncs.', + 'blog_todo_8' => 'Finish native-profile platform and app validation, then verify useful alerts and scrape targets instead of treating a Ready node as a completed monitoring rollout.', 'blog_todo_9' => 'Schedule backup restore drills for external Gitea and OpenEBS volumes, then write the exact restore runbook.', 'blog_todo_10' => 'Tighten TLS, SSH, and token rotation around the OCI edge, Gitea, registry, and runner credentials.', - 'blog_todo_11' => 'Document the new storage split: local for the Pimox template, data-vg on the HP Debian laptop for Kubernetes app data, Raspberry Pi SSD /data for Gitea and Docker, and backup targets for anything that must survive a rebuild.', + 'blog_todo_11' => 'Restore any needed non-registry laptop PVC data explicitly, document its new host and path, and verify that switching profiles cannot bind the wrong local volume.', 'blog_todo_12' => 'Move sensitive app configuration into Sealed Secrets, External Secrets, or another explicit secret-management path.', 'blog_todo_13' => 'Test the OpenWrt VM in a maintenance window before making it a gateway: confirm WAN, LAN, rollback access, DHCP settings, and that Pimox remains reachable.', 'blog_todo_14' => 'Buy or configure a managed switch before VLAN work. Until then, keep OpenWrt as a simple two-interface firewall and avoid risky remote bridge rewrites.', @@ -248,4 +248,10 @@ return [ 'demo_mlops_label' => 'Demo 09', 'demo_mlops_title' => 'MLOps Deployment Platform', 'demo_mlops_desc' => 'Placeholder for the serious MLOps showcase: inference service, Kubernetes rollout, metrics, drift signals, and rollback workflow.', + 'blog_stack_23' => 'Cluster identity is pinned to API endpoint, CA fingerprint and kube-system UID. Each profile has separate cluster, platform and app state; a shared runtime lock and host probes block conflicting deployments.', + 'blog_stack_24' => 'The laptop-to-native transition is resumable. It verifies the old identity, stops laptop K3s workloads, archives state and datastore, copies a checksum-verified registry onto the Orange Pi, verifies the new identity over SSH, and then sequences platform and apps.', + 'blog_activity_20' => 'Added per-profile state and pinned API endpoint, CA fingerprint and namespace UID so an old kubeconfig cannot silently redirect a deployment into another cluster.', + 'blog_activity_21' => 'Added scheduling feasibility checks and runtime exclusion across the debian, pimox and k3s profiles. One-core workers are assessed by actual capacity and reservations rather than a fixed two-core requirement.', + 'blog_activity_22' => 'Retired accidental laptop K3s with retained state and datastore backups, preserved the source registry, and copied verified registry data to the Orange Pi before native K3s startup. Other old laptop PVC data stays preserved locally.', + 'blog_activity_23' => 'On November 2, 2026, the native opi5plus node at 192.168.100.80 reported Ready. Platform and apps remain separate rollout milestones; a Ready node alone does not prove either is finished.', ]; diff --git a/apps/website/lang/nah.php b/apps/website/lang/nah.php index 7017456..290cd8d 100644 --- a/apps/website/lang/nah.php +++ b/apps/website/lang/nah.php @@ -1,4 +1,5 @@ 'Juvenal Diaz', 'job_title' => 'Hueyi tequitini: DevOps, MLOps ihuan tlatecpanaliztli', @@ -93,7 +94,6 @@ return [ 'blog_kicker' => 'Homelab tlahcuilolli', 'blog_title' => 'Tlatecpanaliztli homelab CI/CD pipeline', - 'blog_subtitle' => 'Case-study style tlahcuilolli: quen Debian operations host, all-Pimox Kubernetes VMs, external Gitea, local registry, Kyverno policy, Argo CD, monitoring, static demos, ihuan Debian-hosted AI stack omocuepque repeatable delivery system.', 'case_studies_kicker' => 'Portfolio tlamantli', 'case_studies_title' => 'Evidence quen production', 'case_studies_intro' => 'Inin yeyi proof points ma quitta hiring manager achto: platform ownership, production reliability at scale, ihuan reserved MLOps path para model-serving tequitl.', @@ -113,30 +113,18 @@ return [ 'blog_speaker_answer' => 'Nehuatl, coffee ipan noma', 'blog_q1' => 'Melahuac: tleica niquichihua nochi inin ihuan ahmo zan ome containers quen normal person?', 'blog_a1' => 'Pampa onciquitta "host a website" ihuan oniquilhuia: "tlein panos tla inin quipia control plane, GitOps, retained storage, image registry, ihuan miec yancuic ways para nimopinahuiz?" Melahuac goal catca practice: provision infra, quipia config ipan Git, deploy ika automation, xitlapana, xicyecana, ihuan xiquitta tla huel rebuild ahmo ika shell history ihuan vibes.', - 'blog_q2' => 'Tleica kubeadm? Managed clusters catca too emotionally stable?', - 'blog_a2' => 'Quena. kubeadm quicahua cluster nechca metal; in polite way quitosnequi niquita nochi sharp edge. Debian node quipia control plane, Raspberry Pi joins quen arm64 worker, ihuan Pimox ipan Orange Pi 5 Plus quimaca repeatable Debian 13 arm64 VM workers. Suddenly networking, storage, container runtimes, certs, ihuan node recovery amo cloud magic: no problema.', 'blog_q3' => 'Canin motlatia CI/CD part?', - 'blog_a3' => 'Tepiton, zan real. OpenTofu quichihua cluster, platform, apps, ihuan edge layers. Argo CD quitta Git ipan app workers, Kyverno quimaca policy pressure, Docker Buildx quichihua amd64 ihuan arm64 images, ihuan local registry quimaca cluster. Clean loop: Git mopatla, image omochiuh, cluster updated, ahmo aca monequi kubectl-edit 2 AM.', 'blog_q4' => 'Tleica own registry ihuan Gitea? Simple option amo oncatca?', 'blog_a4' => 'Simple option huel oncatca, ic heroic oniquignore. Registry quitosnequi experiments amo monequi yasque public image repo, ihuan external Gitea quimaca lab own Git service ahmo quichihua Kubernetes responsible para source of truth. In ome quichihua setup ma nesi quen tepiton platform ika opinions, responsibilities, ihuan storage drama.', 'blog_q5' => 'Tlein achi cualani?', 'blog_a5' => 'Storage. Nochipa storage. Kubernetes, Docker, retained volumes, ihuan build caches huel quitemitia root disk ika quiet confidence of bad decision. Moving OpenEBS local volumes ihuan Docker data ipan external SSD quicuep lab de "tleica nochi tlatla?" ica "okay, axcan huel tlatequipanoa." Growth, supposedly.', - 'blog_q6' => 'Platform controllers finally moved off control plane?', - 'blog_a6' => 'Quena. Argo CD ihuan Kyverno axcan target homelab.dev/node-role=app workers, including Kyverno hook jobs, para Debian node ma mocahua focus ipan control-plane duties. Inin change quichihua lab ma nesi amo nochi balanced ipan achto machine in boot.', 'blog_q7' => 'Current cluster huel quipia nochi inin, o tiquchichinos Pi?', - 'blog_a7' => 'Pi survives pampa demos cateh intentionally local-first ihuan now ship as separate static artifact. Website pod mocahua portfolio shell, demos-static pod serves static bundles, ihuan browser quichihua expensive work. Tla later onicship real ONNX object detection, Transformers.js, o full video transcoding models, monequi lazy-load ipan browser o yasque beefier node.', 'blog_q8' => 'Axcan lab huel quichihua own worker nodes?', 'blog_a8' => 'Quena, ihuan axcan ika fewer crossed fingers. Debian quipia provisioning layer ika dnsmasq, nginx, PXE boot files, GRUB, ihuan Debian 13 arm64 preseed. OpenTofu notza Pimox through qm, quichihua VM 9000 ipan local storage, quiboota from network, quinstala OS, quichihua golden-node prep, disables swap, verifies cgroups, installs containerd ihuan kubeadm tooling, then seals it as template. Worker clones cateh idempotent by VMID tla onca stable non-local Pimox datastore.', 'blog_q9' => 'Ihuan OpenWrt no quisa nican?', - 'blog_a9' => 'Zan simple firewall, ahmo networking science project. Pipeline huel quichihua opt-in OpenWrt ARM SystemReady VM, attach vmbr0 quen WAN ihuan vmbr1 quen LAN, ihuan configure LAN side ahmo rewriting Orange Pi host networking. DHCP stays optional, VLANs wait until onca managed switch ihuan local test window.', 'blog_q10' => 'Tlein omopatla ipan observability ihuan scheduling side?', - 'blog_a10' => 'Monitoring moved de "someday" to "running," ihuan scheduling moved de "whatever fits" to explicit worker placement. Prometheus Stack, Grafana, Loki, Promtail, node-exporter, ihuan kube-state-metrics quimaca useful signals; next step quitosnequi elegir few alerts in melahuac nechixitisque para right reasons.', 'blog_stack_title' => 'Tlamantli ihuan tleica nemi nican', - 'blog_stack_1' => 'Debian Linux quimaca steady adult in room: control plane host, deployment workstation, PXE/preseed server, ihuan canin OpenTofu, Docker, kubeadm, ihuan scripts quichihua tequitl.', - 'blog_stack_2' => 'Raspberry Pi keeps external Gitea service close to lab ipan SSD-backed /data, while Pimox ipan Orange Pi 5 Plus huel quimaca app-worker pool tla VM storage stable. HP Debian laptop axcan quipia NVMe-backed data-vg storage para Kubernetes data paths.', 'blog_stack_3' => 'OpenTofu quichihua cluster, platform, apps, edge, ihuan provisioning layers repeatable, pampa "I swear I remember the command" amo disaster recovery strategy.', - 'blog_stack_4' => 'Calico handles pod networking, ihuan OpenEBS hostpath storage keeps important data after rebuilds, pampa deleting everything by accident zan funny once.', - 'blog_stack_5' => 'Argo CD quimaca GitOps referee ihuan now runs on app workers: manifests cateh ipan Git, cluster follows along, ihuan manual drift gets side-eyed back into place.', 'blog_stack_6' => 'OCI edge host runs nginx, HAProxy, Varnish, ihuan Squid para TLS, routing, HTTP/2, keepalive, gzip, ihuan caching ma mocahua outside home network mientras Tailscale quihuica traffic back to Traefik.', 'blog_stack_7' => 'Shared theme toggle quipia plain CSS ihuan JavaScript: dark mode old-console green-on-black, light mode black cursive on ivory ipan website ihuan demo catalog.', 'blog_stack_8' => 'First demo keeps files ipan browser. Image crunching uses native Canvas APIs axcan, while fast serious path para video conversion is Rust compiled to WebAssembly ika TypeScript UI.', @@ -146,22 +134,16 @@ return [ 'blog_stack_12' => 'Pimox worker pipeline uses qm over SSH para create OVMF/virtio-scsi Debian 13 arm64 VM, wait for qemu-guest-agent, seal it, ihuan convert VM 9000 into reusable template on local storage.', 'blog_stack_13' => 'Golden image bakes in Kubernetes prerequisites: swap disabled, cgroup boot options checked, kernel modules loaded, containerd configured for systemd cgroups, kubeadm/kubelet/kubectl installed, ihuan qemu-guest-agent enabled.', 'blog_stack_14' => 'Worker clone automation is count-based ihuan idempotent: LAB_PIMOX_WORKER_COUNT=1 quitosnequi ensure VM 9010 exists, amo create fresh worker every run. New workers refused tla target storage is local.', - 'blog_stack_15' => 'OpenWrt handled separately from Debian golden-node template. Lab downloads upstream ARM SystemReady EFI image, imports it onto selected non-local Pimox storage, ihuan keeps disabled unless LAB_OPENWRT_VM=true.', - 'blog_stack_16' => 'Monitoring layer axcan includes Prometheus Stack, Grafana, Loki, Promtail, node-exporter, ihuan kube-state-metrics, ika placement guardrails para platform add-ons ma amo default to control plane.', 'blog_stack_17' => 'Portfolio website keeps Apache at core, runs PHP through PHP-FPM ika OPcache, pre-renders read-heavy pages into static HTML during image build, ihuan leaves PHP para write ihuan translation endpoints.', 'blog_stack_18' => 'Supply-chain path axcan uses BuildKit SBOM attestations, Cosign signatures, public key ipan cluster, ihuan audit-first Kyverno ImageValidatingPolicy in huel mopromote para deny unsigned local-registry pods.', 'blog_stack_19' => 'Translation path axcan uses Redis para per-string cache hits, custom Ollama website-translator model ipan Debian server para cache misses, n8n para prewarming ihuan batch workflows, ihuan structured logs para cache, latency, JSON parse, ihuan timeout signals.', 'blog_stack_20' => 'AI stack mocahua ipan Debian by design: OmniRoute runs in Docker Compose under /data/homelab-ai-stack, seeds OpenRouter ihuan NVIDIA keys locally, creates free/no-auth provider routes, validates real completions, ihuan writes model hints para tools.', 'blog_stack_21' => 'Goose, Holmes, ihuan Hermes mocahuah quen bare-metal tools ika Jeannie wrappers. Ica doctor-k8s huel collect read-only Kubernetes evidence ihuan ask Holmes for triage quema cluster itself is broken.', - 'blog_stack_22' => 'Pimox migration quicuep Orange Pi 5 Plus into rebuildable Kubernetes capacity: yeyi Debian arm64 VMs, big-core KVM pinning, containerd 2.x registry trust, known-host refresh, imagefs cleanup, ihuan app rollouts without manual node edits.', 'blog_arch_kicker' => 'Architecture mapa', 'blog_arch_title' => 'Homelab, end to end', - 'blog_arch_intro' => 'Current delivery path starts ika push to Gitea, runs local validation, builds arm64 images, syncs validated commit into GitOps mirror, ihuan lets Argo CD reconcile from app workers. Infrastructure path stays manual through jeannie, including PXE/Pimox template builder, NVMe-backed worker clones, Kyverno policy placement, Redis-backed website translation, n8n workflow automation, ihuan opt-in OpenWrt firewall VM, while OCI edge routes public traffic back through private path.', - 'blog_arch_caption' => 'Diagram intentionally operational: quinextia app delivery loop, image flow, provisioning path, worker-placement boundary, monitoring layer, Redis/n8n/Ollama translation path, OpenWrt firewall option, ihuan public traffic path ahmo hiding practical bits in quichihua small lab behave like platform.', 'blog_arch_fun_link' => 'Xiquitta Christmas-tree version', 'blog_activity_kicker' => 'Yancuic activity log', 'blog_activity_title' => 'Tlein omopatla since first build', - 'blog_activity_intro' => 'Lab omocuep de working Kubernetes experiment into more complete self-hosted delivery system. Latest work focused on trust, repeatability, VM-based expansion, controller placement, measured website performance, ihuan deploys in match exact commit in passed validation.', 'blog_activity_1' => 'Moved Gitea out of Kubernetes ihuan onto Raspberry Pi as local Git service, while keeping public /git/ route through edge stack.', 'blog_activity_2' => 'Installed ihuan validated Debian-hosted Gitea Actions runner para pushes to main can build, scan, ihuan deploy without laptop session.', 'blog_activity_3' => 'Added custom checkout flow para /git/ subpath ihuan kept persistent Debian checkout para deployment scripts.', @@ -184,17 +166,13 @@ return [ 'blog_todo_kicker' => 'Improvement tlatecpanaliztli', 'blog_todo_title' => 'Todo list para next homelab pass', 'blog_todo_intro' => 'Inin cateh improvement proposals, amo chores zan pampa chores. Each item either reduces rebuild risk, tightens supply-chain hygiene, o makes platform easier to operate quema tlein fails.', - 'blog_todo_1' => 'Move Gitea data from Raspberry Pi SD card to SSD-backed storage.', - 'blog_todo_2' => 'Keep Debian bare GitOps mirror as cluster source ihuan add object-storage backups quema OCI storage ready.', 'blog_todo_3' => 'Add real OpenTofu remote state backend ika backup, locking, ihuan documented recovery path.', 'blog_todo_4' => 'Replace remaining mutable latest image references ika immutable tags o digest pins para demo workloads; website image axcan uses content-hash tag.', 'blog_todo_5' => 'Move Cosign private key into Vault o occe secret manager so runner ayacmo owns long-lived signing material on disk.', 'blog_todo_6' => 'Add Renovate o Dependabot-style dependency updates para base images, Helm charts, ihuan GitHub/Gitea Actions.', 'blog_todo_7' => 'Expand Kyverno baseline policy coverage: non-root, read-only roots, resource requests, allowed registries, ihuan documented exceptions para platform components.', - 'blog_todo_8' => 'Turn installed observability stack into useful operations views: few high-signal dashboards, alerts para node health, storage pressure, certificate expiry, ihuan failed app syncs.', 'blog_todo_9' => 'Schedule backup restore drills para external Gitea ihuan OpenEBS volumes, then write exact restore runbook.', 'blog_todo_10' => 'Tighten TLS, SSH, ihuan token rotation around OCI edge, Gitea, registry, ihuan runner credentials.', - 'blog_todo_11' => 'Document new storage split: local para Pimox template, data-vg ipan HP Debian laptop para Kubernetes app data, Raspberry Pi SSD /data para Gitea ihuan Docker, ihuan backup targets para tlein must survive rebuild.', 'blog_todo_12' => 'Move sensitive app configuration into Sealed Secrets, External Secrets, o occe explicit secret-management path.', 'blog_todo_13' => 'Test the OpenWrt VM ipan maintenance window before making it a gateway: confirm WAN, LAN, rollback access, DHCP settings, ihuan Pimox remains reachable.', 'blog_todo_14' => 'Buy o configure managed switch before VLAN work. Until then, keep OpenWrt quen simple two-interface firewall ihuan avoid risky remote bridge rewrites.', diff --git a/bootstrap/platform/README.md b/bootstrap/platform/README.md index 75cbf60..446c316 100644 --- a/bootstrap/platform/README.md +++ b/bootstrap/platform/README.md @@ -81,9 +81,10 @@ verification, restart behavior and refusal cases. The Gitea runner requires an app-node selector and host Docker socket when enabled; a zero-replica runner is left disabled across all profiles. -The k3s installer currently also enables its bundled metrics-server and -ServiceLB, while the platform manages metrics-server and MetalLB. Check live -ownership before consolidating these services on an existing installation. +New native K3s installs disable packaged Traefik, metrics-server and ServiceLB; +the platform manages the corresponding ingress, metrics and MetalLB layers. +Existing externally managed metrics-server installations are reused after +ownership discovery. Check live ownership before consolidating older installs. Recovery and repository-scan helpers still contain timestamp triggers, so a successful second plan is not necessarily a zero-change plan. diff --git a/docs/ai-ops.md b/docs/ai-ops.md index 26a06a4..9f2a484 100644 --- a/docs/ai-ops.md +++ b/docs/ai-ops.md @@ -60,29 +60,6 @@ map to explicit heal/runbook commands, self-heal allowlists, or human-reviewed pipeline changes. This keeps the diagnostic layer read-only while still using Holmes to summarize likely root cause, impact, and next action. -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./jeannie doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./jeannie rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - ## AI Evals The repo includes a local eval harness for Jeannie explanations and homelab RAG @@ -234,15137 +211,3 @@ tool-correctness signals over time: ``` Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./jeannie doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./jeannie rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./jeannie ai-evals run -``` - -Use `./jeannie ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./jeannie prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./jeannie ai-evals run -``` - -Use `./jeannie ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./jeannie prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./jeannie prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. diff --git a/docs/app-ops.md b/docs/app-ops.md index 0f4dc98..f95d7ca 100644 --- a/docs/app-ops.md +++ b/docs/app-ops.md @@ -1,5 +1,19 @@ # Application Operations +## Profile-aware application delivery + +Run app operations with the intended profile and its pinned kubeconfig. The +native Orange Pi target uses `LAB_CLUSTER_PROFILE=k3s` and +`KUBECONFIG="$HOME/.kube/opi5-k3s-config"`. Platform and Argo CD readiness must +complete before `./jeannie apps` runs. The transition command sequences +these stages and stops when a prerequisite fails. + +Application deployment verifies identity, renders scheduling estimates and +discovers retained registry placement. A one-core VM is allowed when its +reservations and placement permit the rollout; native K3s does not require old +Pimox worker inventory. See the [code map](code-map.md) and +[deployment gates](deployment.md#scheduling-and-deployment-gates). + ## Adding Apps Add Kubernetes manifests under `apps/` and register them in @@ -53,382 +67,19 @@ standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath data still lives under `/data/openebs/local`, and larger service data such as Gitea, Ollama models, and app volumes should stay under `/data`. -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. +Local PV data belongs to the host where its node affinity points. For native +K3s, the registry directory is on the Orange Pi, while Gitea and build data stay +on the laptop. The laptop-to-native transition copies a verified registry union +before native K3s starts, retains source/backup directories and writes a +profile-scoped receipt. The apps pipeline checks that receipt against live node +placement and storage before creating the registry PV. Different existing +remote data is refused rather than overwritten. + +The image endpoint remains `192.168.100.73:30500`; forwarding resolves the live +selected registry node across profiles. Old Jeannie-tagged forwarding rules are +retired before installing the selected route. Other laptop PVC contents are +preserved locally and are not automatically restored into the new cluster. +See [registry migration](../bootstrap/apps/README.md). ## Gitea @@ -635,1858 +286,6 @@ not auto-merge infrastructure changes. Keep app-only dependency updates on the normal Gitea Actions path, and run `./jeannie up` manually on the Debian server for platform or provisioning updates. -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. ## Website App The website is a PHP app under `apps/website`. It includes a home page, CV page, diff --git a/docs/architecture.md b/docs/architecture.md index 5841f72..c8b94dc 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -7,8 +7,9 @@ The lab is intentionally small but production-shaped: - Debian remains the always-on operations host for Jeannie, Docker builds, external Gitea, the GitOps mirror, the local registry endpoint, Ollama, OmniRoute, and AI tool wrappers -- Kubernetes capacity now comes from Pimox Debian arm64 VMs on the Orange Pi 5 - Plus, with one control-plane VM and worker VMs managed as rebuildable capacity +- Kubernetes has three selectable profiles: a laptop kubeadm control plane with + Pimox workers, an entirely virtualized Pimox kubeadm cluster, and native K3s + on the Orange Pi 5 Plus. Only one profile may run at a time - a Raspberry Pi arm64 host runs selected support services outside the Kubernetes rebuild blast radius - the Debian host also runs the always-on Gitea Docker service outside @@ -37,7 +38,7 @@ The lab is intentionally small but production-shaped: ## Inventory -The canonical non-secret inventory is [homelab.yml](homelab.yml). Keep LAN IPs, +The canonical non-secret inventory is [homelab.yml](../homelab.yml). Keep LAN IPs, Tailscale IPs, public hostnames, ports, storage paths, and service ownership there before copying values into scripts, OpenTofu variables, runbooks, or service docs. Secrets and tokens do not belong in that file. @@ -46,32 +47,41 @@ service docs. Secrets and tokens do not belong in that file. variables for the edge, provisioning, cluster, platform, and apps stacks. This keeps values such as the Debian LAN IP, Debian Tailscale IP, RPi LAN IP, OCI IP, Traefik MetalLB IP, and domain name from drifting across scripts and templates. -`scripts/render-docs` also renders [docs/service-catalog.md](docs/service-catalog.md) +`scripts/render-docs` also renders [the service catalog](service-catalog.md) and the static service catalog page at `apps/demos-static/public/homelab-catalog/index.html` from the same inventory. -Run `./jeannie up` and `./jeannie nuke` only from the Debian homelab server. The -script intentionally refuses to run from non-Debian machines so a laptop cannot -accidentally modify the cluster. +Run deployment commands from the Debian operations laptop at `.73`, or through +its allowlisted API. The development laptop is a separate client. Host checks +and pinned cluster identities prevent an unintended local deployment target. ## Flow +The [code map](code-map.md) traces these layers to the actual entrypoints. +`lib/jeannie/env.sh` is the shared inventory loader; `pipeline.sh` uses that +loader rather than maintaining a second copy of profile defaults. + 1. `bootstrap/provisioning` - prepares a Debian server as a PXE and preseed service for arm64 VMs - serves Debian 13 arm64 netboot assets through TFTP and HTTP - exposes a PXE rescue menu and HTTP rescue page for manual repair paths - creates a golden image install path with Kubernetes, containerd, qemu-guest-agent, cloud-init, and storage client packages ready - - is driven by `./jeannie up` when Pimox is reachable, without changing - Orange Pi host networking + - is used by the kubeadm VM profiles; native K3s skips worker provisioning + and OpenWrt VM startup, preserving Orange Pi host networking 2. `bootstrap/cluster` - - creates the kubeadm control plane on the Debian amd64 node - - joins worker nodes such as Raspberry Pi and Pimox Debian arm64 nodes + - installs the selected runtime: kubeadm on the laptop or Pimox CP VM, + or K3s directly on the Orange Pi host + - joins Pimox workers for the kubeadm profiles; native K3s is single-node - configures Calico-compatible pod CIDR - configures containerd to pull from the in-cluster NodePort registry - creates retained host directories under `/data/openebs/local` + Native K3s disables packaged Traefik, ServiceLB and metrics-server so the + platform can own ingress, MetalLB and metrics-server. Existing externally + managed metrics-server installations are discovered and reused. + 3. `bootstrap/platform` - installs a minimal Calico deployment through the Tigera operator - installs NodeLocal DNSCache for node-local DNS query caching @@ -114,6 +124,36 @@ accidentally modify the cluster. - enables gzip, HTTP/2, TLS session reuse, client keepalive, upstream keepalive, and cache headers for the public website path +## Profile isolation and switching + +| Profile | API | Runtime placement | +| --- | --- | --- | +| `debian` | `https://192.168.100.73:6443` | Laptop CP, worker VMs 9010/9011 | +| `pimox` | `https://192.168.100.65:6443` | CP VM 9001, worker VMs 9010/9011 | +| `k3s` | `https://192.168.100.80:6443` | Native Orange Pi host, node `opi5plus` | + +`cluster-runtime-guard.py` probes both physical hosts, API listeners, K3s +workload processes and Pimox VM power state. Deployment/start pipelines hold a +shared lock and refuse conflicts. This does not prevent manual starts outside +Jeannie. Switching modes requires stopping the previous runtime first. + +`cluster-context.py` binds each profile to its API endpoint, CA fingerprint and +`kube-system` UID. Its state root is +`~/.local/share/homelab/clusters//`, with `identity.json` and separate +`stacks/{cluster,platform,apps}/terraform.tfstate` files. Stopped-cluster startup +checks endpoint/CA offline, then checks live UID after startup. Deployment, +import, cleanup and healing retain live identity checks. + +Retained local PVs remain tied to their host and data path. A different profile +does not automatically inherit the old cluster's volume contents. The laptop +K3s transition verifies and copies registry data before host K3s starts, archives +the old identity/state and datastore, and enrolls a new identity on the Orange +Pi. Other laptop PVC data stays on the laptop pending a separate restore. + +On November 2, 2026, the native `opi5plus` node reported Ready. Platform/apps +completion must be checked independently; source support is not proof of a +successful live deployment. + ## Pimox Migration Lessons The Pimox migration moved Kubernetes workloads away from the old Debian-hosted @@ -123,9 +163,10 @@ gateway, and recovery commands. Pimox VMs provide disposable Kubernetes capacity Operational lessons now encoded in Jeannie: -- Preserve two guest CPUs per Pimox VM. The Orange Pi 5 Plus has mixed core - classes, so the VMs are pinned to the big-core CPU set with a Proxmox hook - script instead of shrinking workers to one Kubernetes CPU. +- Two guest CPUs per Pimox VM remain the desired topology. Runtime scheduling + checks use actual capacity and reservations; an existing one-core worker is + not silently treated as a two-core VM or blocked solely by a two-core floor. + The VM path supports big-core pinning through a Proxmox hook script. - Treat VM disks as rebuildable. Durable application data belongs on retained OpenEBS paths, host-level `/data`, or backups, not inside an untracked VM root disk. @@ -139,743 +180,6 @@ Operational lessons now encoded in Jeannie: pods. App deploys include deterministic stale-pod and unused image cleanup rather than relying on manual `kubectl delete` or node shell history. -## Prerequisites - -On the Debian host: - -- OpenTofu -- Docker with Buildx -- kubeadm, kubelet, kubectl, and containerd pinned to the target Kubernetes - minor, currently `v1.36` -- SSH access to worker nodes -- SSH access to the OCI edge host -- Go toolchain for Jeannie core helpers; `./jeannie up` installs - `golang-go` on the Debian host if it is missing -- enough persistent storage for `/data/openebs/local` and Docker's data root - -After a clean Debian reinstall, bootstrap the host package set and desktop -configuration first: - -```bash -sudo apt-get update -sudo apt-get install -y git ansible sudo -git clone /home/jv/my-homelab-configs -cd /home/jv/my-homelab-configs -ansible-playbook -K -i bootstrap/host/inventory.ini bootstrap/host/playbook.yml -``` - -If you kept the private app-config archive generated from the old Debian host, -pass its generated `ansible-vars.yml` with `-e @/path/to/ansible-vars.yml`. -Details are in `bootstrap/host/README.md`. - -The default kubeconfig path is `/home/jv/.kube/config`. Override it with -`KUBECONFIG_PATH` or `TF_VAR_kubeconfig_path` when needed. - -## Implementation Language Policy - -Jeannie keeps `./jeannie` as the stable command entrypoint. New durable -read-only orchestration, report rendering, inventory parsing, status/doctor -logic, and self-heal planning should prefer Go under `cmd/jeannie-core` because -it ships as one small binary and is easier to test than Bash. Bash remains for -thin compatibility wrappers and remote shell glue. Python remains acceptable for -AI/RAG, data-heavy utilities, or cases where an existing Python ecosystem is the -clear fit. New repo features should choose the smallest language that fits the -task instead of defaulting to Bash. - -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./jeannie doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./jeannie rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./jeannie ai-evals run -``` - -Use `./jeannie ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./jeannie prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - ## Workload Placement `bootstrap/cluster` labels nodes with homelab placement metadata: @@ -896,12 +200,13 @@ the physical layout changes. The current website, demos, and registry manifests are not moved automatically because the public NodePort path and retained OpenEBS hostpath PVs are node-local. Move workloads only after their storage and edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. +through its Debian-host Compose deployment instead. -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. +Platform controllers use `homelab.dev/workload-class=platform`. Multi-node +profiles retain worker placement, topology spread and preferred anti-affinity; +single-node profiles reconcile that platform label on their selected control +plane. Scheduling preflight checks the live labels instead of assuming a VM +worker exists in a native K3s cluster. PVC-backed monitoring StatefulSets are intentionally treated separately because their retained OpenEBS hostpath volumes are node-local. Run `./jeannie move-prometheus-stack-workers` from the Debian host to label existing @@ -983,10 +288,6 @@ For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of remote SSH targets when more worker nodes exist. Set it to an empty string for a single-node rebuild. -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - ## Policy Guardrails `bootstrap/platform` installs Kyverno and the upstream baseline Pod Security @@ -1054,5112 +355,6 @@ Ingress objects. The local registry remains a `NodePort` because the cluster nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; they run on the Debian Docker host. -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Flow - -1. `bootstrap/provisioning` - - prepares a Debian server as a PXE and preseed service for arm64 VMs - - serves Debian 13 arm64 netboot assets through TFTP and HTTP - - exposes a PXE rescue menu and HTTP rescue page for manual repair paths - - creates a golden image install path with Kubernetes, containerd, - qemu-guest-agent, cloud-init, and storage client packages ready - - is driven by `./jeannie up` when Pimox is reachable, without changing - Orange Pi host networking - -2. `bootstrap/cluster` - - creates the kubeadm control plane on the Debian amd64 node - - joins worker nodes such as Raspberry Pi and Pimox Debian arm64 nodes - - configures Calico-compatible pod CIDR - - configures containerd to pull from the in-cluster NodePort registry - - creates retained host directories under `/data/openebs/local` - -3. `bootstrap/platform` - - installs a minimal Calico deployment through the Tigera operator - - installs NodeLocal DNSCache for node-local DNS query caching - - installs MetalLB for LAN `LoadBalancer` services - - installs Traefik as the single Kubernetes ingress entry point - - installs OpenEBS - - creates `openebs-hostpath-retain` - - installs Argo CD - - installs Kyverno with audit-first baseline Pod Security policies and - homelab image signature/SBOM admission controls - - registers the private GitOps repo without storing the SSH private key in - Terraform state - -4. `bootstrap/apps` - - registers Argo CD Applications from the `applications` map - - passes the website image produced by the build step into Argo CD as a - Kustomize image override - - deploys the tuned website runtime: Apache listens on port 8080, PHP-FPM - listens on loopback inside the container, OPcache is enabled, and - pre-rendered HTML handles the read-heavy pages - - default apps are `container-registry`, `website-production`, - `demos-static`, the `heimdall` route bundle, `n8n`, and - `supply-chain-policy` - -5. `bootstrap/edge` - - connects to the OCI jump box - - uploads nginx, HAProxy, Varnish, and Squid configs - - obtains and renews Let's Encrypt certificates for the configured hostname - - runs the edge cache/proxy chain with Docker Compose - - enables gzip, HTTP/2, TLS session reuse, client keepalive, upstream - keepalive, and cache headers for the public website path - -## Prerequisites - -On the Debian host: - -- OpenTofu -- Docker with Buildx -- kubeadm, kubelet, kubectl, and containerd pinned to the target Kubernetes - minor, currently `v1.36` -- SSH access to worker nodes -- SSH access to the OCI edge host -- Go toolchain for Jeannie core helpers; `./jeannie up` installs - `golang-go` on the Debian host if it is missing -- enough persistent storage for `/data/openebs/local` and Docker's data root - -After a clean Debian reinstall, bootstrap the host package set and desktop -configuration first: - -```bash -sudo apt-get update -sudo apt-get install -y git ansible sudo -git clone /home/jv/my-homelab-configs -cd /home/jv/my-homelab-configs -ansible-playbook -K -i bootstrap/host/inventory.ini bootstrap/host/playbook.yml -``` - -If you kept the private app-config archive generated from the old Debian host, -pass its generated `ansible-vars.yml` with `-e @/path/to/ansible-vars.yml`. -Details are in `bootstrap/host/README.md`. - -The default kubeconfig path is `/home/jv/.kube/config`. Override it with -`KUBECONFIG_PATH` or `TF_VAR_kubeconfig_path` when needed. - -## Implementation Language Policy - -Jeannie keeps `./jeannie` as the stable command entrypoint. New durable -read-only orchestration, report rendering, inventory parsing, status/doctor -logic, and self-heal planning should prefer Go under `cmd/jeannie-core` because -it ships as one small binary and is easier to test than Bash. Bash remains for -thin compatibility wrappers and remote shell glue. Python remains acceptable for -AI/RAG, data-heavy utilities, or cases where an existing Python ecosystem is the -clear fit. New repo features should choose the smallest language that fits the -task instead of defaulting to Bash. - -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./jeannie doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./jeannie rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./jeannie ai-evals run -``` - -Use `./jeannie ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./jeannie prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. ## Edge Services The OCI jump box runs the public edge path: diff --git a/docs/cluster-context.md b/docs/cluster-context.md index e35db88..ae44445 100644 --- a/docs/cluster-context.md +++ b/docs/cluster-context.md @@ -14,6 +14,13 @@ updates an existing binding. Kubeconfigs must use explicit CA verification and a single absolute file path. Context aliases are allowed only when they resolve to the same pinned identity. TLS bypasses and endpoint/CA overrides are refused. +The declared profiles are `debian` (laptop kubeadm CP plus VM workers), `pimox` +(VM CP and workers), and `k3s` (native Orange Pi host). Native K3s uses +`https://192.168.100.80:6443` and `~/.kube/opi5-k3s-config`. The old laptop K3s +identity at `.73` is archived by the reviewed transition, never rebound to `.80`. +See [runtime isolation](architecture.md#profile-isolation-and-switching) and the +[native transition](deployment.md#move-laptop-k3s-to-the-orange-pi). + ## Enroll the existing cluster once Run on Debian after pulling the change. Preview enrollment first: @@ -59,8 +66,10 @@ OCI foundations, provisioning, and edge are shared infrastructure; their state locations remain unchanged. On a fresh profile cache, Jeannie initializes local-backend metadata from an -empty temporary configuration directory, using the real stack's provider lock -file in read-only mode. It then verifies the backend points to the scoped state +empty temporary configuration directory. Migrated state uses a copy of the real +stack's provider lock file in read-only mode; fresh/empty state does not copy +unrelated provider entries into that backend-only configuration. The real stack +keeps its complete provider lock file. It verifies the backend points to scoped state and initializes the real stack without `-reconfigure`. This avoids OpenTofu 1.12.6 treating the retained repository state as a migration source. Neither `-force-copy` nor an automatic migration approval is used. Initialization checks @@ -165,6 +174,13 @@ operation or remote provisioner is verified before it starts; the guard cannot make a long-running operation atomic with a cluster identity change. Use Jeannie entry points rather than raw OpenTofu commands for these stacks. +An enrolled stopped cluster can use the startup-only offline endpoint/CA check. +`start-cluster` verifies the live namespace UID after startup. That exception is +not an offline apply/import/cleanup/healing bypass. Deployment/start commands +also hold a shared runtime lock and reject conflicting host services, private +K3s workload processes and VM power states. These guards do not prevent manual +starts outside Jeannie. + ## Validation on Debian No local application or unit tests are run on the development laptop. The diff --git a/docs/code-map.md b/docs/code-map.md new file mode 100644 index 0000000..9e8b353 --- /dev/null +++ b/docs/code-map.md @@ -0,0 +1,62 @@ +# Repository Code Map + +Refreshed with `graphify update .` on November 2, 2026. The generated local map +is `graphify-out/graph.json`, with `graph.html` and `GRAPH_REPORT.md` alongside +it. That directory is intentionally gitignored; this guide records the useful +paths without committing generated caches. + +Graphify is a navigation aid. The paths below were checked against source; +dynamic imports and shell dispatch are not a complete call graph. The refresh +reported three extracted nodes without `source_file` metadata, and community +names were derived from hubs rather than refreshed with an LLM. + +| Responsibility | Entry point | Relationship to the pipeline | +| --- | --- | --- | +| CLI and API | [jeannie](../jeannie), [API server](../cmd/jeannie-server/main.go) | API allowlisted commands use the same CLI; internal tasks and recursive remote dispatch stay excluded. | +| Profile inventory | [env.sh](../lib/jeannie/env.sh), [homelab.yml](../homelab.yml) | One shared loader exports profile defaults and Terraform variables; pipeline sources it. | +| Runtime exclusion | [cluster-runtime-guard.py](../scripts/cluster-runtime-guard.py) | Host services, private K3s workloads, API listeners and VM states gate deployment/start; a shared lock serializes pipelines. | +| Identity and state | [cluster-context.py](../scripts/cluster-context.py) | Endpoint, CA and namespace UID bind each profile; guarded tools use separate scoped backends. | +| Runtime bootstrap | [cluster/main.tf](../bootstrap/cluster/main.tf) | Selects kubeadm or native K3s; the native remote bootstrap explicitly executes Bash and requires the declared hypervisor capability. | +| Scheduling estimate | [scheduling-preflight.py](../scripts/scheduling-preflight.py) | `Estimate`, `pod_requests` and `manifests_from_plan` connect planned workloads to live capacity, placement and rollout constraints. | +| Application storage | [registry-storage-reconcile.py](../scripts/registry-storage-reconcile.py) | `prepare_local`, `publish_remote` and `remote_manifest` stage, verify and preserve registry data before placement changes. | +| Native transition | [cluster-transition.py](../scripts/cluster-transition.py), [k3s-stop.sh](../scripts/k3s-stop.sh) | A private phase journal sequences retirement, offline storage copy, bootstrap, independent identity enrollment, platform and apps. | +| Layer orchestration | [pipeline.sh](../lib/jeannie/pipeline.sh) | Applies guards, discovery/adoption, bounded transport retries and readiness checks around OpenTofu and Argo operations. | +| Documentation | [render-docs](../scripts/render-docs), [templates](templates/) | README and modular guides are generated from templates; the service catalog comes from inventory. | +| Blog | [blog.php](../apps/website/blog.php), [English copy](../apps/website/lang/en.php), [Nahuatl copy](../apps/website/lang/nah.php) | The PHP page supplies the diagram and source links; language dictionaries supply narrative copy. | + +## Native transition flow + +```mermaid +flowchart TD + A[Review transition plan] --> B[Verify pinned laptop identity] + B --> C[Stop laptop K3s workloads and archive state] + C --> D[Stop VMs and copy verified registry offline] + D --> E[Bootstrap K3s on Orange Pi] + E --> F[Compare API identity with direct SSH reads] + F --> G[Enroll new profile identity] + G --> H[Scheduling estimate and platform apply] + H --> I[Registry placement and app delivery] +``` + +Failures retain the journal and original data. Resume the same transition +command after fixing the cause. Only registry data is copied; other old laptop +PVC data requires a separate restore. A Ready node proves bootstrap readiness, +not completion of every platform or application rollout. + +## Documentation maintenance + +Edit `README.md.tmpl` and `docs/templates/*.md.tmpl`, then run +`scripts/render-docs`. Keep architecture, deployment, app operations and AI +operations in their own guides; duplicated copies previously left contradictory +instructions in the generated documentation. Update blog text and diagram labels +together. Website source changes take effect after the normal image build and +Argo delivery path; editing PHP does not publish the live site. + +Useful local navigation commands: + +```sh +graphify update . +graphify explain 'cluster-transition.py' +graphify explain 'publish_remote' +graphify query 'scheduling-preflight' --budget 1200 +``` diff --git a/docs/deployment.md b/docs/deployment.md index 7d9d13b..de2968e 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,13 +1,109 @@ # Homelab Deployment Guide +## Select and verify a profile + +Jeannie runs from the Debian operations laptop. Choose one of the three +[cluster profiles](architecture.md#profile-isolation-and-switching) explicitly; +the committed inventory default remains `pimox`. + +| Profile | Runtime | Kubeconfig | +| --- | --- | --- | +| `debian` | Laptop kubeadm CP and two Pimox workers | `~/.kube/config` | +| `pimox` | Pimox CP VM and two worker VMs | `~/.kube/pimox-config` | +| `k3s` | Native Orange Pi host | `~/.kube/opi5-k3s-config` | + +For the already enrolled native cluster: + +```bash +export LAB_CLUSTER_PROFILE=k3s +export LAB_CLUSTER_RUNTIME=k3s +export TF_VAR_cluster_runtime=k3s +export KUBECONFIG="$HOME/.kube/opi5-k3s-config" +./jeannie cluster-profile +./jeannie cluster-context check +./jeannie cluster-runtime check +``` + +When changing profiles, clear stale runtime, kubeconfig, host and `TF_VAR_*` +overrides first. The runtime guard rejects conflicting runtime overrides rather +than assuming that an old shell environment describes the new profile. + +Before an apply, import, cleanup or healing action, Jeannie checks the selected +API endpoint, CA fingerprint and `kube-system` UID against its enrolled identity. +Review `cluster-context enroll`, verify the identity independently on the target +host, then use `enroll --yes` for a new cluster. Do not reuse another cluster's +identity or copy its scoped state into a fresh profile. The +[identity guide](cluster-context.md) explains reviewed legacy state migration. + +Deployment/start pipelines also check conflicting services, K3s workload +processes and VM state, and hold a cross-profile runtime lock. Native K3s +requires every Pimox VM stopped. The kubeadm modes require native host K3s +stopped, plus the other profile's control plane stopped. Runtime probe failures +block deployment. Stop the selected old mode with `stop-cluster` before switching. + +## Move laptop K3s to the Orange Pi + +The accidental K3s deployment on `.73` is retired through a resumable transition +to the declared native host `.80`. Run this on the Debian laptop: + +```bash +cd ~/my-homelab-configs +git pull --ff-only gitea main +./jeannie cluster-transition k3s-to-native +./jeannie cluster-transition k3s-to-native --yes +``` + +The first invocation prints the plan; `--yes` stops and disables laptop K3s, +stops only its private workload process trees, backs up its server datastore and +configuration, archives its scoped identity/state, and gracefully stops Pimox +VMs. It prepares a checksum-verified registry copy on the Orange Pi before +native K3s starts. Existing different remote data is preserved and blocks copying. +The worker used as a registry source can be started temporarily, then stopped. + +The command bootstraps the native cluster, compares its API identity with direct +SSH reads from the Orange Pi, enrolls that identity, then runs `platform all` +and `apps` in sequence. It stops on failure. Repeat the same command to resume; +do not delete the private transition journal or scoped state to force a retry. +It is also API-allowlisted after rebuilding the API binary. + +Old state is retained under `~/.local/share/homelab/retired-clusters/` and the +stopped datastore archive under `/var/backups/jeannie-k3s-laptop-*`. The journal +is `~/.local/share/homelab/transitions/k3s-to-native.json`. Other laptop PVC data +stays on the laptop: this copies registry data, not all application databases. +See [registry transition details](../bootstrap/apps/README.md). + +The native `opi5plus` node has reported Ready. Platform and apps completion +remain separate checks. Do not run another deployment alongside the transition. + +## Scheduling and deployment gates + +Before platform/apps apply, `scripts/scheduling-preflight.py` renders planned +Helm and Argo sources and compares requests with allocatable resources and live +reservations. It checks selectors, taints, affinity, host ports, PV placement +and rollout budgets. Low current CPU usage does not free CPU reservations. +One-core nodes can run workloads when the reservations and placement fit. + +Fresh operator workloads can use an explicit estimate of primary resources; +generated sidecars and volumes still require post-apply readiness checks. +Missing CNI is treated as initial bootstrap only when the Calico creation plan +and live node state establish that case. Existing CNI failures remain blockers. +Single-node platform labels target the selected node across runtimes. + +Follow the [code map](code-map.md) for the actual guard, backend and storage +entrypoints. Recognized transient transport failures have bounded retries; +identity, ownership, configuration and scheduling errors require correction. +Init diagnostics are private under the selected profile's `diagnostics/`. +Do not fix a scoped backend failure by forcing a legacy state copy. + ## Prerequisites On the Debian host: - OpenTofu - Docker with Buildx -- kubeadm, kubelet, kubectl, and containerd pinned to the target Kubernetes - minor, currently `v1.36` +- kubectl and Python with PyYAML for profile, identity and scheduling helpers +- kubeadm, kubelet and containerd for kubeadm profiles; native K3s is installed + remotely by the cluster layer and uses its own runtime - SSH access to worker nodes - SSH access to the OCI edge host - Go toolchain for Jeannie core helpers; `./jeannie up` installs @@ -29,8 +125,9 @@ If you kept the private app-config archive generated from the old Debian host, pass its generated `ansible-vars.yml` with `-e @/path/to/ansible-vars.yml`. Details are in `bootstrap/host/README.md`. -The default kubeconfig path is `/home/jv/.kube/config`. Override it with -`KUBECONFIG_PATH` or `TF_VAR_kubeconfig_path` when needed. +The selected profile declares its kubeconfig path. Keep `KUBECONFIG`, +`KUBECONFIG_PATH`, `LAB_KUBECONFIG_PATH` and `TF_VAR_kubeconfig_path` aligned if +you set overrides; an override does not replace the pinned identity checks. ## Implementation Language Policy @@ -45,12 +142,10 @@ task instead of defaulting to Bash. ## Version Discipline -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. +Each cluster should use compatible API server and kubelet versions. The +kubeadm profiles use the `v1.36` image line; native K3s currently pins +`v1.31.5+k3s1`. These are independent clusters, not mixed-version nodes in one +cluster. Changing profiles must not join old workers to the new native runtime. Check node versions from the Debian host: @@ -61,237 +156,9 @@ Check node versions from the Debian host: The check prints the API server, kubelet versions, kubelet minors, and containerd runtimes. It exits nonzero when kubelet minors differ from the API server minor or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./jeannie rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./jeannie ai-evals run -``` - -Use `./jeannie ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./jeannie prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./jeannie incident replay -./jeannie incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./jeannie safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./jeannie impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./jeannie agent-sandbox check "./jeannie status" -./jeannie agent-sandbox check "./jeannie nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./jeannie ai-scheduler recommend small-rag -./jeannie ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./jeannie ask --citations "how do I recover the cluster?" -./jeannie ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./jeannie red-blue plan -./jeannie red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./jeannie promote plan -./jeannie promote validate -./jeannie promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./jeannie status --heal-plan -./jeannie status --heal -./jeannie heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./jeannie status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./jeannie workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -### Alertmanager-driven first self-heal loop - -The first headless self-heal path is intentionally narrow and targets node image -filesystem pressure / `FreeDiskSpaceFailed` symptoms. Alertmanager can call the -Debian-hosted `jeannie-eventd` webhook. For a disk-pressure alert, the webhook -maps the alert to the reporting Pimox worker and applies worker-scoped image and -old pod-log cleanup; other alerts still -flow through the guarded status/heal planner. - -For the first phase, the automatic mutations are: - -- prune unused container images and delete pod/container logs older than three - days on the alerting Pimox worker; -- delete stale Kubernetes pod records where the reason is `Evicted`, - `NodeLost`, `Unknown`, or `ContainerStatusUnknown`. - -It does not delete PVCs, delete namespaces, or mutate OpenTofu state. Disk cleanup -is limited to CRI image pruning and old pod/container logs; it does not touch -application data. Apply mode remains disabled unless `LAB_SELF_HEAL_APPLY=true`. - -Test the event pipeline without mutating anything: - -```bash -./jeannie self-heal dry-run infra/jeannie-eventd/free-disk-space-failed.sample.json -``` - -Preview stale pod cleanup directly: - -```bash -./jeannie heal cleanup-stale-pods -``` - -Apply the narrow cleanup when the dry-run targets are correct: - -```bash -./jeannie heal cleanup-stale-pods --yes -``` - -Run the webhook locally in dry-run mode: - -```bash -./jeannie self-heal serve -``` - -Install or refresh the Debian systemd webhook service through Jeannie: - -```bash -./jeannie self-heal install-service -``` - -Enable apply mode only after the dry-run output and audit files look correct: - -```bash -LAB_SELF_HEAL_APPLY=true ./jeannie self-heal serve -``` - -The systemd example binds the webhook to the Debian LAN address path so the -cluster can reach it. Keep it limited to the homelab network/firewall. - -Audit artifacts are written under: - -```text -${HOMELAB_STATE_DIR:-~/.local/share/homelab}/self-heal-events/ -``` - -The webhook also exposes Prometheus metrics at `/metrics`. The platform -Prometheus scrape config collects `192.168.100.73:18081`, and the -repo-provisioned `Homelab Self-Heal` Grafana dashboard shows event totals, -applied action totals, failed events, and alert counts. Rebuild dashboards -after pulling this change: - -```bash -./jeannie grafana-dashboards apply -``` - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./jeannie model-observe prompts -./jeannie model-observe run --offline -./jeannie model-observe report -``` - -Use `--live` only when Ollama is available. +this check before app deploys. Do not treat version drift as authorization to +destroy an enrolled cluster: automatic rebuild is refused because it changes +the pinned identity. Review any image, worker and re-enrollment transition first. ## Deploying @@ -305,7 +172,7 @@ cd ~/my-homelab-configs The script first deploys external Gitea to the Debian host with Docker Compose under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are +Pimox host at `192.168.100.80` in kubeadm mode. When SSH, `qm`, and `vmbr0` are available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 arm64 template, creates or reuses one worker VM clone, discovers the guest IP through qemu-guest-agent, and passes that worker into the cluster layer. It then @@ -314,6 +181,11 @@ local registry, builds the website and demos images when their source changed, pushes them to the registry, recreates pods only after a new image is built, and applies the edge stack. +For native K3s, worker/template provisioning and OpenWrt VM startup are skipped. +The selected native cluster is bootstrapped over SSH and uses the same platform +and application layers with live single-node scheduling checks. Run `up` only +after enrollment and after any existing transition has completed. + Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set `LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline keeps the template on its configured `local` storage, creates new worker VM @@ -744,11 +616,10 @@ default and lets SSH be the reachability check. Set `LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. `LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. +requires generated kubeadm/Pimox workers to be `Ready` with positive CPU +capacity. Native K3s ignores that old VM inventory and uses live scheduling +preflight. `LAB_PIMOX_APP_DEPLOY_MIN_CPUS` no longer sets a two-core floor; +the scheduling estimate determines whether each workload can fit. Long-running `./jeannie up` steps keep compact output by default, but the active step line refreshes with elapsed time and the latest log line. Set @@ -760,20 +631,13 @@ can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential execution while troubleshooting, or raise it above the default `4` if the lab can absorb more concurrent work. -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template with 2 cores, -8 GiB memory, and a 30 GiB default root disk, replaces two Pimox worker VMs with -2 cores, 8 GiB memory, and 30 GiB root disks, and joins those workers to the -Kubernetes cluster. Pimox 7 ARM does not support `qm --affinity`; Jeannie -instead starts the generated KVM command under CPU set `4-7` and verifies every -worker reports two guest CPUs before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. +VM profiles retain their template and worker lifecycle controls. Desired worker +size is two CPUs with 8 GiB memory and a 30 GiB default root disk; observed +capacity and reservations decide scheduling. CPU pinning uses a generated KVM +hook rather than unsupported `qm --affinity`. Native K3s skips this VM path. +The Raspberry Pi is excluded from worker generation unless explicitly enabled. +Automatic `rebuild-cluster` is refused for an enrolled identity; review any +destructive worker or control-plane replacement separately. To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, PV data, or VM disks, run: @@ -782,6 +646,13 @@ PV data, or VM disks, run: ./jeannie stop-cluster ``` +Behavior follows the selected profile: native K3s stops the Orange Pi service +and only its private workload process trees; Pimox stops its CP and worker VMs; +the hybrid Debian profile stops its local kubeadm runtime and worker VMs. +Starting a stopped cluster verifies the enrolled endpoint and CA offline, starts +the selected runtime, then verifies the live namespace UID before deployment. +It refuses to start alongside another profile. + This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully shuts down automated Pimox worker VMs. It intentionally leaves the host @@ -818,184 +689,10 @@ worker_nodes = { Stateful apps currently pin retained local PVs to the `debian` node. Move or duplicate those PV manifests when you want storage on another node. -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - ## Adding Platform Tools Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - ## Secrets Use SOPS with age for secrets that need to live in Git. The Debian host @@ -1011,2685 +708,107 @@ bootstrap installs `age` and `sops`; then run: Commit `.sops.yaml`, but keep the private age key outside the repo. Operational notes are in `docs/secrets.md`. -## Edge Services +## Guarded Self-Healing -The OCI jump box runs the public edge path: +Jeannie can turn status findings into an experimental self-heal plan: + +```bash +./jeannie status --heal-plan +./jeannie status --heal +./jeannie heal apply --yes +``` + +Normal `status` remains read-only. The heal planner maps known findings to +guarded actions, chooses one highest-impact auto-eligible finding, checks the +proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that +one action. Re-run `./jeannie status` after every heal cycle so Jeannie +can reassess before touching the next issue. If a specific Pimox worker is +NotReady, heal targets that worker with `./jeannie workers restart N` +instead of repeating a broad cluster start. After an action runs, Jeannie waits +for the target condition to clear and reports `healed` or `still failing`. +Failed heal actions are placed on a short cooldown so Jeannie does not loop on +the same VM restart; the next plan escalates to diagnostics instead. +Destructive actions remain blocked. + +### Alertmanager-driven first self-heal loop + +The first headless self-heal path is intentionally narrow and targets node image +filesystem pressure / `FreeDiskSpaceFailed` symptoms. Alertmanager can call the +Debian-hosted `jeannie-eventd` webhook. For a disk-pressure alert, the webhook +maps the alert to the reporting Pimox worker and applies worker-scoped image and +old pod-log cleanup; other alerts still +flow through the guarded status/heal planner. + +For the first phase, the automatic mutations are: + +- prune unused container images and delete pod/container logs older than three + days on the alerting Pimox worker; +- delete stale Kubernetes pod records where the reason is `Evicted`, + `NodeLost`, `Unknown`, or `ContainerStatusUnknown`. + +It does not delete PVCs, delete namespaces, or mutate OpenTofu state. Disk cleanup +is limited to CRI image pruning and old pod/container logs; it does not touch +application data. Apply mode remains disabled unless `LAB_SELF_HEAL_APPLY=true`. + +Test the event pipeline without mutating anything: + +```bash +./jeannie self-heal dry-run infra/jeannie-eventd/free-disk-space-failed.sample.json +``` + +Preview stale pod cleanup directly: + +```bash +./jeannie heal cleanup-stale-pods +``` + +Apply the narrow cleanup when the dry-run targets are correct: + +```bash +./jeannie heal cleanup-stale-pods --yes +``` + +Run the webhook locally in dry-run mode: + +```bash +./jeannie self-heal serve +``` + +Install or refresh the Debian systemd webhook service through Jeannie: + +```bash +./jeannie self-heal install-service +``` + +Enable apply mode only after the dry-run output and audit files look correct: + +```bash +LAB_SELF_HEAL_APPLY=true ./jeannie self-heal serve +``` + +The systemd example binds the webhook to the Debian LAN address path so the +cluster can reach it. Keep it limited to the homelab network/firewall. + +Audit artifacts are written under: ```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP +${HOMELAB_STATE_DIR:-~/.local/share/homelab}/self-heal-events/ ``` -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: +The webhook also exposes Prometheus metrics at `/metrics`. The platform +Prometheus scrape config collects `192.168.100.73:18081`, and the +repo-provisioned `Homelab Self-Heal` Grafana dashboard shows event totals, +applied action totals, failed events, and alert counts. Rebuild dashboards +after pulling this change: ```bash -./jeannie tailnet-policy-check +./jeannie grafana-dashboards apply ``` -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - ## Destructive Rebuilds -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./jeannie up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./jeannie up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./jeannie workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./jeannie doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./jeannie openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./jeannie up` -runs `./jeannie preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./jeannie preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./jeannie fix-debian-docker-root -``` - -When `./jeannie up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./jeannie rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB-memory worker VMs starting at VMID `9010`, worker clone storage -`opi5_ssd`, 30 GiB template/control-plane/worker root disks, and KVM launch -affinity `4-7` because this Pimox is pinned to Debian Bullseye on an Orange Pi -5 Plus. Jeannie launches the generated KVM command under that host CPU set so -PSCI can bring both guest CPUs online; it removes legacy `args` entries so -native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. Override -disk sizing with `LAB_PIMOX_TEMPLATE_DISK_GIB`, -`LAB_PIMOX_CONTROL_PLANE_DISK_GIB`, and `LAB_PIMOX_WORKER_DISK_GIB`; Jeannie -installs `cloud-guest-utils`, `e2fsprogs`, and `cri-tools`, resizes the Pimox -disk, and grows the guest root filesystem during the pipeline. The NVMe that -was previously attached to the Orange Pi now belongs to the HP Debian laptop as -LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox datastore is -`opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template with 2 cores, -8 GiB memory, and a 30 GiB default root disk, replaces two Pimox worker VMs with -2 cores, 8 GiB memory, and 30 GiB root disks, and joins those workers to the -Kubernetes cluster. Pimox 7 ARM does not support `qm --affinity`; Jeannie -instead starts the generated KVM command under CPU set `4-7` and verifies every -worker reports two guest CPUs before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./jeannie help -./jeannie status -./jeannie capacity -./jeannie capacity-advisor -./jeannie capacity-limits -./jeannie recover-plan -./jeannie recover-power --dry-run -./jeannie impact --since HEAD~1 -./jeannie review-last-change -./jeannie scorecard -./jeannie explain scorecard -./jeannie gitops-status -./jeannie cert-check -./jeannie grafana-dashboards list -./jeannie release-snapshot -./jeannie backup-status -./jeannie synthetic-checks -./jeannie resource-budget -./jeannie control-plane status -./jeannie artifact-cache status -./jeannie blockchain-devnet status -./jeannie blockchain-test -./jeannie blockchain-wallet instructions -./jeannie golden-ledger check -./jeannie route-inventory -./jeannie workers list -./jeannie change-journal list -./jeannie map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./jeannie status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./jeannie capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./jeannie impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./jeannie explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./jeannie explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./jeannie up` provisions -them through the platform stack; `./jeannie grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./jeannie resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./jeannie control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./jeannie up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./jeannie map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./jeannie doctor-edge -./jeannie doctor-gitea -./jeannie doctor-rpi -./jeannie doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./jeannie rpi-services -``` - -`./jeannie up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./jeannie status` and `./jeannie doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./jeannie up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB-memory worker VMs starting at VMID `9010`, worker clone storage -`opi5_ssd`, 30 GiB template/control-plane/worker root disks, and KVM launch -affinity `4-7` because this Pimox is pinned to Debian Bullseye on an Orange Pi -5 Plus. Jeannie launches the generated KVM command under that host CPU set so -PSCI can bring both guest CPUs online; it removes legacy `args` entries so -native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. Override -disk sizing with `LAB_PIMOX_TEMPLATE_DISK_GIB`, -`LAB_PIMOX_CONTROL_PLANE_DISK_GIB`, and `LAB_PIMOX_WORKER_DISK_GIB`; Jeannie -installs `cloud-guest-utils`, `e2fsprogs`, and `cri-tools`, resizes the Pimox -disk, and grows the guest root filesystem during the pipeline. The NVMe that -was previously attached to the Orange Pi now belongs to the HP Debian laptop as -LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox datastore is -`opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./jeannie apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./jeannie up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./jeannie rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template with 2 cores, -8 GiB memory, and a 30 GiB default root disk, replaces two Pimox worker VMs with -2 cores, 8 GiB memory, and 30 GiB root disks, and joins those workers to the -Kubernetes cluster. Pimox 7 ARM does not support `qm --affinity`; Jeannie -instead starts the generated KVM command under CPU set `4-7` and verifies every -worker reports two guest CPUs before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./jeannie stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./jeannie start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./jeannie move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./jeannie nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./jeannie apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./jeannie apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./jeannie secrets-init -./jeannie secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./jeannie tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./jeannie up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./jeannie deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./jeannie deploy-heimdall -``` - -`./jeannie up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./jeannie deploy-gitea -``` - -## Gitea Backups - -`./jeannie up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./jeannie backup-gitea -``` - -Run the restore drill manually with: - -```bash -./jeannie drill-gitea-restore -./jeannie drill-restore -./jeannie drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./jeannie backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./jeannie validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./jeannie validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./jeannie access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./jeannie kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `jeannie`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./jeannie doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./jeannie apps`; -if kubelet minor drift is detected it runs `./jeannie rebuild-cluster`; if no -kubeconfig exists it also runs `./jeannie rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./jeannie bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./jeannie install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./jeannie up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./jeannie website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./jeannie website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./jeannie ollama-setup -``` - -`jeannie` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./jeannie doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./jeannie ai-index -./jeannie ai-check -./jeannie ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./jeannie up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `jeannie` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `jeannie` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./jeannie apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Destructive Rebuilds - -`./jeannie nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. +Profile switching uses `stop-cluster` and the selected startup/bootstrap path; +it does not require `nuke`. Destructive actions require separate review of +identity, scoped state, retained storage and recovery. `rebuild-cluster` refuses +automatic destruction of an enrolled cluster because a rebuild changes its +identity. Preserve backups and plan re-enrollment before any such maintenance. diff --git a/docs/service-catalog.md b/docs/service-catalog.md index 012965f..357015d 100644 --- a/docs/service-catalog.md +++ b/docs/service-catalog.md @@ -12,7 +12,7 @@ Update `homelab.yml`, then run `scripts/render-service-catalog`. | debian | control-plane | 192.168.100.73 | 100.85.138.30 | /var/lib/docker | | rpi4 | dns-edge-worker | 192.168.100.89 | 100.77.80.72 | /nvme-storage/docker | | opi5_pimox | pimox | 192.168.100.80 | | opi5_ssd | -| oci_edge | public-edge | 132.145.170.74 | 100.118.255.19 | | +| oci_edge | public-edge | 132.145.170.74 | 100.122.188.79 | | ## Services diff --git a/docs/templates/ai-ops.md.tmpl b/docs/templates/ai-ops.md.tmpl index b8b9ddb..02e46a5 100644 --- a/docs/templates/ai-ops.md.tmpl +++ b/docs/templates/ai-ops.md.tmpl @@ -60,29 +60,6 @@ map to explicit heal/runbook commands, self-heal allowlists, or human-reviewed pipeline changes. This keeps the diagnostic layer read-only while still using Holmes to summarize likely root cause, impact, and next action. -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./{{ main_script }} doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./{{ main_script }} rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - ## AI Evals The repo includes a local eval harness for Jeannie explanations and homelab RAG @@ -234,15137 +211,3 @@ tool-correctness signals over time: ``` Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./{{ main_script }} doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./{{ main_script }} rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./{{ main_script }} ai-evals run -``` - -Use `./{{ main_script }} ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./{{ main_script }} prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./{{ main_script }} ai-evals run -``` - -Use `./{{ main_script }} ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./{{ main_script }} prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./{{ main_script }} prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. diff --git a/docs/templates/app-ops.md.tmpl b/docs/templates/app-ops.md.tmpl index 8ff0b68..48d55b7 100644 --- a/docs/templates/app-ops.md.tmpl +++ b/docs/templates/app-ops.md.tmpl @@ -1,5 +1,19 @@ # Application Operations +## Profile-aware application delivery + +Run app operations with the intended profile and its pinned kubeconfig. The +native Orange Pi target uses `LAB_CLUSTER_PROFILE=k3s` and +`KUBECONFIG="$HOME/.kube/opi5-k3s-config"`. Platform and Argo CD readiness must +complete before `./{{ main_script }} apps` runs. The transition command sequences +these stages and stops when a prerequisite fails. + +Application deployment verifies identity, renders scheduling estimates and +discovers retained registry placement. A one-core VM is allowed when its +reservations and placement permit the rollout; native K3s does not require old +Pimox worker inventory. See the [code map](code-map.md) and +[deployment gates](deployment.md#scheduling-and-deployment-gates). + ## Adding Apps Add Kubernetes manifests under `apps/` and register them in @@ -53,382 +67,19 @@ standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath data still lives under `/data/openebs/local`, and larger service data such as Gitea, Ollama models, and app volumes should stay under `/data`. -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. +Local PV data belongs to the host where its node affinity points. For native +K3s, the registry directory is on the Orange Pi, while Gitea and build data stay +on the laptop. The laptop-to-native transition copies a verified registry union +before native K3s starts, retains source/backup directories and writes a +profile-scoped receipt. The apps pipeline checks that receipt against live node +placement and storage before creating the registry PV. Different existing +remote data is refused rather than overwritten. + +The image endpoint remains `192.168.100.73:30500`; forwarding resolves the live +selected registry node across profiles. Old Jeannie-tagged forwarding rules are +retired before installing the selected route. Other laptop PVC contents are +preserved locally and are not automatically restored into the new cluster. +See [registry migration](../bootstrap/apps/README.md). ## Gitea @@ -635,1858 +286,6 @@ not auto-merge infrastructure changes. Keep app-only dependency updates on the normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server for platform or provisioning updates. -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. ## Website App The website is a PHP app under `apps/website`. It includes a home page, CV page, diff --git a/docs/templates/architecture.md.tmpl b/docs/templates/architecture.md.tmpl index e8c3bd2..ad604d5 100644 --- a/docs/templates/architecture.md.tmpl +++ b/docs/templates/architecture.md.tmpl @@ -7,8 +7,9 @@ The lab is intentionally small but production-shaped: - Debian remains the always-on operations host for Jeannie, Docker builds, external Gitea, the GitOps mirror, the local registry endpoint, Ollama, OmniRoute, and AI tool wrappers -- Kubernetes capacity now comes from Pimox Debian arm64 VMs on the Orange Pi 5 - Plus, with one control-plane VM and worker VMs managed as rebuildable capacity +- Kubernetes has three selectable profiles: a laptop kubeadm control plane with + Pimox workers, an entirely virtualized Pimox kubeadm cluster, and native K3s + on the Orange Pi 5 Plus. Only one profile may run at a time - a Raspberry Pi arm64 host runs selected support services outside the Kubernetes rebuild blast radius - the Debian host also runs the always-on Gitea Docker service outside @@ -37,7 +38,7 @@ The lab is intentionally small but production-shaped: ## Inventory -The canonical non-secret inventory is [homelab.yml](homelab.yml). Keep LAN IPs, +The canonical non-secret inventory is [homelab.yml](../homelab.yml). Keep LAN IPs, Tailscale IPs, public hostnames, ports, storage paths, and service ownership there before copying values into scripts, OpenTofu variables, runbooks, or service docs. Secrets and tokens do not belong in that file. @@ -46,32 +47,41 @@ service docs. Secrets and tokens do not belong in that file. variables for the edge, provisioning, cluster, platform, and apps stacks. This keeps values such as the Debian LAN IP, Debian Tailscale IP, RPi LAN IP, OCI IP, Traefik MetalLB IP, and domain name from drifting across scripts and templates. -`scripts/render-docs` also renders [docs/service-catalog.md](docs/service-catalog.md) +`scripts/render-docs` also renders [the service catalog](service-catalog.md) and the static service catalog page at `apps/demos-static/public/homelab-catalog/index.html` from the same inventory. -Run `./{{ main_script }} up` and `./{{ main_script }} nuke` only from the Debian homelab server. The -script intentionally refuses to run from non-Debian machines so a laptop cannot -accidentally modify the cluster. +Run deployment commands from the Debian operations laptop at `.73`, or through +its allowlisted API. The development laptop is a separate client. Host checks +and pinned cluster identities prevent an unintended local deployment target. ## Flow +The [code map](code-map.md) traces these layers to the actual entrypoints. +`lib/jeannie/env.sh` is the shared inventory loader; `pipeline.sh` uses that +loader rather than maintaining a second copy of profile defaults. + 1. `bootstrap/provisioning` - prepares a Debian server as a PXE and preseed service for arm64 VMs - serves Debian 13 arm64 netboot assets through TFTP and HTTP - exposes a PXE rescue menu and HTTP rescue page for manual repair paths - creates a golden image install path with Kubernetes, containerd, qemu-guest-agent, cloud-init, and storage client packages ready - - is driven by `./{{ main_script }} up` when Pimox is reachable, without changing - Orange Pi host networking + - is used by the kubeadm VM profiles; native K3s skips worker provisioning + and OpenWrt VM startup, preserving Orange Pi host networking 2. `bootstrap/cluster` - - creates the kubeadm control plane on the Debian amd64 node - - joins worker nodes such as Raspberry Pi and Pimox Debian arm64 nodes + - installs the selected runtime: kubeadm on the laptop or Pimox CP VM, + or K3s directly on the Orange Pi host + - joins Pimox workers for the kubeadm profiles; native K3s is single-node - configures Calico-compatible pod CIDR - configures containerd to pull from the in-cluster NodePort registry - creates retained host directories under `/data/openebs/local` + Native K3s disables packaged Traefik, ServiceLB and metrics-server so the + platform can own ingress, MetalLB and metrics-server. Existing externally + managed metrics-server installations are discovered and reused. + 3. `bootstrap/platform` - installs a minimal Calico deployment through the Tigera operator - installs NodeLocal DNSCache for node-local DNS query caching @@ -114,6 +124,36 @@ accidentally modify the cluster. - enables gzip, HTTP/2, TLS session reuse, client keepalive, upstream keepalive, and cache headers for the public website path +## Profile isolation and switching + +| Profile | API | Runtime placement | +| --- | --- | --- | +| `debian` | `https://192.168.100.73:6443` | Laptop CP, worker VMs 9010/9011 | +| `pimox` | `https://192.168.100.65:6443` | CP VM 9001, worker VMs 9010/9011 | +| `k3s` | `https://192.168.100.80:6443` | Native Orange Pi host, node `opi5plus` | + +`cluster-runtime-guard.py` probes both physical hosts, API listeners, K3s +workload processes and Pimox VM power state. Deployment/start pipelines hold a +shared lock and refuse conflicts. This does not prevent manual starts outside +Jeannie. Switching modes requires stopping the previous runtime first. + +`cluster-context.py` binds each profile to its API endpoint, CA fingerprint and +`kube-system` UID. Its state root is +`~/.local/share/homelab/clusters//`, with `identity.json` and separate +`stacks/{cluster,platform,apps}/terraform.tfstate` files. Stopped-cluster startup +checks endpoint/CA offline, then checks live UID after startup. Deployment, +import, cleanup and healing retain live identity checks. + +Retained local PVs remain tied to their host and data path. A different profile +does not automatically inherit the old cluster's volume contents. The laptop +K3s transition verifies and copies registry data before host K3s starts, archives +the old identity/state and datastore, and enrolls a new identity on the Orange +Pi. Other laptop PVC data stays on the laptop pending a separate restore. + +On November 2, 2026, the native `opi5plus` node reported Ready. Platform/apps +completion must be checked independently; source support is not proof of a +successful live deployment. + ## Pimox Migration Lessons The Pimox migration moved Kubernetes workloads away from the old Debian-hosted @@ -123,9 +163,10 @@ gateway, and recovery commands. Pimox VMs provide disposable Kubernetes capacity Operational lessons now encoded in Jeannie: -- Preserve two guest CPUs per Pimox VM. The Orange Pi 5 Plus has mixed core - classes, so the VMs are pinned to the big-core CPU set with a Proxmox hook - script instead of shrinking workers to one Kubernetes CPU. +- Two guest CPUs per Pimox VM remain the desired topology. Runtime scheduling + checks use actual capacity and reservations; an existing one-core worker is + not silently treated as a two-core VM or blocked solely by a two-core floor. + The VM path supports big-core pinning through a Proxmox hook script. - Treat VM disks as rebuildable. Durable application data belongs on retained OpenEBS paths, host-level `/data`, or backups, not inside an untracked VM root disk. @@ -139,743 +180,6 @@ Operational lessons now encoded in Jeannie: pods. App deploys include deterministic stale-pod and unused image cleanup rather than relying on manual `kubectl delete` or node shell history. -## Prerequisites - -On the Debian host: - -- OpenTofu -- Docker with Buildx -- kubeadm, kubelet, kubectl, and containerd pinned to the target Kubernetes - minor, currently `v1.36` -- SSH access to worker nodes -- SSH access to the OCI edge host -- Go toolchain for Jeannie core helpers; `./{{ main_script }} up` installs - `golang-go` on the Debian host if it is missing -- enough persistent storage for `/data/openebs/local` and Docker's data root - -After a clean Debian reinstall, bootstrap the host package set and desktop -configuration first: - -```bash -sudo apt-get update -sudo apt-get install -y git ansible sudo -git clone /home/jv/my-homelab-configs -cd /home/jv/my-homelab-configs -ansible-playbook -K -i bootstrap/host/inventory.ini bootstrap/host/playbook.yml -``` - -If you kept the private app-config archive generated from the old Debian host, -pass its generated `ansible-vars.yml` with `-e @/path/to/ansible-vars.yml`. -Details are in `bootstrap/host/README.md`. - -The default kubeconfig path is `/home/jv/.kube/config`. Override it with -`KUBECONFIG_PATH` or `TF_VAR_kubeconfig_path` when needed. - -## Implementation Language Policy - -Jeannie keeps `./{{ main_script }}` as the stable command entrypoint. New durable -read-only orchestration, report rendering, inventory parsing, status/doctor -logic, and self-heal planning should prefer Go under `cmd/jeannie-core` because -it ships as one small binary and is easier to test than Bash. Bash remains for -thin compatibility wrappers and remote shell glue. Python remains acceptable for -AI/RAG, data-heavy utilities, or cases where an existing Python ecosystem is the -clear fit. New repo features should choose the smallest language that fits the -task instead of defaulting to Bash. - -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./{{ main_script }} doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./{{ main_script }} rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./{{ main_script }} ai-evals run -``` - -Use `./{{ main_script }} ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./{{ main_script }} prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - ## Workload Placement `bootstrap/cluster` labels nodes with homelab placement metadata: @@ -896,12 +200,13 @@ the physical layout changes. The current website, demos, and registry manifests are not moved automatically because the public NodePort path and retained OpenEBS hostpath PVs are node-local. Move workloads only after their storage and edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. +through its Debian-host Compose deployment instead. -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. +Platform controllers use `homelab.dev/workload-class=platform`. Multi-node +profiles retain worker placement, topology spread and preferred anti-affinity; +single-node profiles reconcile that platform label on their selected control +plane. Scheduling preflight checks the live labels instead of assuming a VM +worker exists in a native K3s cluster. PVC-backed monitoring StatefulSets are intentionally treated separately because their retained OpenEBS hostpath volumes are node-local. Run `./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing @@ -983,10 +288,6 @@ For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated li remote SSH targets when more worker nodes exist. Set it to an empty string for a single-node rebuild. -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - ## Policy Guardrails `bootstrap/platform` installs Kyverno and the upstream baseline Pod Security @@ -1054,5112 +355,6 @@ Ingress objects. The local registry remains a `NodePort` because the cluster nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; they run on the Debian Docker host. -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Flow - -1. `bootstrap/provisioning` - - prepares a Debian server as a PXE and preseed service for arm64 VMs - - serves Debian 13 arm64 netboot assets through TFTP and HTTP - - exposes a PXE rescue menu and HTTP rescue page for manual repair paths - - creates a golden image install path with Kubernetes, containerd, - qemu-guest-agent, cloud-init, and storage client packages ready - - is driven by `./{{ main_script }} up` when Pimox is reachable, without changing - Orange Pi host networking - -2. `bootstrap/cluster` - - creates the kubeadm control plane on the Debian amd64 node - - joins worker nodes such as Raspberry Pi and Pimox Debian arm64 nodes - - configures Calico-compatible pod CIDR - - configures containerd to pull from the in-cluster NodePort registry - - creates retained host directories under `/data/openebs/local` - -3. `bootstrap/platform` - - installs a minimal Calico deployment through the Tigera operator - - installs NodeLocal DNSCache for node-local DNS query caching - - installs MetalLB for LAN `LoadBalancer` services - - installs Traefik as the single Kubernetes ingress entry point - - installs OpenEBS - - creates `openebs-hostpath-retain` - - installs Argo CD - - installs Kyverno with audit-first baseline Pod Security policies and - homelab image signature/SBOM admission controls - - registers the private GitOps repo without storing the SSH private key in - Terraform state - -4. `bootstrap/apps` - - registers Argo CD Applications from the `applications` map - - passes the website image produced by the build step into Argo CD as a - Kustomize image override - - deploys the tuned website runtime: Apache listens on port 8080, PHP-FPM - listens on loopback inside the container, OPcache is enabled, and - pre-rendered HTML handles the read-heavy pages - - default apps are `container-registry`, `website-production`, - `demos-static`, the `heimdall` route bundle, `n8n`, and - `supply-chain-policy` - -5. `bootstrap/edge` - - connects to the OCI jump box - - uploads nginx, HAProxy, Varnish, and Squid configs - - obtains and renews Let's Encrypt certificates for the configured hostname - - runs the edge cache/proxy chain with Docker Compose - - enables gzip, HTTP/2, TLS session reuse, client keepalive, upstream - keepalive, and cache headers for the public website path - -## Prerequisites - -On the Debian host: - -- OpenTofu -- Docker with Buildx -- kubeadm, kubelet, kubectl, and containerd pinned to the target Kubernetes - minor, currently `v1.36` -- SSH access to worker nodes -- SSH access to the OCI edge host -- Go toolchain for Jeannie core helpers; `./{{ main_script }} up` installs - `golang-go` on the Debian host if it is missing -- enough persistent storage for `/data/openebs/local` and Docker's data root - -After a clean Debian reinstall, bootstrap the host package set and desktop -configuration first: - -```bash -sudo apt-get update -sudo apt-get install -y git ansible sudo -git clone /home/jv/my-homelab-configs -cd /home/jv/my-homelab-configs -ansible-playbook -K -i bootstrap/host/inventory.ini bootstrap/host/playbook.yml -``` - -If you kept the private app-config archive generated from the old Debian host, -pass its generated `ansible-vars.yml` with `-e @/path/to/ansible-vars.yml`. -Details are in `bootstrap/host/README.md`. - -The default kubeconfig path is `/home/jv/.kube/config`. Override it with -`KUBECONFIG_PATH` or `TF_VAR_kubeconfig_path` when needed. - -## Implementation Language Policy - -Jeannie keeps `./{{ main_script }}` as the stable command entrypoint. New durable -read-only orchestration, report rendering, inventory parsing, status/doctor -logic, and self-heal planning should prefer Go under `cmd/jeannie-core` because -it ships as one small binary and is easier to test than Bash. Bash remains for -thin compatibility wrappers and remote shell glue. Python remains acceptable for -AI/RAG, data-heavy utilities, or cases where an existing Python ecosystem is the -clear fit. New repo features should choose the smallest language that fits the -task instead of defaulting to Bash. - -## Version Discipline - -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. - -Check node versions from the Debian host: - -```bash -./{{ main_script }} doctor-versions -``` - -The check prints the API server, kubelet versions, kubelet minors, and containerd -runtimes. It exits nonzero when kubelet minors differ from the API server minor -or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./{{ main_script }} rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./{{ main_script }} ai-evals run -``` - -Use `./{{ main_script }} ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./{{ main_script }} prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. - -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB worker VMs starting at VMID `9010`, worker clone storage `opi5_ssd`, -and KVM launch affinity `4-7` because this Pimox is pinned to Debian Bullseye -on an Orange Pi 5 Plus. Jeannie launches the generated KVM command under that -host CPU set so PSCI can bring both guest CPUs online; it removes legacy `args` -entries so native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. The NVMe -that was previously attached to the Orange Pi now belongs to the HP Debian -laptop as LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox -datastore is `opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template -with 2 cores and 8 GiB memory, replaces two Pimox worker VMs with 2 cores and -8 GiB memory, and joins those workers to the Kubernetes cluster. Pimox 7 ARM -does not support `qm --affinity`; Jeannie instead starts the generated KVM -command under CPU set `4-7` and verifies every worker reports two guest CPUs -before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. ## Edge Services The OCI jump box runs the public edge path: diff --git a/docs/templates/deployment.md.tmpl b/docs/templates/deployment.md.tmpl index 2a62f20..3595275 100644 --- a/docs/templates/deployment.md.tmpl +++ b/docs/templates/deployment.md.tmpl @@ -1,13 +1,109 @@ # Homelab Deployment Guide +## Select and verify a profile + +Jeannie runs from the Debian operations laptop. Choose one of the three +[cluster profiles](architecture.md#profile-isolation-and-switching) explicitly; +the committed inventory default remains `pimox`. + +| Profile | Runtime | Kubeconfig | +| --- | --- | --- | +| `debian` | Laptop kubeadm CP and two Pimox workers | `~/.kube/config` | +| `pimox` | Pimox CP VM and two worker VMs | `~/.kube/pimox-config` | +| `k3s` | Native Orange Pi host | `~/.kube/opi5-k3s-config` | + +For the already enrolled native cluster: + +```bash +export LAB_CLUSTER_PROFILE=k3s +export LAB_CLUSTER_RUNTIME=k3s +export TF_VAR_cluster_runtime=k3s +export KUBECONFIG="$HOME/.kube/opi5-k3s-config" +./{{ main_script }} cluster-profile +./{{ main_script }} cluster-context check +./{{ main_script }} cluster-runtime check +``` + +When changing profiles, clear stale runtime, kubeconfig, host and `TF_VAR_*` +overrides first. The runtime guard rejects conflicting runtime overrides rather +than assuming that an old shell environment describes the new profile. + +Before an apply, import, cleanup or healing action, Jeannie checks the selected +API endpoint, CA fingerprint and `kube-system` UID against its enrolled identity. +Review `cluster-context enroll`, verify the identity independently on the target +host, then use `enroll --yes` for a new cluster. Do not reuse another cluster's +identity or copy its scoped state into a fresh profile. The +[identity guide](cluster-context.md) explains reviewed legacy state migration. + +Deployment/start pipelines also check conflicting services, K3s workload +processes and VM state, and hold a cross-profile runtime lock. Native K3s +requires every Pimox VM stopped. The kubeadm modes require native host K3s +stopped, plus the other profile's control plane stopped. Runtime probe failures +block deployment. Stop the selected old mode with `stop-cluster` before switching. + +## Move laptop K3s to the Orange Pi + +The accidental K3s deployment on `.73` is retired through a resumable transition +to the declared native host `.80`. Run this on the Debian laptop: + +```bash +cd ~/my-homelab-configs +git pull --ff-only gitea main +./{{ main_script }} cluster-transition k3s-to-native +./{{ main_script }} cluster-transition k3s-to-native --yes +``` + +The first invocation prints the plan; `--yes` stops and disables laptop K3s, +stops only its private workload process trees, backs up its server datastore and +configuration, archives its scoped identity/state, and gracefully stops Pimox +VMs. It prepares a checksum-verified registry copy on the Orange Pi before +native K3s starts. Existing different remote data is preserved and blocks copying. +The worker used as a registry source can be started temporarily, then stopped. + +The command bootstraps the native cluster, compares its API identity with direct +SSH reads from the Orange Pi, enrolls that identity, then runs `platform all` +and `apps` in sequence. It stops on failure. Repeat the same command to resume; +do not delete the private transition journal or scoped state to force a retry. +It is also API-allowlisted after rebuilding the API binary. + +Old state is retained under `~/.local/share/homelab/retired-clusters/` and the +stopped datastore archive under `/var/backups/jeannie-k3s-laptop-*`. The journal +is `~/.local/share/homelab/transitions/k3s-to-native.json`. Other laptop PVC data +stays on the laptop: this copies registry data, not all application databases. +See [registry transition details](../bootstrap/apps/README.md). + +The native `opi5plus` node has reported Ready. Platform and apps completion +remain separate checks. Do not run another deployment alongside the transition. + +## Scheduling and deployment gates + +Before platform/apps apply, `scripts/scheduling-preflight.py` renders planned +Helm and Argo sources and compares requests with allocatable resources and live +reservations. It checks selectors, taints, affinity, host ports, PV placement +and rollout budgets. Low current CPU usage does not free CPU reservations. +One-core nodes can run workloads when the reservations and placement fit. + +Fresh operator workloads can use an explicit estimate of primary resources; +generated sidecars and volumes still require post-apply readiness checks. +Missing CNI is treated as initial bootstrap only when the Calico creation plan +and live node state establish that case. Existing CNI failures remain blockers. +Single-node platform labels target the selected node across runtimes. + +Follow the [code map](code-map.md) for the actual guard, backend and storage +entrypoints. Recognized transient transport failures have bounded retries; +identity, ownership, configuration and scheduling errors require correction. +Init diagnostics are private under the selected profile's `diagnostics/`. +Do not fix a scoped backend failure by forcing a legacy state copy. + ## Prerequisites On the Debian host: - OpenTofu - Docker with Buildx -- kubeadm, kubelet, kubectl, and containerd pinned to the target Kubernetes - minor, currently `v1.36` +- kubectl and Python with PyYAML for profile, identity and scheduling helpers +- kubeadm, kubelet and containerd for kubeadm profiles; native K3s is installed + remotely by the cluster layer and uses its own runtime - SSH access to worker nodes - SSH access to the OCI edge host - Go toolchain for Jeannie core helpers; `./{{ main_script }} up` installs @@ -29,8 +125,9 @@ If you kept the private app-config archive generated from the old Debian host, pass its generated `ansible-vars.yml` with `-e @/path/to/ansible-vars.yml`. Details are in `bootstrap/host/README.md`. -The default kubeconfig path is `/home/jv/.kube/config`. Override it with -`KUBECONFIG_PATH` or `TF_VAR_kubeconfig_path` when needed. +The selected profile declares its kubeconfig path. Keep `KUBECONFIG`, +`KUBECONFIG_PATH`, `LAB_KUBECONFIG_PATH` and `TF_VAR_kubeconfig_path` aligned if +you set overrides; an override does not replace the pinned identity checks. ## Implementation Language Policy @@ -45,12 +142,10 @@ task instead of defaulting to Bash. ## Version Discipline -The lab should converge on one Kubernetes minor across the API server and every -kubelet. The Pimox golden-image default is `v1.36` so rebuilt arm64 VM workers -match the Debian control plane and Raspberry Pi worker instead of staying on an -older template. Avoid treating a three-minor kubelet skew as normal steady -state: it is only a temporary compatibility window and blocks the next control -plane upgrade. +Each cluster should use compatible API server and kubelet versions. The +kubeadm profiles use the `v1.36` image line; native K3s currently pins +`v1.31.5+k3s1`. These are independent clusters, not mixed-version nodes in one +cluster. Changing profiles must not join old workers to the new native runtime. Check node versions from the Debian host: @@ -61,237 +156,9 @@ Check node versions from the Debian host: The check prints the API server, kubelet versions, kubelet minors, and containerd runtimes. It exits nonzero when kubelet minors differ from the API server minor or when containerd major versions are mixed. The Gitea Actions auto path runs -this check before app deploys; kubelet minor drift switches the job to -`./{{ main_script }} rebuild-cluster` so the Pimox template and worker VMs are replaced -from the pinned image. For Pimox workers, prefer rebuilding from the corrected -golden template and rejoining the worker over ad hoc live package upgrades. - -## AI Evals - -The repo includes a local eval harness for Jeannie explanations and homelab RAG -grounding. It uses fixtures and allowlisted read-only commands, so it is safe to -run before changing the lab: - -```bash -./{{ main_script }} ai-evals run -``` - -Use `./{{ main_script }} ai-evals list` to see the current cases. Add new cases -under `infra/ai-evals` whenever a troubleshooting pattern or runbook behavior -should become repeatable. - -## Prompt Injection Lab - -The defensive security training path includes local prompt-injection fixtures -for hostile runbooks, tool output, dashboard annotations, and command arguments. -Run it without touching live infrastructure: - -```bash -./{{ main_script }} prompt-injection-lab run -``` - -Cases live under `security/prompt-injection-lab` and are meant to become -regression tests for future Jeannie AI features. - -## Incident Commander - -The repo also includes a read-only incident commander trainer. It classifies -pasted failure text, prints a likely hypothesis, links the right runbook, and -lists the next read-only Jeannie commands: - -```bash -./{{ main_script }} incident replay -./{{ main_script }} incident triage --text "502 Bad Gateway from nginx" -``` - -Incident fixtures live under `infra/incident-commander`. Use them to turn -repeat outages into repeatable triage behavior before adding any self-healing. - -## Safety Cases - -Before high-blast-radius changes, generate a safety case from the Git diff: - -```bash -./{{ main_script }} safety-case --since HEAD~1 -``` - -It summarizes risk, blast radius, required validation, rollback, and forbidden -actions. The implementation lives under `infra/safety-cases` and reuses the -same impact rules as `./{{ main_script }} impact`. - -## Agent Sandbox - -Future Jeannie AI actions should be checked before execution. The local sandbox -policy starts with a read-only command classifier: - -```bash -./{{ main_script }} agent-sandbox check "./{{ main_script }} status" -./{{ main_script }} agent-sandbox check "./{{ main_script }} nuke" -``` - -Policy is stored in `infra/agent-sandbox/policy.tsv`. - -## AI Workload Scheduling - -For AI-ish workloads, Jeannie can simulate placement across Debian, Pimox -workers, and the RPi based on CPU, memory, architecture, tailnet access, and -control-plane policy: - -```bash -./{{ main_script }} ai-scheduler recommend small-rag -./{{ main_script }} ai-scheduler simulate -``` - -The simulator lives under `infra/ai-scheduler` and is a stepping stone toward a -real Kubernetes controller. - -## Memory With Provenance - -Jeannie can return cited retrieval context and check whether the local RAG index -is stale: - -```bash -./{{ main_script }} ask --citations "how do I recover the cluster?" -./{{ main_script }} ai-memory check -``` - -This keeps local AI answers grounded in repo files and runbooks. - -## Red/Blue Loop - -Safe red-team/blue-team checks are grouped under one command: - -```bash -./{{ main_script }} red-blue plan -./{{ main_script }} red-blue run --local -``` - -Local mode runs deterministic prompt-injection and eval checks. Live scans are -listed but gated so they can run from the Debian host when intended. - -## Canary Promotion - -The promotion helper defines release gates before production changes: - -```bash -./{{ main_script }} promote plan -./{{ main_script }} promote validate -./{{ main_script }} promote rollback website-production -``` - -The current version is intentionally conservative: it validates local gates and -prints rollback steps while dev namespace automation remains explicit future -work. - -## Guarded Self-Healing - -Jeannie can turn status findings into an experimental self-heal plan: - -```bash -./{{ main_script }} status --heal-plan -./{{ main_script }} status --heal -./{{ main_script }} heal apply --yes -``` - -Normal `status` remains read-only. The heal planner maps known findings to -guarded actions, chooses one highest-impact auto-eligible finding, checks the -proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that -one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie -can reassess before touching the next issue. If a specific Pimox worker is -NotReady, heal targets that worker with `./{{ main_script }} workers restart N` -instead of repeating a broad cluster start. After an action runs, Jeannie waits -for the target condition to clear and reports `healed` or `still failing`. -Failed heal actions are placed on a short cooldown so Jeannie does not loop on -the same VM restart; the next plan escalates to diagnostics instead. -Destructive actions remain blocked. - -### Alertmanager-driven first self-heal loop - -The first headless self-heal path is intentionally narrow and targets node image -filesystem pressure / `FreeDiskSpaceFailed` symptoms. Alertmanager can call the -Debian-hosted `jeannie-eventd` webhook. For a disk-pressure alert, the webhook -maps the alert to the reporting Pimox worker and applies worker-scoped image and -old pod-log cleanup; other alerts still -flow through the guarded status/heal planner. - -For the first phase, the automatic mutations are: - -- prune unused container images and delete pod/container logs older than three - days on the alerting Pimox worker; -- delete stale Kubernetes pod records where the reason is `Evicted`, - `NodeLost`, `Unknown`, or `ContainerStatusUnknown`. - -It does not delete PVCs, delete namespaces, or mutate OpenTofu state. Disk cleanup -is limited to CRI image pruning and old pod/container logs; it does not touch -application data. Apply mode remains disabled unless `LAB_SELF_HEAL_APPLY=true`. - -Test the event pipeline without mutating anything: - -```bash -./{{ main_script }} self-heal dry-run infra/jeannie-eventd/free-disk-space-failed.sample.json -``` - -Preview stale pod cleanup directly: - -```bash -./{{ main_script }} heal cleanup-stale-pods -``` - -Apply the narrow cleanup when the dry-run targets are correct: - -```bash -./{{ main_script }} heal cleanup-stale-pods --yes -``` - -Run the webhook locally in dry-run mode: - -```bash -./{{ main_script }} self-heal serve -``` - -Install or refresh the Debian systemd webhook service through Jeannie: - -```bash -./{{ main_script }} self-heal install-service -``` - -Enable apply mode only after the dry-run output and audit files look correct: - -```bash -LAB_SELF_HEAL_APPLY=true ./{{ main_script }} self-heal serve -``` - -The systemd example binds the webhook to the Debian LAN address path so the -cluster can reach it. Keep it limited to the homelab network/firewall. - -Audit artifacts are written under: - -```text -${HOMELAB_STATE_DIR:-~/.local/share/homelab}/self-heal-events/ -``` - -The webhook also exposes Prometheus metrics at `/metrics`. The platform -Prometheus scrape config collects `192.168.100.73:18081`, and the -repo-provisioned `Homelab Self-Heal` Grafana dashboard shows event totals, -applied action totals, failed events, and alert counts. Rebuild dashboards -after pulling this change: - -```bash -./{{ main_script }} grafana-dashboards apply -``` - -## Model Behavior Observatory - -Stable prompts track local model behavior, latency, refusal behavior, and -tool-correctness signals over time: - -```bash -./{{ main_script }} model-observe prompts -./{{ main_script }} model-observe run --offline -./{{ main_script }} model-observe report -``` - -Use `--live` only when Ollama is available. +this check before app deploys. Do not treat version drift as authorization to +destroy an enrolled cluster: automatic rebuild is refused because it changes +the pinned identity. Review any image, worker and re-enrollment transition first. ## Deploying @@ -305,7 +172,7 @@ cd ~/my-homelab-configs The script first deploys external Gitea to the Debian host with Docker Compose under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are +Pimox host at `192.168.100.80` in kubeadm mode. When SSH, `qm`, and `vmbr0` are available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 arm64 template, creates or reuses one worker VM clone, discovers the guest IP through qemu-guest-agent, and passes that worker into the cluster layer. It then @@ -314,6 +181,11 @@ local registry, builds the website and demos images when their source changed, pushes them to the registry, recreates pods only after a new image is built, and applies the edge stack. +For native K3s, worker/template provisioning and OpenWrt VM startup are skipped. +The selected native cluster is bootstrapped over SSH and uses the same platform +and application layers with live single-node scheduling checks. Run `up` only +after enrollment and after any existing transition has completed. + Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set `LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline keeps the template on its configured `local` storage, creates new worker VM @@ -744,11 +616,10 @@ default and lets SSH be the reachability check. Set `LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. `LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. +requires generated kubeadm/Pimox workers to be `Ready` with positive CPU +capacity. Native K3s ignores that old VM inventory and uses live scheduling +preflight. `LAB_PIMOX_APP_DEPLOY_MIN_CPUS` no longer sets a two-core floor; +the scheduling estimate determines whether each workload can fit. Long-running `./{{ main_script }} up` steps keep compact output by default, but the active step line refreshes with elapsed time and the latest log line. Set @@ -760,20 +631,13 @@ can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential execution while troubleshooting, or raise it above the default `4` if the lab can absorb more concurrent work. -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template with 2 cores, -8 GiB memory, and a 30 GiB default root disk, replaces two Pimox worker VMs with -2 cores, 8 GiB memory, and 30 GiB root disks, and joins those workers to the -Kubernetes cluster. Pimox 7 ARM does not support `qm --affinity`; Jeannie -instead starts the generated KVM command under CPU set `4-7` and verifies every -worker reports two guest CPUs before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. +VM profiles retain their template and worker lifecycle controls. Desired worker +size is two CPUs with 8 GiB memory and a 30 GiB default root disk; observed +capacity and reservations decide scheduling. CPU pinning uses a generated KVM +hook rather than unsupported `qm --affinity`. Native K3s skips this VM path. +The Raspberry Pi is excluded from worker generation unless explicitly enabled. +Automatic `rebuild-cluster` is refused for an enrolled identity; review any +destructive worker or control-plane replacement separately. To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, PV data, or VM disks, run: @@ -782,6 +646,13 @@ PV data, or VM disks, run: ./{{ main_script }} stop-cluster ``` +Behavior follows the selected profile: native K3s stops the Orange Pi service +and only its private workload process trees; Pimox stops its CP and worker VMs; +the hybrid Debian profile stops its local kubeadm runtime and worker VMs. +Starting a stopped cluster verifies the enrolled endpoint and CA offline, starts +the selected runtime, then verifies the live namespace UID before deployment. +It refuses to start alongside another profile. + This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully shuts down automated Pimox worker VMs. It intentionally leaves the host @@ -818,184 +689,10 @@ worker_nodes = { Stateful apps currently pin retained local PVs to the `debian` node. Move or duplicate those PV manifests when you want storage on another node. -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - ## Adding Platform Tools Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - ## Secrets Use SOPS with age for secrets that need to live in Git. The Debian host @@ -1011,2685 +708,107 @@ bootstrap installs `age` and `sops`; then run: Commit `.sops.yaml`, but keep the private age key outside the repo. Operational notes are in `docs/secrets.md`. -## Edge Services +## Guarded Self-Healing -The OCI jump box runs the public edge path: +Jeannie can turn status findings into an experimental self-heal plan: + +```bash +./{{ main_script }} status --heal-plan +./{{ main_script }} status --heal +./{{ main_script }} heal apply --yes +``` + +Normal `status` remains read-only. The heal planner maps known findings to +guarded actions, chooses one highest-impact auto-eligible finding, checks the +proposed command against `infra/agent-sandbox/policy.tsv`, and runs only that +one action. Re-run `./{{ main_script }} status` after every heal cycle so Jeannie +can reassess before touching the next issue. If a specific Pimox worker is +NotReady, heal targets that worker with `./{{ main_script }} workers restart N` +instead of repeating a broad cluster start. After an action runs, Jeannie waits +for the target condition to clear and reports `healed` or `still failing`. +Failed heal actions are placed on a short cooldown so Jeannie does not loop on +the same VM restart; the next plan escalates to diagnostics instead. +Destructive actions remain blocked. + +### Alertmanager-driven first self-heal loop + +The first headless self-heal path is intentionally narrow and targets node image +filesystem pressure / `FreeDiskSpaceFailed` symptoms. Alertmanager can call the +Debian-hosted `jeannie-eventd` webhook. For a disk-pressure alert, the webhook +maps the alert to the reporting Pimox worker and applies worker-scoped image and +old pod-log cleanup; other alerts still +flow through the guarded status/heal planner. + +For the first phase, the automatic mutations are: + +- prune unused container images and delete pod/container logs older than three + days on the alerting Pimox worker; +- delete stale Kubernetes pod records where the reason is `Evicted`, + `NodeLost`, `Unknown`, or `ContainerStatusUnknown`. + +It does not delete PVCs, delete namespaces, or mutate OpenTofu state. Disk cleanup +is limited to CRI image pruning and old pod/container logs; it does not touch +application data. Apply mode remains disabled unless `LAB_SELF_HEAL_APPLY=true`. + +Test the event pipeline without mutating anything: + +```bash +./{{ main_script }} self-heal dry-run infra/jeannie-eventd/free-disk-space-failed.sample.json +``` + +Preview stale pod cleanup directly: + +```bash +./{{ main_script }} heal cleanup-stale-pods +``` + +Apply the narrow cleanup when the dry-run targets are correct: + +```bash +./{{ main_script }} heal cleanup-stale-pods --yes +``` + +Run the webhook locally in dry-run mode: + +```bash +./{{ main_script }} self-heal serve +``` + +Install or refresh the Debian systemd webhook service through Jeannie: + +```bash +./{{ main_script }} self-heal install-service +``` + +Enable apply mode only after the dry-run output and audit files look correct: + +```bash +LAB_SELF_HEAL_APPLY=true ./{{ main_script }} self-heal serve +``` + +The systemd example binds the webhook to the Debian LAN address path so the +cluster can reach it. Keep it limited to the homelab network/firewall. + +Audit artifacts are written under: ```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP +${HOMELAB_STATE_DIR:-~/.local/share/homelab}/self-heal-events/ ``` -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: +The webhook also exposes Prometheus metrics at `/metrics`. The platform +Prometheus scrape config collects `192.168.100.73:18081`, and the +repo-provisioned `Homelab Self-Heal` Grafana dashboard shows event totals, +applied action totals, failed events, and alert counts. Rebuild dashboards +after pulling this change: ```bash -./{{ main_script }} tailnet-policy-check +./{{ main_script }} grafana-dashboards apply ``` -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - ## Destructive Rebuilds -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Deploying - -From the Debian server: - -```bash -cd ~/my-homelab-configs -./{{ main_script }} up -``` - -The script first deploys external Gitea to the Debian host with Docker Compose -under `/data/homelab-gitea`, backed by the HP laptop NVMe, so Git stays -outside the Kubernetes rebuild blast radius. It then detects the -Pimox host at `192.168.100.80` in auto mode. When SSH, `qm`, and `vmbr0` are -available, it applies `bootstrap/provisioning`, creates or reuses the Debian 13 -arm64 template, creates or reuses one worker VM clone, discovers the guest IP -through qemu-guest-agent, and passes that worker into the cluster layer. It then -applies the remaining OpenTofu stacks, refreshes Argo CD apps, waits for the -local registry, builds the website and demos images when their source changed, -pushes them to the registry, recreates pods only after a new image is built, and -applies the edge stack. - -Set `LAB_PIMOX_PIPELINE=false` to skip Pimox automation. Set -`LAB_PIMOX_WORKER_COUNT=0` to create or refresh only the template. The pipeline -keeps the template on its configured `local` storage, creates new worker VM -clones on `opi5_ssd` by default when that Pimox storage is available, -checks that the Pimox bridge already exists, refuses `local` as worker clone -storage, and refuses to edit Orange Pi host networking. Keep durable data on -the HP Debian laptop's `data-vg` or external backups; treat Orange Pi VM disks -as rebuildable worker capacity. - -`LAB_PIMOX_SKIP_WORKER_INDEXES` defaults to an empty value, so the pipeline owns -worker index `1` and VMID `9010` when `LAB_PIMOX_WORKER_COUNT=1`. Set -`LAB_PIMOX_SKIP_WORKER_INDEXES=1` if an existing manually created first worker -must be left untouched, or set `LAB_PIMOX_WORKER_COUNT=2` to manage both VMID -`9010` and VMID `9011`. - -Pimox workers can join the tailnet during cluster worker bootstrap. Keep the -ephemeral or pre-authorized auth key outside Git, either in -`~/.config/homelab/tailscale-pimox-worker.authkey` on the Debian host or in -`LAB_PIMOX_WORKER_TAILSCALE_AUTH_KEY`. Then run the cluster pipeline with: - -```bash -LAB_PIMOX_WORKER_TAILSCALE_ENABLED=true ./{{ main_script }} up -``` - -For existing workers, prefer the Jeannie wrapper because it reads the generated -worker keys and exports the correct OpenTofu variables: - -```bash -./{{ main_script }} workers tailnet -``` - -When applying `bootstrap/cluster` directly, use the OpenTofu variable name -instead of the Jeannie `LAB_` wrapper: - -```bash -TF_VAR_worker_tailscale_enabled=true \ -tofu -chdir=bootstrap/cluster apply \ - -var-file="$PWD/.lab/cluster-workers.auto.tfvars.json" -``` - -Worker Tailscale defaults to `--accept-routes=false` because these VMs already -live on the homelab LAN; accepting an advertised `192.168.100.0/24` route can -steal their local LAN route and break SSH or MetalLB traffic. Pod egress SNAT -from the Kubernetes pod CIDR to `tailscale0` stays enabled, so pods on Pimox -workers can reach tailnet-only services. Set -`LAB_PIMOX_WORKER_TAILSCALE_ACCEPT_ROUTES=true` only when the worker must consume -tailnet-advertised routes that do not overlap the local LAN. Set -`LAB_PIMOX_WORKER_TAILSCALE_POD_EGRESS_SNAT=false` when pod egress through -`tailscale0` is not wanted. `./{{ main_script }} doctor-cluster` checks Pimox -worker tailnet egress against -`${LAB_PIMOX_WORKER_TAILNET_PROBE_HOST:-LAB_DEBIAN_TAILSCALE_IP}` and -`${LAB_PIMOX_WORKER_TAILNET_PROBE_PORT:-LAB_GITEA_HTTP_PORT}`. - -OpenWrt firewall VM automation is available as a standalone command because it -attaches to both WAN and LAN bridges. Run `./{{ main_script }} openwrt` after `vmbr1` -already exists on the Orange Pi. The pipeline downloads the OpenWrt ARM -SystemReady EFI image, writes basic WAN/LAN/firewall config into the image, -imports it as VM `9100`, attaches `vmbr0` as WAN and `vmbr1` as LAN, and stores -the VM disk on the selected non-local Pimox storage. It leaves the VM stopped -and not enabled for host boot by default. It does not use the Debian Kubernetes -golden-node template for OpenWrt. - -The website and demos images default to `linux/amd64,linux/arm64` because both -deployments can schedule on either the Debian host or ARM workers. Override with -`WEBSITE_IMAGE_PLATFORMS` or `DEMOS_IMAGE_PLATFORMS` only when intentionally -restricting node placement. - -Build metadata is written under `.lab/` so repeat runs can skip the website -or demos image build when the source hash, platform, image reference, and -registry manifest still match. - -The website build is intentionally performed on the Debian homelab path and the -Gitea Actions runner, not on a laptop. The current image uses -`php:8.5.12-fpm-alpine`, installs Apache, routes PHP through PHP-FPM, enables -OPcache for immutable image deploys, and runs -`apps/website/render-static-pages.sh` during the image build. That render step -produces static HTML for `/`, `/cv.php`, `/blog.php`, `/demos.php`, and -`/homelab-tree.php` in the static languages. Runtime PHP remains for write and -translation endpoints such as `save_idea.php`, `visitor_ideas.php`, -`translate.php`, and `save_lang.php`. - -Set `LAB_GITEA_DEPLOY=false` to skip the external Gitea deployment step when the -service is already managed manually. The default Gitea target is -`jv@192.168.100.73`, install directory `/data/homelab-gitea`, HTTP port `3000`, -and SSH port `32222`. - -Before continuing into Pimox, cluster, apps, or edge changes, `./{{ main_script }} up` -runs `./{{ main_script }} preflight`. The preflight verifies Gitea, Debian Docker -root, Debian Tailscale IP, RPi Docker root fallback state, RPi Tailscale IP, -Pimox worker storage, and OCI edge SSH. Run it directly when changing inventory -or host storage/networking: - -```bash -./{{ main_script }} preflight -``` - -If the Debian Docker root check fails after a reinstall, repair it before -running the full pipeline: - -```bash -./{{ main_script }} fix-debian-docker-root -``` - -When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but -the Kubernetes API is down, it starts the saved runtime before applying cluster -changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally -want to destroy and recreate the cluster. - -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB-memory worker VMs starting at VMID `9010`, worker clone storage -`opi5_ssd`, 30 GiB template/control-plane/worker root disks, and KVM launch -affinity `4-7` because this Pimox is pinned to Debian Bullseye on an Orange Pi -5 Plus. Jeannie launches the generated KVM command under that host CPU set so -PSCI can bring both guest CPUs online; it removes legacy `args` entries so -native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. Override -disk sizing with `LAB_PIMOX_TEMPLATE_DISK_GIB`, -`LAB_PIMOX_CONTROL_PLANE_DISK_GIB`, and `LAB_PIMOX_WORKER_DISK_GIB`; Jeannie -installs `cloud-guest-utils`, `e2fsprogs`, and `cri-tools`, resizes the Pimox -disk, and grows the guest root filesystem during the pipeline. The NVMe that -was previously attached to the Orange Pi now belongs to the HP Debian laptop as -LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox datastore is -`opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template with 2 cores, -8 GiB memory, and a 30 GiB default root disk, replaces two Pimox worker VMs with -2 cores, 8 GiB memory, and 30 GiB root disks, and joins those workers to the -Kubernetes cluster. Pimox 7 ARM does not support `qm --affinity`; Jeannie -instead starts the generated KVM command under CPU set `4-7` and verifies every -worker reports two guest CPUs before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Validation - -Useful checks after a rebuild: - -```bash -export KUBECONFIG=/home/jv/.kube/config - -kubectl get nodes -kubectl top nodes -kubectl -n argocd get applications -kubectl -n container-registry get pods -kubectl -n website-production get pods -o wide -kubectl -n demos-static get pods -o wide - -ssh jv@192.168.100.73 'cd /data/homelab-gitea && sudo docker compose ps' -ssh jv@192.168.100.73 'cd /data/homelab-heimdall && sudo docker compose ps' - -docker info --format '{{.DockerRootDir}}' -df -h / /data /data/openebs/local /data/docker -``` - -The website should be reached through the configured public hostname, not the raw -OCI IP address, because the Let's Encrypt certificate is issued for the -hostname. - -Run a read-only health snapshot from the Debian server with: - -```bash -./{{ main_script }} help -./{{ main_script }} status -./{{ main_script }} capacity -./{{ main_script }} capacity-advisor -./{{ main_script }} capacity-limits -./{{ main_script }} recover-plan -./{{ main_script }} recover-power --dry-run -./{{ main_script }} impact --since HEAD~1 -./{{ main_script }} review-last-change -./{{ main_script }} scorecard -./{{ main_script }} explain scorecard -./{{ main_script }} gitops-status -./{{ main_script }} cert-check -./{{ main_script }} grafana-dashboards list -./{{ main_script }} release-snapshot -./{{ main_script }} backup-status -./{{ main_script }} synthetic-checks -./{{ main_script }} resource-budget -./{{ main_script }} control-plane status -./{{ main_script }} artifact-cache status -./{{ main_script }} blockchain-devnet status -./{{ main_script }} blockchain-test -./{{ main_script }} blockchain-wallet instructions -./{{ main_script }} golden-ledger check -./{{ main_script }} route-inventory -./{{ main_script }} workers list -./{{ main_script }} change-journal list -./{{ main_script }} map -``` - -`help` prints the grouped command reference in pipeline order, from inventory -and bootstrap through cluster lifecycle, reports, observability, recovery, -access, apps, security, AI, and destructive commands. - -`status` uses the reusable report UI and defaults to showing only failures and -warnings so the terminal stays readable. Use `./{{ main_script }} status --all` -to show every check, `--details` for row details, `--json` for structured -output, or `--verbose` for the older full host/Docker/Kubernetes/Pimox/RPi/ -Tailscale/HTTP dump. The cascade includes "what broke" signals such as -deployment readiness, pod restarts, node pressure, disk pressure, Traefik -5xx/404 log evidence, and recent Gitea errors. - -High-signal Prometheus alerts live in `apps/homelab-alerts`. They cover node -readiness, pod restart storms, unavailable deployments, node/PVC storage -pressure, Traefik 5xx spikes, website availability, and Gitea/Pi-hole scrape -coverage. Keep this set small so alerts remain actionable. - -Application egress is controlled with Kubernetes NetworkPolicies where the lab -owns the workload. The website namespace defaults to denied egress and allows -only DNS, Redis, and the Debian Ollama endpoint. The security lab namespace is -isolated from the cluster and LAN while allowing DNS plus outbound HTTP/HTTPS -for controlled practice targets. - -`capacity` is the placement report for the hardware you already have. By -default it uses the compact report renderer and shows summarized Debian, -Kubernetes, Pimox, RPi, and placement signals without dumping full details. Use -`./{{ main_script }} capacity --details`, `--json`, `--only problems`, or -`--verbose` for the older full capacity dump. - -`capacity-advisor` interprets capacity, resource-budget, and control-plane -placement signals to recommend whether to add Pimox VMs, taint Debian, or fix -resource definitions first. - -`capacity-limits` prints suggested Kubernetes `resources.requests` and -`resources.limits` YAML snippets for containers missing them. It uses -`infra/resource-recommendations.yml` as a conservative starting profile and does -not edit manifests. - -`recover-plan` prints the disaster recovery order and lightweight prerequisite -checks, from Debian and Gitea through DNS, Pimox, Kubernetes, GitOps apps, and -edge verification. - -`recover-power` runs the post-outage recovery sequence in dependency order: -Debian runtime, Gitea, RPi DNS, Pimox workers, Kubernetes, GitOps/apps, and -edge/public checks. Use `recover-power --dry-run` to preview the sequence. - -`impact` explains what a change may touch before you apply it. Use -`./{{ main_script }} impact --since HEAD~1` for the last commit or pass paths -like `bootstrap/edge` and `apps/website`. - -`review-last-change` summarizes the last commit, runs impact analysis for the -touched files, and prints validation plus rollback hints. - -`scorecard` rolls up backup readiness, GitOps health, DNS/RPi health, cluster -health, edge health, capacity pressure, security posture, public certificates, -inventory, and docs freshness into a compact pass/warn/fail report. - -`explain` is the read-only follow-up for warnings, failures, and corrective -output. It can run safe report commands itself, such as -`./{{ main_script }} explain scorecard`, `status`, `capacity`, or -`resource-budget`, and it can explain captured output with -`./{{ main_script }} explain output < saved-output.txt`. It lists what each -finding means, diagnostic commands, whether a Jeannie fix command already -exists, and risk/auto-fix safety. - -Report-oriented commands share the reusable UI module in `scripts/report-ui` -and renderer in `scripts/report-render`. Commands emit status TSV rows, and the -renderer prints compact grouped summaries by default, with details or JSON -available for future TUI/web output. Rows may include separate `fix`, `graph`, -and `query` fields so a warning can point to both the next `jeannie` command and -the matching Grafana panel or Explore query. - -`gitops-status` prints a focused Argo CD view: application sync and health, -out-of-sync or degraded apps, repository secret presence, recent Argo CD events, -and recent repo-server/application-controller errors. - -`grafana-dashboards` manages repo-provisioned Grafana dashboards under -`bootstrap/platform/grafana-dashboards`. `./{{ main_script }} up` provisions -them through the platform stack; `./{{ main_script }} grafana-dashboards apply` -rebuilds just the dashboard ConfigMaps and restarts Grafana. The optional -blockchain devnet dashboard uses metrics from -`infra/blockchain-devnet/metrics/exporter.py`. - -`cert-check` verifies public DNS, TLS certificate expiry, public website/Gitea -HTTP status, and DuckDNS-to-OCI edge IP drift from the canonical inventory. - -`release-snapshot` writes a timestamped pre-change report under the homelab -state directory with Git state, Kubernetes/Argo CD/Helm state, workload images, -public URL status, and pointers to the latest Gitea/OpenTofu backups. - -`backup-status` reports freshness for Gitea backups, OpenTofu state backups, -restore drill reports, and repo-managed Pi-hole restore inputs. The main -`status` cascade includes this as a warning signal. - -`synthetic-checks` runs end-to-end probes for Gitea HTTP/SSH, registry API, -Pi-hole DNS, Traefik LAN HTTP, and temporary Kubernetes DNS/ingress pods. The -registry push/pull smoke test is opt-in with -`LAB_SYNTHETIC_REGISTRY_PUSH=true`. - -`resource-budget` checks the report-only policy in `infra/resource-budgets.yml` -against Kubernetes pod requests/limits and Debian host disk/memory signals. Use -it before adding heavier workloads so the HP laptop remains usable. By default -it summarizes missing requests/limits by namespace; use -`./{{ main_script }} resource-budget --details` for every pod/container. - -`control-plane` shows or manages the Debian Kubernetes control-plane scheduling -taint. After Pimox workers are stable, use `./{{ main_script }} control-plane taint` -to keep normal app/data-plane pods off the Debian host while control-plane and -DaemonSet workloads continue using their normal tolerations. - -`artifact-cache` manages an optional Debian-host cache stack in -`infra/artifact-cache` with apt-cacher-ng and a Docker Hub registry pull-through -cache. Use `artifact-cache instructions` for client configuration snippets. - -`blockchain-devnet` manages an optional local Ethereum Anvil devnet under -`infra/blockchain-devnet`. It is for contract, wallet, RPC, and observability -learning only; never use real seed phrases or mainnet keys. - -`blockchain-test` runs the Foundry tests in `labs/blockchain`. The lab starts -with a simple `Counter` contract and ownership tests so there is a known-good -baseline before practicing vulnerable contracts. - -`blockchain-wallet` provides disposable dev-wallet generation, address -derivation, and message-signing practice. It is documented in -`labs/blockchain/WALLET_LAB.md`; never use real seed phrases or funded keys. - -`golden-ledger` shows or validates `infra/pimox/golden-image-ledger.yml`, the -reviewable record of template VMID, storage, OS release, Kubernetes pins, -runtime versions, and build metadata for Pimox worker golden images. - -`route-inventory` reports Kubernetes ingress hosts, paths, backend services, -TLS coverage, and visible Uptime Kuma monitor coverage so stale routes and -missing monitors are easier to spot. - -`workers` provides named Kubernetes/Pimox worker lifecycle operations: -`list`, `tailnet`, `start`, `stop`, `drain`, `uncordon`, `recreate-plan`, and -`rebalance`. -Use `recreate-plan ` before replacing one broken Pimox worker so the -cluster drain, VM stop, and `./{{ main_script }} up` path stay ordered. - -`change-journal` lists local journal entries written before risky commands such -as `up`, `apps`, `deploy-gitea`, `rpi-services`, `stop-cluster`, -`start-cluster`, `rebuild-cluster`, `release-snapshot`, and `nuke`. Entries live -under `${HOMELAB_STATE_DIR}/change-journal` and record Git revision, branch, -dirty file count, and command details. - -`map` prints a dependency map from the canonical inventory, covering public -entry, GitOps automation, cluster foundation, DNS, observability, and security -learning paths. `./{{ main_script }} map --dot` emits Graphviz DOT. - -Focused doctor commands run narrower read-only checks. They use the same -problems-first UI as `status`; add `--all`, `--details`, `--json`, or -`--verbose` when you need more context: - -```bash -./{{ main_script }} doctor-edge -./{{ main_script }} doctor-gitea -./{{ main_script }} doctor-rpi -./{{ main_script }} doctor-cluster -``` - -`doctor-cluster` also checks whether Pimox workers have Tailscale installed, -`tailscaled` active, a Tailscale IP, and TCP egress to the configured tailnet -probe service. - -## RPi Services - -The Raspberry Pi runs lightweight always-on services outside Kubernetes from -`infra/rpi-services`: - -- Pi-hole on DNS port `53` and web port `8081` -- Unbound as Pi-hole's first upstream resolver -- Uptime Kuma on port `3001` - -Deploy or refresh them from the Debian server with: - -```bash -./{{ main_script }} rpi-services -``` - -`./{{ main_script }} up` also runs this step unless -`LAB_RPI_SERVICES_DEPLOY=false` is set. Docker data for the Raspberry Pi is -expected under `/nvme-storage/docker` when that path is an active writable mount point. If -the NVMe is missing or resets, it rewrites Docker's `data-root` to -`/var/lib/docker` and restarts Docker so DNS can still come up from the -SD/root filesystem. - -Pi-hole uses Unbound first and public fallback upstreams after that, so DNS can -continue resolving if the Unbound container stops. Repo-managed Pi-hole state -lives in `infra/rpi-services/adlists.txt`, -`infra/rpi-services/local-dns-records.txt`, -`infra/rpi-services/cname-records.txt`, and -`infra/rpi-services/static-dhcp-hosts.txt`. The bootstrap inserts adlists without -deleting manually added Pi-hole lists, then renders the DNS/CNAME/DHCP files into -a managed dnsmasq config inside the Pi-hole container. If `PIHOLE_WEBPASSWORD` -is not provided, the bootstrap generates one and keeps it in -`/opt/homelab-rpi-services/.env`. -Uptime Kuma monitor seeds live in -`infra/rpi-services/uptime-kuma-monitors.json` and are applied after the first -Kuma user exists. -`./{{ main_script }} status` and `./{{ main_script }} doctor-rpi` test Pi-hole DNS, -direct Unbound DNS, public fallback resolver readiness, Uptime Kuma HTTP, and -whether Docker is currently using `/nvme-storage/docker` or has fallen back to -`/var/lib/docker`. - -## Adding Nodes - -For Pimox on Orange Pi 5 Plus, `./{{ main_script }} up` can create the Debian 13 arm64 -template and worker VM clones automatically when the Orange Pi storage path is -healthy. Defaults are intentionally tied to the observed host: Pimox SSH host -`192.168.100.80`, bridge `vmbr0`, template VMID `9000` on `local` storage, two -8 GiB-memory worker VMs starting at VMID `9010`, worker clone storage -`opi5_ssd`, 30 GiB template/control-plane/worker root disks, and KVM launch -affinity `4-7` because this Pimox is pinned to Debian Bullseye on an Orange Pi -5 Plus. Jeannie launches the generated KVM command under that host CPU set so -PSCI can bring both guest CPUs online; it removes legacy `args` entries so -native `qm` CPU topology is the only `-smp` argument. Set -`LAB_PIMOX_KVM_CPUSET=` to use normal `qm start` on a different host. Override -disk sizing with `LAB_PIMOX_TEMPLATE_DISK_GIB`, -`LAB_PIMOX_CONTROL_PLANE_DISK_GIB`, and `LAB_PIMOX_WORKER_DISK_GIB`; Jeannie -installs `cloud-guest-utils`, `e2fsprogs`, and `cri-tools`, resizes the Pimox -disk, and grows the guest root filesystem during the pipeline. The NVMe that -was previously attached to the Orange Pi now belongs to the HP Debian laptop as -LVM volume group `data-vg`; the current Orange Pi SSD-backed Pimox datastore is -`opi5_ssd` and is used for rebuildable VM root disks. Details and -override variables are in -`bootstrap/provisioning/README.md`. - -Worker indexes are stable. Index `1` maps to VMID `9010`, node name -`pimox-worker-01`, and worker key `pimox01`; index `2` maps to VMID `9011`, and -so on. `LAB_PIMOX_SKIP_WORKER_INDEXES=1` leaves the first slot unmanaged while -allowing higher indexes to be automated. - -Worker networking defaults to static because the ISP modem DHCP server does not -answer Pimox worker VM DHCP requests behind `vmbr0`. Set -`LAB_PIMOX_WORKER_NETWORK_MODE=dhcp` only when LAN DHCP is known to answer VM -traffic. Static mode uses -`LAB_PIMOX_WORKER_STATIC_IPS="192.168.100.66 192.168.100.67 192.168.100.76"`, -`LAB_PIMOX_WORKER_GATEWAY=192.168.100.1`, and -`LAB_PIMOX_WORKER_DNS_SERVERS="192.168.100.89 1.1.1.1"`. -For static workers, Jeannie also adds targeted Pimox-host forwarding exceptions -for each worker IP in `DOCKER-USER` when that chain exists, or `FORWARD` -otherwise. If `iptables` is missing on the Pimox host, Jeannie installs it before -adding those rules. Disable this with `LAB_PIMOX_WORKER_CONFIGURE_FORWARDING=false` -only when the Pimox host firewall already permits bridged worker IP traffic. -Before adding rules, Jeannie saves `iptables-save` output on the Pimox host under -`${LAB_PIMOX_WORKER_IPTABLES_BACKUP_DIR:-~/iptables-backups}`. -Worker NIC MAC addresses default to the VMID-derived deterministic format used -by the original working Pimox worker path. Set `LAB_PIMOX_WORKER_MAC_MODE=auto` -only when you explicitly want Pimox to generate the MAC. -Worker creation fails faster than template creation: static guest-network -configuration waits up to `LAB_PIMOX_GUEST_AGENT_CONFIG_TIMEOUT_SECONDS=300`, -worker IP/SSH readiness waits up to `LAB_PIMOX_WORKER_WAIT_TIMEOUT_SECONDS=600`, -and SSH after an IP appears waits up to `LAB_PIMOX_GUEST_SSH_TIMEOUT_SECONDS=600`. -Static guest-network validation skips the extra LAN ICMP probe by default -because the ISP modem may not answer worker VM pings. Set -`LAB_PIMOX_WORKER_REQUIRE_LAN_PROBE=true` only when the gateway/probe host -should be required during qemu-guest-agent network setup. After -qemu-guest-agent reports an IP, Debian skips the extra ICMP host probe by -default and lets SSH be the reachability check. Set -`LAB_PIMOX_WORKER_REQUIRE_HOST_PROBE=true` only when you want a faster ICMP gate. -`LAB_PIMOX_GUEST_TIMEOUT_SECONDS` remains the broader template-build timeout. -Before `./{{ main_script }} apps` changes any application resources, Jeannie -requires every generated Pimox worker to be `Ready` and expose at least two -Kubernetes CPUs. Override the threshold with -`LAB_PIMOX_APP_DEPLOY_MIN_CPUS`; set -`LAB_PIMOX_APP_DEPLOY_REQUIRE_CAPACITY=false` only for a deliberately -non-Pimox deployment. - -Long-running `./{{ main_script }} up` steps keep compact output by default, but -the active step line refreshes with elapsed time and the latest log line. Set -`JEANNIE_PROGRESS_INTERVAL_SECONDS=5` for faster heartbeats, or -`JEANNIE_VERBOSE=true` to stream full command output. -Independent host services run through the Go DAG runner during `up`: Gitea -deploy/bootstrap, RPi services, Pimox workers, OpenWrt, and OCI edge host checks -can progress concurrently. Set `JEANNIE_UP_PARALLELISM=1` to force sequential -execution while troubleshooting, or raise it above the default `4` if the lab -can absorb more concurrent work. - -Run a full cluster rebuild from the Debian server with: - -```bash -./{{ main_script }} rebuild-cluster -``` - -That path preserves external Gitea, rebuilds the Pimox template with 2 cores, -8 GiB memory, and a 30 GiB default root disk, replaces two Pimox worker VMs with -2 cores, 8 GiB memory, and 30 GiB root disks, and joins those workers to the -Kubernetes cluster. Pimox 7 ARM does not support `qm --affinity`; Jeannie -instead starts the generated KVM command under CPU set `4-7` and verifies every -worker reports two guest CPUs before Kubernetes workloads proceed. -The Raspberry Pi is still included as a Kubernetes worker by default; `nuke` -does not clean it unless you explicitly add it to `WORKER_SSH_TARGETS`. - -To pause the Kubernetes cluster without deleting kubeadm files, OpenTofu state, -PV data, or VM disks, run: - -```bash -./{{ main_script }} stop-cluster -``` - -This stops `kubelet`, stops Kubernetes CRI containers with `crictl` when -available, stops any workers listed in `WORKER_SSH_TARGETS`, and gracefully -shuts down automated Pimox worker VMs. It intentionally leaves the host -`containerd`/Docker stack running so external Docker Compose services such as -Gitea stay online. It does not run `kubeadm reset`, delete CNI files, or remove -state. Use `LAB_CLUSTER_STOP_CONTAINERD=true` only when you intentionally want -to stop the host container runtime too. Use `LAB_CLUSTER_STOP_VM_TIMEOUT_SECONDS` -to change the Pimox shutdown timeout, `LAB_CLUSTER_STOP_FORCE=false` to avoid a -hard `qm stop` after timeout, and the usual `LAB_PIMOX_WORKER_COUNT`, -`LAB_PIMOX_WORKER_BASE_VMID`, and `LAB_PIMOX_SKIP_WORKER_INDEXES` variables to -select VM workers. Resume the runtime with: - -```bash -./{{ main_script }} start-cluster -``` - -Kubernetes worker generation defaults to automated Pimox workers only. The -Raspberry Pi stays out of the cluster unless `LAB_INCLUDE_RASPBERRY_WORKER=true` -is set. Stale manual workers in `.lab/manual-workers.tsv` are ignored unless -`LAB_INCLUDE_MANUAL_WORKERS=true` is set. To manage workers manually instead, -add entries to `bootstrap/cluster/variables.tf` or a `.tfvars` file: - -```hcl -worker_nodes = { - raspberrypi = { - host = "192.168.100.89" - user = "jv" - node_name = "raspberry" - ssh_key_path = "/home/jv/.ssh/id_ed25519" - } -} -``` - -Stateful apps currently pin retained local PVs to the `debian` node. Move or -duplicate those PV manifests when you want storage on another node. - -## Workload Placement - -`bootstrap/cluster` labels nodes with homelab placement metadata: - -- `node-role.kubernetes.io/worker=worker` on every worker so `kubectl get nodes` - shows `worker` instead of `` in the ROLES column -- `homelab.dev/node-role=control-plane`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=control-plane` on the Debian control plane -- `homelab.dev/node-role=edge-app`, `homelab.dev/storage=local`, and - `homelab.dev/workload-class=edge` on the Raspberry Pi worker -- `homelab.dev/node-role=app`, `homelab.dev/storage=ssd`, and - `homelab.dev/workload-class=platform` on automated Pimox worker clones when - those workers are enabled - -Override `control_plane_node_labels`, `worker_node_labels`, -`LAB_RASPBERRY_NODE_LABELS_JSON`, or `LAB_PIMOX_WORKER_NODE_LABELS_JSON` when -the physical layout changes. The current website, demos, and registry manifests -are not moved automatically because the public NodePort path and retained -OpenEBS hostpath PVs are node-local. Move workloads only after their storage and -edge path are ready on the target node. Gitea is outside Kubernetes and is moved -by changing the Raspberry Pi Docker install target instead. - -The stateless platform controllers are pinned to Pimox worker nodes through -`homelab.dev/workload-class=platform` and include hostname topology spread plus -preferred pod anti-affinity so future Argo CD, Kyverno, Prometheus operator, and -kube-state-metrics scheduling does not collapse onto the first worker that joins. -PVC-backed monitoring StatefulSets are intentionally treated separately because -their retained OpenEBS hostpath volumes are node-local. Run -`./{{ main_script }} move-prometheus-stack-workers` from the Debian host to label existing -worker nodes, destroy only the existing `prometheus-stack` Helm release, delete -its retained PVC/PV objects, and recreate the stack on the worker selector when -you intentionally accept losing that monitoring data. A planned monitoring data -migration should be handled as a separate maintenance task with backup, -delete/recreate or storage migration steps, and post-restore checks. - -The older NodePort path is now reserved for special cases such as the local -registry. `bootstrap/cluster` still contains `homelab-tailscale-nodeport` -support, but app traffic should normally enter through Traefik's MetalLB -address instead of per-app NodePorts. Before applying the edge stack, Jeannie -configures a Tailscale subnet router so the OCI edge can route to the Traefik -LoadBalancer address. The default route advertiser is the Debian control-plane -host because it can reach both Tailscale and the MetalLB address; set -`LAB_EDGE_TAILSCALE_ROUTER=rpi` to use the Raspberry Pi instead. - -The cluster stack still supports worker-based subnet-route advertisement when -that is useful: - -```hcl -metallb = { - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.240"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -} - -traefik = { - enabled = true - repository = "https://helm.traefik.io/traefik" - chart_version = "40.2.0" - namespace = "traefik" - load_balancer_ip = "192.168.100.240" - ingress_class = "traefik" -} - -tailscale_subnet_routes = { - enabled = true - worker_key = "raspberrypi" - routes = ["192.168.100.0/24"] -} -``` - -DuckDNS resolves `*.lab2025.duckdns.org` to the OCI edge, so public requests for -the service hostnames land on the same edge host. For direct LAN testing, point -LAN DNS, `/etc/hosts`, or a Tailscale DNS override for app hostnames at -Traefik's address: - -```text -192.168.100.240 lab2025.duckdns.org -192.168.100.240 demos.lab2025.duckdns.org -192.168.100.240 n8n.lab2025.duckdns.org -192.168.100.240 prowlarr.lab2025.duckdns.org -192.168.100.240 sonarr.lab2025.duckdns.org -192.168.100.240 radarr.lab2025.duckdns.org -192.168.100.240 qbittorrent.lab2025.duckdns.org -192.168.100.240 kapowarr.lab2025.duckdns.org -192.168.100.240 suwayomi.lab2025.duckdns.org -192.168.100.240 maintainerr.lab2025.duckdns.org -192.168.100.240 grafana.lab2025.duckdns.org -192.168.100.240 argocd.lab2025.duckdns.org -``` - -Heimdall is external to Kubernetes. For direct LAN testing, use -`http://192.168.100.73:8082/`; public access still uses -`https://heimdall.lab2025.duckdns.org/` through the OCI edge. - -The edge stack uses Traefik as its backend by default and validates -`http://192.168.100.240:80/` before updating the edge containers. If Tailscale -subnet-route approval is not automatic in the tailnet policy, the edge deploy -will fail clearly instead of silently keeping a broken public path. - -For `./{{ main_script }} nuke`, set `WORKER_SSH_TARGETS` to a space-separated list of -remote SSH targets when more worker nodes exist. Set it to an empty string for a -single-node rebuild. - -## Adding Platform Tools - -Add Helm releases through `bootstrap/platform`'s `extra_helm_releases` map. - -## Policy Guardrails - -`bootstrap/platform` installs Kyverno and the upstream baseline Pod Security -policies in `Audit` mode. This gives the lab policy reports for unsafe workload -settings without blocking existing pods during the first rollout. After reports -are clean, individual policies can be promoted to `Enforce` in -`bootstrap/platform/main.tf`. - -`apps/supply-chain-policy` adds a separate Kyverno `ImageValidatingPolicy` for -the images built by this repo and pushed to the local registry. The policy -targets `192.168.100.73:30500/php-website:*` and -`192.168.100.73:30500/demos-static:*`, mutates admitted pods to image digests, -and audits whether the image has both: - -- a valid Cosign signature from the homelab signing key -- a signed SPDX SBOM attestation - -The private Cosign key, generated password, and downloaded Cosign binary live in -`${XDG_DATA_HOME:-$HOME/.local/share}/homelab/` by default so the signing -identity survives temporary checkout cleanup. Repo-local image state files still -live under `.lab/`, which is ignored by Git. `./{{ main_script }} apps` creates or reuses -the persistent Cosign key, publishes the public key into the Kyverno namespace as -`homelab-cosign-public-key`, builds images with BuildKit SBOM attestations, signs -the pushed images, attaches a signed SPDX SBOM predicate, and verifies both -artifacts before refreshing the workload Applications. The policy starts in -`Audit` mode so an existing live deployment can recover while the current images -are signed; after `./{{ main_script }} apps` verifies both images, change `validationActions` in -`apps/supply-chain-policy/local-registry-image-policy.yaml` from `Audit` to -`Deny` to make it admission-enforcing. Set `COSIGN_PASSWORD` if you want to -manage the key password externally; otherwise the Debian runner creates -`cosign/cosign.password` under the homelab state directory for non-interactive -runs. Set `COSIGN_KEY_PREFIX`, `COSIGN_PASSWORD_FILE`, or `COSIGN_BIN` to override -those paths. - -## DNS Cache - -`bootstrap/platform` installs NodeLocal DNSCache in `kube-system` with -`registry.k8s.io/dns/k8s-dns-node-cache`. The default listens on -`169.254.20.10` and the kube-dns service IP `10.96.0.10`, which keeps the -rollout compatible with the current kube-proxy iptables path without rewriting -kubelet DNS settings across the nodes. Override `nodelocal_dns` if the service -CIDR or upstream DNS servers change. - -## MetalLB - -MetalLB is present in `bootstrap/platform` but disabled by default. Enable it -only after reserving a LAN IP range outside DHCP and outside any future OpenWrt -LAN pool: - -```bash -export TF_VAR_metallb='{ - enabled = true - repository = "https://metallb.github.io/metallb" - version = "0.16.0" - namespace = "metallb-system" - address_pool = ["192.168.100.240-192.168.100.250"] - l2_advertisement_enabled = true - pool_name = "homelab-lan" -}' -``` - -Traefik uses MetalLB for a LAN `LoadBalancer` address. Kubernetes app services -such as the website, demos, and n8n should be `ClusterIP` services behind -Ingress objects. The local registry remains a `NodePort` because the cluster -nodes use it as a pull endpoint. Gitea and Heimdall are not Kubernetes services; -they run on the Debian Docker host. - -## Secrets - -Use SOPS with age for secrets that need to live in Git. The Debian host -bootstrap installs `age` and `sops`; then run: - -```bash -./{{ main_script }} secrets-init -./{{ main_script }} secrets-check -``` - -`secrets-init` creates `~/.config/sops/age/keys.txt` if needed and renders -`.sops.yaml` from `.sops.yaml.example` with the host's public age recipient. -Commit `.sops.yaml`, but keep the private age key outside the repo. Operational -notes are in `docs/secrets.md`. - -## Edge Services - -The OCI jump box runs the public edge path: - -```text -nginx -> HAProxy -> Varnish/Squid -> Traefik MetalLB IP -``` - -Tailnet access policy is tracked in `infra/tailscale/tailnet-policy.hujson`. -Validate it before applying with: - -```bash -./{{ main_script }} tailnet-policy-check -``` - -The `bootstrap/edge` stack renders configs from `bootstrap/edge/templates` and -deploys them to `/opt/homelab-edge` on the OCI host. Defaults are in -`bootstrap/edge/variables.tf`; override them through `TF_VAR_*` or a `.tfvars` -file when the public host, SSH key, server name, backend Tailscale IP, or -Traefik backend address changes. - -The `/git/` route is intentionally different from the Kubernetes app routes: it -proxies to Gitea on the Debian host through Tailscale instead of Traefik. This -keeps public read-only source browsing available even when the cluster has been -destroyed. - -For the main website, nginx terminates TLS, serves cached HTML and static -assets, compresses text responses with gzip, advertises HTTP/2, reuses TLS -sessions, and keeps upstream connections open to the Traefik backend. The -application side marks pre-rendered HTML as -`Cache-Control: public, max-age=300, s-maxage=3600`; the edge keeps CSS and JS -under the stronger immutable asset policy. In local measurements, cached -single-resource requests are dominated by the remote TCP/TLS path, while a -reused HTTP/2 asset batch completes in roughly 60 ms after the connection is -established. - -Use the configured `server_name` in the browser, for example -`https://lab2025.duckdns.org`. A raw OCI IP address will still show a browser -certificate warning because the trusted certificate is issued for the hostname. - -The edge stack uses HTTP-01 validation and requests one certificate covering -`server_name` plus `additional_server_names`. DuckDNS resolves sub-subdomains -under `lab2025.duckdns.org` to the same edge IP, so inbound TCP 80 and 443 must -be open before `./{{ main_script }} up` runs. Set `TF_VAR_letsencrypt_email` to receive -expiry notices, or leave it empty to register without an email. Set -`TF_VAR_enable_letsencrypt=false` to keep using the temporary local certificate. - -Operational runbooks: - -- [Edge failures](docs/runbooks/edge-failures.md) -- [Gitea failures](docs/runbooks/gitea-failures.md) -- [Cluster stop/start failures](docs/runbooks/cluster-stop-start-failures.md) - -## Adding Apps - -Add Kubernetes manifests under `apps/` and register them in -`bootstrap/apps`'s `applications` map. Argo CD will own sync, pruning, and -self-healing for the app. - -The `heimdall` Argo CD app name is retained as a small route bundle for -Grafana, Prometheus, Alertmanager, and Argo CD ingresses so the next app sync can -prune the old in-cluster Heimdall workload cleanly. Do not add new Kubernetes -workloads there. Use `./{{ main_script }} deploy-heimdall` for the dashboard -itself. - -The `n8n` app runs in the `n8n` namespace with retained OpenEBS storage and is -exposed at `https://n8n.lab2025.duckdns.org`. It receives -`OLLAMA_BASE_URL=http://192.168.100.73:11434` so workflows can call the existing -Debian-host Ollama API for translation prewarming and batch jobs. - -The ARR/media stack is intentionally not deployed by the Kubernetes app -pipeline. It is better suited to a Docker Compose stack on the Debian host with -persistent volumes under `/data`, where large media paths, qBittorrent writes, -and service config directories can survive cluster rebuilds without OpenEBS -node-affinity or PVC migration concerns. The active host-level Compose -definition lives under `infra/arr-stack` and stores persistent data under -`/data/arr`. Historical Kubernetes manifests are archived under -`archive/apps/arr-stack` for migration reference only. - -## Storage - -OpenEBS provides the platform storage provisioner. Stateful Kubernetes apps use -retained local PV paths such as `/data/openebs/local/registry`; these paths are -intentionally outside kubeadm reset paths so data can survive cluster -destroy/create cycles. Those critical volumes are declared explicitly as -retained local PVs so a rebuilt cluster binds back to the same host paths -instead of creating fresh directories. - -For the current lab, the HP Debian laptop's root filesystem is on NVMe, so the -standard Docker root `/var/lib/docker` is acceptable. OpenEBS retained hostpath -data still lives under `/data/openebs/local`, and larger service data such as -Gitea, Ollama models, and app volumes should stay under `/data`. - -## Gitea - -Gitea is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/gitea/docker-compose.yml`, not as a -Kubernetes workload. This keeps Git available when the Kubernetes cluster is -destroyed and rebuilt. - -The default data path is `/data/homelab-gitea/data` on the HP laptop NVMe. -Docker may use the standard `/var/lib/docker` root because `/` is also on NVMe. - -Public source browsing stays available through -`https://lab2025.duckdns.org/git/`. Registration is disabled and anonymous users -can view public repositories, so the blog can link to code read-only while -writes still require an authenticated Gitea account. - -## Heimdall - -Heimdall is external bootstrap infrastructure. It runs on the Debian host as an -always-on Docker Compose service from `infra/heimdall/docker-compose.yml`, not -as a Kubernetes workload. This keeps the lab navigation page available when the -cluster is destroyed, rebuilding, or unhealthy. - -Deploy or refresh it from the Debian server with: - -```bash -./{{ main_script }} deploy-heimdall -``` - -`./{{ main_script }} up` also runs this step during the independent host -services stage unless `LAB_HEIMDALL_DEPLOY=false` is set. The default data path -is `/data/homelab-heimdall/data/config`, and the local HTTP port is `8082`. -Dashboard links are seeded from `infra/heimdall/links.json` by a sidecar -container that upserts repo-managed tiles without deleting manually added ones. - -The Debian bare repo remains the GitOps mirror: - -```text -/home/jv/git-server/my-homelab-configs.git -``` - -Argo CD consumes that Debian mirror through the default `gitops_repo_url`. -Gitea Actions pushes the `main` commit into the mirror before running the -selected deploy command. - -The platform bootstrap registers the Argo CD repository secret and the SSH host -key for the Debian GitOps mirror. If Argo CD reports -`knownhosts: key is unknown` after the Debian host was rebuilt or its SSH host -key changed, refresh `argocd-ssh-known-hosts-cm` in the `argocd` namespace, -restart `argocd-repo-server`, and hard-refresh the affected Application. - -Deploy or refresh the external Gitea container from the Debian host with: - -```bash -./{{ main_script }} deploy-gitea -``` - -## Gitea Backups - -`./{{ main_script }} up` installs a Debian-host systemd timer named -`homelab-gitea-backup.timer`. The timer runs daily, SSHes to the configured -Gitea host, executes `gitea dump` inside the Gitea Docker container, copies the -dump back to Debian, and stores it under `/home/jv/backups/gitea`. The default -retention is 30 days. - -The same install step also creates `homelab-gitea-restore-drill.timer`. The -monthly drill is non-destructive: it verifies the latest backup ZIP, extracts it -to a temporary directory, records a report under -`/home/jv/backups/gitea-restore-drills`, and removes the temporary extract. It -does not write into the live Gitea data directory. - -Run a manual backup from the Debian server with: - -```bash -./{{ main_script }} backup-gitea -``` - -Run the restore drill manually with: - -```bash -./{{ main_script }} drill-gitea-restore -./{{ main_script }} drill-restore -./{{ main_script }} drill-pihole-restore -``` - -`drill-restore` validates the latest Gitea backup archive, Pi-hole repo-managed -config inputs, the latest OpenTofu state backup archive when present, and the -GitOps rebuild path. It does not replace running services or mutate Kubernetes. - -Useful checks: - -```bash -./{{ main_script }} backup-status -systemctl list-timers homelab-gitea-backup.timer -systemctl list-timers homelab-gitea-restore-drill.timer -sudo systemctl start homelab-gitea-backup.service -ls -lh /home/jv/backups/gitea -ls -lh /home/jv/backups/gitea-restore-drills -``` - -## Gitea Actions - -This repo includes a Gitea Actions workflow at -`.gitea/workflows/homelab-main.yml`. It runs validation on pushes to `dev` and -`main`, and deploys only from `main`. That keeps the promotion path simple: - -```text -dev -> ./{{ main_script }} validate in Gitea Actions -> main -> Argo CD sync -``` - -The workflow targets a repository-scoped Debian host runner with the label -`homelab-debian`. - -Run the same validation locally before promoting: - -```bash -./{{ main_script }} validate -``` - -## Identity and access audit - -Run a read-only access inventory from the Debian server with: - -```bash -./{{ main_script }} access-audit -``` - -The audit reports configured SSH targets and key file modes, Git/Gitea remotes, -Tailscale ACL policy validation, current Kubernetes authorization, broad -cluster-admin bindings, automation service accounts, and Gitea runner status. -It does not create users, tokens, kubeconfigs, or keys. Use it to move toward -separate identities: - -- admin kubeconfig only on the Debian control host -- read-only kubeconfig for dashboards and audits -- separate service accounts for automation -- explicit SSH inventory for Debian, RPi, Pimox, and OCI edge -- repo-managed Tailscale ACLs - -The read-only Kubernetes identity is managed in `apps/access-control`. After -that app syncs, generate a separate read-only kubeconfig on the Debian host: - -```bash -./{{ main_script }} kubeconfig-readonly -``` - -The workflow only blocks automatic deploy for external Gitea service -changes: files under `infra/gitea/`, or edits inside the `deploy_gitea`, -`install_gitea_backup_timer`, `backup_gitea`, or `drill_gitea_restore` -functions in `{{ main_script }}`. Other changes use `HOMELAB_ACTION_COMMAND=auto` by -default: Actions runs `./{{ main_script }} doctor-versions` when the Debian runner already -has a cluster kubeconfig. If node versions are aligned it runs `./{{ main_script }} apps`; -if kubelet minor drift is detected it runs `./{{ main_script }} rebuild-cluster`; if no -kubeconfig exists it also runs `./{{ main_script }} rebuild-cluster`. - -Set `HOMELAB_ACTION_COMMAND=apps` or `HOMELAB_ACTION_COMMAND=rebuild-cluster` -on the runner to force one path. - -`./{{ main_script }} bootstrap-gitea-repo` also registers the Debian host SSH public key -with the Gitea repository and switches the Debian working copy's `gitea` remote -to `ssh://git@192.168.100.73:32222/jv/my-homelab-configs.git`. The default key -is `/home/jv/.ssh/id_ed25519.pub`; set `LAB_GITEA_REPO_SSH_KEY_PATH` to use a -different Debian-host key, or `LAB_GITEA_REPO_SSH_BOOTSTRAP=false` to leave SSH -access unchanged. The Actions deploy job uses the checked-out Actions workspace -as the source commit, updates the first available persistent checkout from -`HOMELAB_DEPLOY_DIR`, `/home/jv/my-homelab-configs`, or -`/home/jv/repos/my-homelab-configs`, and otherwise deploys directly from the -Actions workspace. It does not need SSH read access back to Gitea. - -Enable Actions for the repository in Gitea, then create a repository-level runner -token from: - -```text -https://lab2025.duckdns.org/git/jv/my-homelab-configs/settings/actions/runners -``` - -Register and start the Debian runner from the Debian server: - -```bash -cd ~/my-homelab-configs -GITEA_RUNNER_REGISTRATION_TOKEN='' ./{{ main_script }} install-gitea-runner -``` - -The runner is installed as `homelab-gitea-runner.service`, runs as user `jv`, and -uses a host label instead of a Docker job container because deployment needs the -Debian host's Docker, OpenTofu, kubeconfig, SSH keys, and local state. - -The deployment job is non-interactive. User `jv` must be able to run `sudo -n -true` on the Debian host for deployment commands that require sudo. - -Useful checks: - -```bash -systemctl status homelab-gitea-runner.service -journalctl -u homelab-gitea-runner.service -n 100 --no-pager -``` - -## Renovate - -`renovate.json` defines dependency update rules for Dockerfiles, OpenTofu -providers, Helm chart versions, and the pinned tools used by the Gitea Actions -workflow. Renovate should open reviewable update branches or PRs only; it must -not auto-merge infrastructure changes. Keep app-only dependency updates on the -normal Gitea Actions path, and run `./{{ main_script }} up` manually on the Debian server -for platform or provisioning updates. - -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. - -## Website App - -The website is a PHP app under `apps/website`. It includes a home page, CV page, -blog page, and demos page, plus a lightweight translation flow backed by Redis, -n8n, and Ollama. -Static language files live in `apps/website/lang`; `en.php` and `nah.php` are -curated source files, with the Nahuatl home page intentionally biased toward as -many Nahuatl words as possible while keeping technical terms understandable. -Unsupported browser languages use the same-origin `/translate.php` endpoint, -which calls Ollama server-side through `OLLAMA_HOST` and `OLLAMA_MODEL`; the -browser never calls the private Ollama IP directly. Redis caches per-string -translation results in the `website-production` namespace, while n8n is -available for translation prewarming and batch workflow jobs. The default model -is the custom `website-translator` Ollama model defined in -`apps/website/ollama/Modelfile`. Generated runtime language JSON is saved -through `save_lang.php` on the website PVC, and `translate.php` emits structured -logs for cache hits, misses, Ollama latency, JSON parse failures, and timeouts. - -Create or refresh the Ollama model on the Debian server before deploying a -website image that points at it: - -```bash -./{{ main_script }} website-translation-model -``` - -Ollama must also listen on the Debian host LAN address so Kubernetes pods on -other nodes can reach `OLLAMA_HOST=http://192.168.100.73:11434`: - -```bash -./{{ main_script }} website-ollama-listen -``` - -The Debian host bootstrap also manages Ollama when `debian_pc_install_ollama` -is true: it installs the service, stores models under `/data/ollama/models`, -binds the API to the configured LAN listener, and pulls the lightweight -`ai_gateway.model`. On an existing host, apply just this setup with: - -```bash -./{{ main_script }} ollama-setup -``` - -`{{ main_script }}` also has a backstage local AI helper for doctor commands. -It is not a separate CLI action; when `ai_gateway.enabled` is true in -`homelab.yml`, doctor commands try the configured Ollama model and silently -skip the helper if Ollama is down. The default lightweight model is: - -```bash -ollama pull qwen2.5:0.5b -``` - -Disable it for low-CPU sessions with: - -```bash -LAB_BACKSTAGE_BRAIN_ENABLED=false ./{{ main_script }} doctor-edge -``` - -Build the local homelab knowledge index separately from the main deployment: - -```bash -./{{ main_script }} ai-index -./{{ main_script }} ai-check -./{{ main_script }} ask "how do I check edge to Gitea?" -``` - -The index is built from the non-secret source list in -`infra/ai/knowledge-sources.txt`, skips paths in -`infra/ai/knowledge-excludes.txt`, and defaults to `/data/homelab-ai/index`. -Doctor commands use it as extra context when it exists, but infrastructure -deployment does not depend on it. -Use `ask` as the runbook and command finder. It returns the closest indexed -docs/scripts by default; set `LAB_AI_ASK_LLM=true` to ask Ollama after -retrieval. - -The CV page has two client-side presentation modes: - -- `Elegant`: dark, minimal, terminal-inspired styling with a square profile - image and light green console text. -- `Fancy`: centered circular profile image, cursive orbit text, and a - cursor-following portrait rotation effect. - -The Demos page is a catalog in the PHP website. The actual demo applications are -served from a separate `demos-static` artifact under `apps/demos-static` and are -published through the `demos-static` Argo CD application. Public traffic reaches -them through the edge path at `/demo-apps/`. - -`./{{ main_script }} up` builds and pushes two independent images: - -- a content-hash `php-website` tag generated by `{{ main_script }}` and passed to Argo CD - as a Kustomize image override -- `demos-static:latest` from `apps/demos-static` -- Cosign signatures and signed SPDX SBOM attestations for both pushed images - -The website manifest keeps the stable base image name `php-website:bootstrap`. -During bootstrap, `{{ main_script }}` hashes `apps/website`, builds -`/php-website:src-`, exports that exact reference through -`TF_VAR_website_image_ref`, and the Argo CD Application applies it through -Kustomize. This keeps the GitOps source generic while the deployed image remains -immutable. The Kyverno supply-chain policy mutates admitted pods to the verified -image digest, so the workload runs the same digest that was signed and attested. - -After `./{{ main_script }} apps`, the live deployment image should be a content-hash tag, -for example `192.168.100.73:30500/php-website:src-...`. If it still shows -`php-website:latest`, Argo CD has not rendered the current Application source. -Check the `website-production` Application source, sync status, and repository -access before restarting pods. - -The first demo, `The Client-Side Media Cruncher (Wasm + TS)`, currently performs -private, browser-only image compression and conversion using native Canvas APIs. -Heavier video conversion, such as MP4 to WebM, should use a Rust core compiled -to WebAssembly with a TypeScript UI so the codec work stays fast and still -avoids backend uploads. - -The demos are designed to be local-first so the current cluster can serve them -from any Linux app node without turning either pod into an application server. -The website pod serves the portfolio shell and the `demos-static` pod serves -static demo bundles; CPU-heavy work runs in the visitor's browser. Because the -deployments can run on either Debian or ARM workers, avoid bundling large ML -models, server-side WebSocket probes, or backend video transcoders into either -image. If those demos become production-grade, lazy load model assets in the -browser or move backend workers to a larger node, such as VMs on the Orange Pi 5 -Plus. - -Current demo inventory: - -- Client-side media cruncher: image conversion/compression with Canvas; future - Rust/Wasm codec path for video. -- Internet quality visualizer: live Canvas graph for latency, jitter, and - stability using same-origin browser probes; a dedicated WebSocket echo endpoint - would be the production version. -- Local log and JSON toolbelt: JSON formatting, JWT decoding, URL parsing, and - local text-log filtering. -- Architecture simulator: click-driven load, crash, and auto-scale simulation. -- Offline traveler converter: PWA shell with timezone, currency, and GB/GiB - conversions. -- Privacy-first redactor: local image redaction prototype; future - onnxruntime-web plus quantized YOLO or face model path. -- Local sentiment sandbox: lightweight local sentiment, keyword, and summary - prototype; future Transformers.js/ONNX path. -- Model drift simulator: visual MLOps playground for spikes, corrupted inputs, - and retraining. - -The Kubernetes deployment uses `apps/website/web-app.yaml` as a Kustomize base. -Keep `TF_VAR_registry_endpoint` aligned with the local registry endpoint used by -the app image build and with the image globs in -`apps/supply-chain-policy/local-registry-image-policy.yaml`. - -Keep the `.terraform.lock.hcl` files committed. They pin provider selections and -make bootstrap behavior reproducible across nodes and rebuilds. -## Destructive Rebuilds - -`./{{ main_script }} nuke` resets kubeadm, containerd runtime state, CNI files, Calico -links, iptables rules, and local OpenTofu state. It does not delete retained data -under `/data/openebs/local`. - -For multi-node labs, set `WORKER_SSH_TARGETS` to a space-separated list of SSH -targets. It defaults to an empty string so worker nodes are not cleaned unless -you explicitly include them. +Profile switching uses `stop-cluster` and the selected startup/bootstrap path; +it does not require `nuke`. Destructive actions require separate review of +identity, scoped state, retained storage and recovery. `rebuild-cluster` refuses +automatic destruction of an enrolled cluster because a rebuild changes its +identity. Preserve backups and plan re-enrollment before any such maintenance.