Skip to content

fma965/f9-homelab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3,347 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Outdated readme, don't believe it!

๐Ÿš€ F9's Homelab ๐Ÿšง

... managed with Flux, Doco-CD, Renovate and GitHub Actions ๐Ÿค–


๐Ÿ’ก Overview

This is a mono repository for my entire homelab configuration, including my Kubernetes cluster and Docker instance. It uses Infrastructure as Code (IaC) and GitOps practices as much as possible using tools like Kubernetes, Flux, Renovate, Doco-CD, and GitHub Actions. All secrets are using 1Password Connect with the exception of 1 or 2 which are SOPS encrypted.

๐ŸŒฑ Kubernetes

My Kubernetes cluster is deployed with Talos. This is a semi-hyper-converged cluster, workloads and block storage are sharing the same available resources on my nodes while I have a separate TrueNAS server for NFS/SMB shares, AI, bulk file storage and backups.

Core Components

  • cert-manager: Creates SSL certificates for services in my cluster.
  • cilium: eBPF-based networking for my workloads.
  • envoy: Modern Kubernetes Gateway provider
  • rook: Distributed storage provider for peristent storage using CEPH
  • volsync: Asynchronous data replication for Kubernetes volumes to NAS via NFS
  • external-secrets: Managed Kubernetes secrets using 1Password Connect.
  • sops: Managed secrets for Kubernetes and Terraform/OpenTofu which are commited to Git.

GitOps

Flux watches the clusters in my kubernetes folder (see Directories below) and makes the changes to my clusters based on the state of my Git repository.

Flux will apply all in kubernetes/apps

Flux will recursively search sub folders until it finds the most top level kustomization.yaml per directory and then apply all the resources listed in it. That aforementioned kustomization.yaml will generally only have a namespace resource and one or many Flux kustomizations (ks.yaml). Under the control of those Flux kustomizations there will be a HelmRelease or other resources related to the application which will be applied.

Renovate watches my entire repository looking for dependency updates, when they are found a PR is automatically created. When PRs are merged Flux applies the changes to my cluster.


๐Ÿฌ Docker

My Docker instance is running on my TrueNAS server and managed by Doco-CD with GitOps practices, it runs AI workloads that require a dedicated NVidia GPU, Ser2Net for my Zigbee adapter and more, I've tried to limit as much as possible what the NAS does and where possible offloaded it to the Kubernetes cluster.

GitOps

Doco-CD watches my docker folder (see Directories below) and makes the changes based on the state of my Git repository.

Doco-CD is controlled mostly from a single file, the .doco-cd.yaml file. This is the file that tells Doco-CD what folders to search for compose files to deploy.


๐Ÿš€ Let's Go!

Pre-requisites

Hardware

  • 3x Computers (I'm using Dell Optiplex 3060's with 2.5Gbe Ethernet)

Software

  • Linux or WSL on Windows is preferred
  • Brew - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Stage 1: Repository Preparation (Infrastructure)

  1. Create a new repository by clicking the green Use this template button at the top of this page, then clone the new repo you just created and cd into it.

Warning

As this repository assumes it's for myself, there are many hardcoded domain name references currently set, I would recommend find and replacing all references of ${SECRET_EXTERNAL_DOMAIN} with your own tld and f9-casa with your own tld replacing dots with dashes, you will ofcourse also need to update any secret files with your own values.

Critical Files that will need updating are

Other files should be updated, but these ones will stop deployment working

Stage 2: Bootstrap Talos Infrastructure

Proxmox Talos VM's, Basic Kubernetes cluster with Cilium

  1. Ensure the following enviroment variables are set to the correct values/paths PROXMOX_VE_USERNAME, PROXMOX_VE_PASSWORD
export PROXMOX_VE_USERNAME="root@pam"
export PROXMOX_VE_PASSWORD="password"
  1. Edit the infrastructure/talos/prod.auto.tfvars file to reflect your desired configuration, refer to comments for explanations of eaach variable

  2. Execute the Infrastructure Bootstrap script

