|
| 1 | +# Gemini Context: Home Automation & Infrastructure |
| 2 | + |
| 3 | +This `GEMINI.md` provides context for the AI agent interacting with this repository. This project serves as the Infrastructure-as-Code (IaC) and configuration management repository for a home automation setup powered by Kubernetes on Raspberry Pis. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +* **Goal:** Manage a home Kubernetes cluster and home automation devices. |
| 8 | +* **Core Technologies:** |
| 9 | + * **Orchestration:** [k3s](https://k3s.io/) (Lightweight Kubernetes). |
| 10 | + * **GitOps:** [Flux CD](https://fluxcd.io/) automatically syncs the cluster state with this repository. |
| 11 | + * **Configuration Management:** [Ansible](https://www.ansible.com/) configures the bare metal Raspberry Pi nodes. |
| 12 | + * **Home Automation:** [Home Assistant](https://www.home-assistant.io/) is the central hub. |
| 13 | + * **Dependency Management:** [Renovate](https://github.com/renovatebot/renovate) handles dependency updates. |
| 14 | + |
| 15 | +## Architecture |
| 16 | + |
| 17 | +* **Hardware:** |
| 18 | + * **Cluster:** 3x Raspberry Pi 4 (8GB) nodes (`k8s-master-1`, `k8s-worker-1`, `k8s-worker-2`). |
| 19 | + * **Network:** UniFi stack (Dream Machine, Switches, APs). |
| 20 | + * **Storage:** Synology DS1621+ NAS (NFS provisioner). |
| 21 | + * **Other:** Raspberry Pi 3b (Pi-hole), various IoT devices (Philips Hue, Sonoff, etc.). |
| 22 | +* **Network Layout:** |
| 23 | + * `192.168.1.32/28`: Kubernetes cluster. |
| 24 | + * `192.168.1.16/28`: Infrastructure. |
| 25 | + * See `README.md` for full VLAN details. |
| 26 | + |
| 27 | +## Directory Structure |
| 28 | + |
| 29 | +* `ansible/`: Ansible playbooks and inventory for provisioning Raspberry Pis. |
| 30 | + * `hosts.yml`: Inventory file defining `kubernetes` and `piholes` groups. |
| 31 | + * `site.yml`: Main playbook. |
| 32 | +* `clusters/home-cluster/`: Kubernetes manifests managed by Flux. |
| 33 | + * `flux-system/`: Flux configuration (GitRepository, Kustomization). |
| 34 | + * `home-assistant/`, `mosquitto/`, `monitoring/`, etc.: Application specific manifests. |
| 35 | +* `.github/`: GitHub Actions workflows for linting and maintenance. |
| 36 | + |
| 37 | +## Key Workflows |
| 38 | + |
| 39 | +### 1. GitOps Deployment |
| 40 | +Changes to the `clusters/home-cluster` directory are automatically deployed by Flux. |
| 41 | +* **Source:** `https://github.com/mfoo/home.git` (branch: `main`). |
| 42 | +* **Sync Path:** `./clusters/home-cluster`. |
| 43 | +* **Action:** Commit and push changes to `main`. Flux will pick them up within 1 minute (GitRepository interval) to 10 minutes (Kustomization interval). |
| 44 | + |
| 45 | +### 2. Ansible Configuration |
| 46 | +Used for bootstrapping and managing the OS level of the Raspberry Pis. |
| 47 | +* **Command:** |
| 48 | + ```bash |
| 49 | + ansible-playbook -i ansible/hosts.yml ansible/site.yml |
| 50 | + ``` |
| 51 | +* **Linter:** CI runs `ansible-lint ansible/site.yml`. |
| 52 | + |
| 53 | +### 3. Adding a New Kubernetes Node |
| 54 | +1. **Provision OS:** Flash generic OS, set hostname, update packages. |
| 55 | +2. **Kernel Config:** Add `cgroup_memory=1 cgroup_enable=memory` to `/boot/firmware/cmdline.txt`. |
| 56 | +3. **Ansible:** Add host to `ansible/hosts.yml` and run the playbook. |
| 57 | +4. **Join Cluster:** Use `k3sup` (requires SSH access). |
| 58 | + ```bash |
| 59 | + k3sup join --server-host k8s-master-1 --host <NEW_NODE_HOSTNAME> --user ubuntu |
| 60 | + ``` |
| 61 | + |
| 62 | +## Development Conventions |
| 63 | + |
| 64 | +* **Secrets:** Managed via [Sealed Secrets](https://github.com/bitnami-labs/sealed-secrets). **Never commit raw secrets.** |
| 65 | +* **Formatting:** |
| 66 | + * Markdown files are linted. |
| 67 | + * Ansible playbooks are linted. |
| 68 | +* **CI/CD:** GitHub Actions run linting checks on push and PR. |
0 commit comments