e5af5c394587f4648e4121efbe93a2e741b8b5df
Homelab
Goals
Wanting to set up homelab kubernetes cluster.
Software
- Running applications
- NAS, backups, security recorder
- Online presence, website, email, communicators (ts3, matrix?)
- Git server, container registry
- Environment to deploy my own apps
- Some LLM server, apps for my own use
- Public services like Tor, mirrors of linux distros etc.
- Some frontends
- Awesome-Selfhosted, Awesome Sysadmin
- Managing them hopefully using GitOps
- FluxCD, Argo etc.
- State of cluster in git, all apps version pinned
- Some bot to inform about updates?
- It's a homelab
- Should be open to experimenting
- Avoiding vendor lock-in, changing my mind shouldn't block me for too long
- Backups of important data in easy to access format
- Expecting downtime, no critical workloads
- Trying to keep it reasonably up anyways
Infrastructure
- Using commodity hardware
- Reasonably scalable
- Preferably mobile workloads, software should be a bit more flexible than me moving disks and data
- Replication is overkill for most data
- Preferably dynamically configured network
- BGP with OpenWRT router
- Dynamically allocated host subnets
- Load-balancing (MetalLB?), ECMP on router
- Static IP configurations on nodes
- IPv6 native, IPv4 accessible
- IPv6 has whole block routed to us which gives us control over address routing and usage
- Which allows us to expose services directly to the internet without complex router config
- Which allows us to use eg. ExternalDNS to autoconfigure domain names for LB
- But majority of the world still runs IPv4, which should be supported for public services
- Exposing IPv4 service may require additional reconfiguration of router, port forwarding, manual domain setting or controller doing this some day in future
- One public IPv4 address means probably extensive use of rule-based ingress controllers
- IPv6 internet from pods should not be NATed
- IPv4 internet from pods should be NATed by router
Current implementation idea
- Cluster server nodes running Talos
- OpenWRT router
- VLAN / virtual interface, for cluster
- Configuring using Ansible
- Peering with cluster using BGP
- Load-balancing using ECMP
- Cluster networking
- Cilium CNI
- Native routing, no encapsulation or overlay
- Using Cilium's network policies for firewall needs
- IPv6 address pool
- Nodes: 2001:470:61a3:100::/64
- Pods: 2001:470:61a3:200::/64
- Services: 2001:470:61a3:300::/112
- Load balancer: 2001:470:61a3:400::/112
- IPv4 address pool
- Nodes: 192.168.1.32/27
- Pods: 10.42.0.0/16
- Services: 10.43.0.0/16
- Load balancer: 10.44.0.0/16
- Storage
- OS is installed on dedicated disk
- Mayastor managing all data disks
- DiskPool for each data disk in cluster, labelled by type SSD or HDD
- Creating StorageClass for each topology need (type, whether to replicate, on which node etc.)
Working with repo
Repo is preconfigured to use with nix and vscode
Install nix, vscode should pick up settings and launch terminals in nix develop with all needed utils.
Bootstrapping cluster
- Configure OpenWRT, create dedicated interface for connecting server
- Set up node subnet, routing
- Create static host entry
kube-api.homelab.lumpiasty.xyzpointing at ipv6 of first node
- Connect server
- Grab Talos ISO, dd it to usb stick
- Boot it and using keyboard set up static ip ipv6 subnet, should become reachable from pc
talosctl gen config homelab https://kube-api.homelab.lumpiasty.xyz:6443- Generate secrets
talosctl gen secrets, backup, keepsecrets.ymlsafe - Generate config files
make gen-talos-config - Apply config to first node
talosctl apply-config --insecure -n 2001:470:61a3:100::2 -f controlplane.yml - Wait for reboot then
talosctl bootstrap --talosconfig=talosconfig -n 2001:470:61a3:100::2 - Set up router and CNI
Updating Talos config
Update patches and re-generate and apply configs.
make gen-talos-config
make apply-talos-config
Description
Languages
Python
28.4%
Jinja
24.1%
Shell
17.3%
HCL
14.7%
Nix
9.2%
Other
6.3%