rm infrastructure/talos/output/* # WARNING! This will delete your old kube-config and talos-confg
rm infrastructure/talos/terraform.tfstate # WARNING! This will delete state
rm infrastructure/talos/terraform.tfstate.backup # WARNING! This will delete state
chmod +x ./infrastructure//talos/bootstrap.sh
./infrastructure/talos/bootstrap.sh

Tip

Optionally add --dry-run/-d to test it, or if you are feeling brave --auto-approve/-y to skip confirmation prompts

Note

Approximate time to deploy: 5 Minutes (assuming NVME storage)

Stage 3: Bootstrap FluxCD Deployment

  1. Ensure you have updated all your *sops* files in kubernetes/** to match your own values

Note

Not many of them have sample files currently but eventually i will ensure every *sops* file has a matching *.sample file [!TIP] If you are using VSCode you should be able to automatically encrypt your sops files.

  1. Ensure the following enviroment variables are set to the correct values/paths SOPS_AGE_KEY_FILE, KUBECONFIG, GITHUB_OWNER, GITHUB_REPO
export SOPS_AGE_KEY_FILE=$PWD/.age.key
export KUBECONFIG=$PWD/infrastructure/talos/output/kube-config.yaml
export GITHUB_REPO="https://github.com/fma965/f9-homelab" # replace with your github repo url
  1. Execute the Kubernetes Bootstrap script
chmod +x ./kubernetes/bootstrap.sh
./kubernetes/bootstrap.sh

Tip

Optionally if you are feeling brave --auto-approve/-y to skip confirmation prompts

Note

Approximate time to deploy: 10 Minutes (assuming NVME storage, excluding PV restore if applicable)

Stage 4: Bootstrap Docker Deployment (Semi-Manual)

Warning

If you do not intend to use Docker skip this stage

Note

Currently Komodo does not support adding of a Git Repo via the km CLI, once this is added we can automate this a bit more

  1. Install Komodo from the AppStore (TrueNAS) or Docker Compose files (UnRaid / Other)
  2. Access the Komodo WebUI
  3. Navigate to "Settings" > "Profile" and create a "New Api Key", copy the Key and Secret in to the Komodo 1Password entry
  4. Navigate to "Settings" > "Providers" and add a Github.com Account using your token (regenerate it in Github if needed)
  5. Navigate to "Syncs" and Create a New Resource Sync called "f9-homelab"
  6. Set the Mode to "Git Repo", Repo to "fma965/f9-homelab"
  7. Set the Account to "fma965"
  8. Add the following resource path docker/komodo.toml
  9. Enable "Delete Unmatched Resources" and "Managed"
  10. Make sure only "Sync Resources" is checked under the Include section
  11. Click "Save", Click "Refresh" and the "Execute"

๐Ÿ”ฎ Git Repo Structure

Click here to the directories of this Git Repo with descriptions
.
โ”œโ”€โ”€ ๐Ÿ“‚ docker
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ infrastructure
โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ talos
โ”‚       โ”œโ”€โ”€ ๐Ÿ“‚ output              # Terraform output artifacts
โ”‚       โ””โ”€โ”€ ๐Ÿ“‚ talos               ๐Ÿค– # Talos Linux Kubernetes configurations
โ”‚
โ””โ”€โ”€ ๐Ÿ“‚ kubernetes
    โ”œโ”€โ”€ ๐Ÿ“‚ apps
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ backup              ๐Ÿ’พ # Backup solutions
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ ceph-csi            ๐Ÿ’พ # Ceph CSI storage driver
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ cert-manager        ๐Ÿ“œ # SSL certificate management
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ default             ๐Ÿ  # Dashboard and landing page
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ external-secrets    ๐Ÿคซ # External secret management
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ flux-system         โšก # GitOps management (FluxCD)
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ game                ๐Ÿฆ– # Game servers
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ git                 โŽ™ # Git services
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ kube-system         โš™๏ธ # Core Kubernetes system components
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ observability       ๐Ÿ‘๏ธ # Monitoring and logging stack
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ openebs-system      ๐Ÿ’พ # Container Attached Storage (OpenEBS)
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ postgresql          ๐Ÿ˜ # PostgreSQL databases
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ redis               ๐Ÿง  # Redis key-value stores
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ security            ๐Ÿ›ก๏ธ # Security tools
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ system-upgrade      โฌ†๏ธ # Kubernetes node upgrade controller
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ traefik             ๐Ÿšฆ # Ingress controller and reverse proxy
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ volsync             ๐Ÿ”„ # Volume snapshot and replication
    โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ webdev              ๐ŸŒ # Web development projects
    โ”œโ”€โ”€ ๐Ÿ“‚ components
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ common             โš™๏ธ # Shared Kubernetes components
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ gatus
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ volsync
    โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ volsync-backuponly
    โ””โ”€โ”€ ๐Ÿ“‚ flux
        โ””โ”€โ”€ ๐Ÿ“‚ cluster             โšก # GitOps cluster definitions

๐Ÿ˜ถ Cloud Dependencies

Most of my infrastructure and workloads are self-hosted and do not rely upon cloud services, some however do, here is a list of them. Note that some of these may not be part of this repo but rather just things that i also use in relation to it.

Service Use Cost
1Password Secrets with External Secrets ~$40/yr
Cloudflare Domain ~ยฃ6/yr
GCP Voice interactions with Home Assistant over Google Assistant Free
GitHub Hosting this repository and continuous integration/deployments Free
Discord Alerts and notifications Free
Pushover Kubernetes Alerts and application notifications $5 OTP

๐ŸŽ“ Wiki

Check out my Wiki to see more about my hardware and much more


๐Ÿ™ Gratitude and Thanks

Thanks to the Home Operations / OneDr0p Discord and community.

About

HomeOps driven by Kubernetes and GitOps using Flux

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors