• Stars
    star
    1,912
  • Rank 24,089 (Top 0.5 %)
  • Language
    Shell
  • License
    Do What The F*ck ...
  • Created over 4 years ago
  • Updated 21 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Wife approved HomeOps driven by Kubernetes and GitOps using Flux

My home operations repository :octocat:

... managed with Flux, Renovate and GitHub Actions 🤖

Discord    Kubernetes    Renovate

Home-Internet    Status-Page    Alertmanager


📖 Overview

This is a mono repository for my home infrastructure and Kubernetes cluster. I try to adhere to Infrastructure as Code (IaC) and GitOps practices using the tools like Ansible, Terraform, Kubernetes, Flux, Renovate and GitHub Actions.


Kubernetes

There is a template over at onedr0p/flux-cluster-template if you wanted to try and follow along with some of the practices I use here.

Installation

My cluster is k3s provisioned overtop bare-metal Ubuntu Server using the Ansible galaxy role ansible-role-k3s. 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 server for (NFS) file storage.

🔸 Click here to see my Ansible playbooks and roles.

Core Components

  • actions-runner-controller: Self-hosted Github runners.
  • calico: Internal Kubernetes networking plugin.
  • cert-manager: Creates SSL certificates for services in my Kubernetes cluster.
  • external-dns: Automatically manages DNS records from my cluster in a cloud DNS provider.
  • external-secrets: Managed Kubernetes secrets using 1Password Connect.
  • ingress-nginx: Ingress controller to expose HTTP traffic to pods over DNS.
  • rook: Distributed block storage for peristent storage.
  • sops: Managed secrets for Kubernetes, Ansible and Terraform which are commited to Git.
  • tf-controller: Additional Flux component used to run Terraform from within a Kubernetes cluster.
  • volsync and snapscheduler: Backup and recovery of persistent volume claims.

GitOps

Flux watches my kubernetes folder (see Directories below) and makes the changes to my cluster based on the YAML manifests.

The way Flux works for me here is it will recursively search the kubernetes/apps folder 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. Those Flux kustomizations will generally have a HelmRelease or other resources related to the application underneath it which will be applied.

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

Directories

This Git repository contains the following directories under kubernetes.

📁 kubernetes      # Kubernetes cluster defined as code
├─📁 bootstrap     # Flux installation
├─📁 flux          # Main Flux configuration of repository
└─📁 apps          # Apps deployed into my cluster grouped by namespace (see below)

Cluster layout

Below is a a high level look at the layout of how my directory structure with Flux works. In this brief example you are able to see that authelia will not be able to run until lldap and cloudnative-pg are running. It also shows that the Cluster custom resource depends on the cloudnative-pg Helm chart. This is needed because cloudnative-pg installs the Cluster custom resource definition in the Helm chart.

# Key: <kind> :: <metadata.name>
GitRepository :: home-ops-kubernetes
    Kustomization :: cluster
        Kustomization :: cluster-apps
            Kustomization :: cluster-apps-cloudnative-pg
                HelmRelease :: cloudnative-pg
            Kustomization :: cluster-apps-cloudnative-pg-cluster
                DependsOn:
                    Kustomization :: cluster-apps-cloudnative-pg
                Cluster :: postgres
            Kustomization :: cluster-apps-lldap
                HelmRelease :: lldap
                DependsOn:
                    Kustomization :: cluster-apps-cloudnative-pg-cluster
            Kustomization :: cluster-apps-authelia
                DependsOn:
                    Kustomization :: cluster-apps-lldap
                    Kustomization :: cluster-apps-cloudnative-pg-cluster
                HelmRelease :: authelia

Networking

Click to see a high level network diagram dns
Name CIDR
Management VLAN 192.168.1.0/24
Kubernetes Nodes VLAN 192.168.42.0/24
Kubernetes external services (Calico w/ BGP) 192.168.69.0/24
Kubernetes pods (Calico w/ BGP) 10.42.0.0/16
Kubernetes services (Calico w/ BGP) 10.43.0.0/16
  • HAProxy is configured on my VyOS router for the Kubernetes Control Plane Load Balancer.
  • Calico is configured with externalIPs to expose Kubernetes services with their own IP over BGP which is configured on my router.

☁️ Cloud Dependencies

While most of my infrastructure and workloads are selfhosted I do rely upon the cloud for certain key parts of my setup. This saves me from having to worry about two things. (1) Dealing with chicken/egg scenarios and (2) services I critically need whether my cluster is online or not.

The alternative solution to these two problems would be to host a Kubernetes cluster in the cloud and deploy applications like HCVault, Vaultwarden, ntfy, and Gatus. However, maintaining another cluster and monitoring another group of workloads is a lot more time and effort than I am willing to put in.

Service Use Cost
1Password Secrets with External Secrets ~$65/yr
Cloudflare Domain and R2 ~$30/yr
Migadu Email hosting ~$20/yr
GCP Voice interactions with Home Assistant over Google Assistant Free
GitHub Hosting this repository and continuous integration/deployments Free
Newsgroup Ninja Usenet access ~$70/yr
NextDNS My routers DNS server which includes AdBlocking ~$20/yr
Pushover Kubernetes Alerts and application notifications Free
Terraform Cloud Storing Terraform state Free
UptimeRobot Monitoring internet connectivity and external facing applications ~$60/yr
Total: ~$27/mo

🌐 DNS

Internal DNS

Bind9 and dnsdist are deployed on Vyos as containers. In my cluster external-dns is deployed with the RFC2136 provider that populates Bind9 with all my ingresses DNS records.

dnsdist has some downstream DNS servers configured such as Bind9 (above) and NextDNS profiles. All my clients use dnsdist as the upstream DNS server, this allows for more granularity with configuring DNS across my networks. These could be things like giving each of my VLANs a specific NextDNS profile, or having all requests for my domain forward to Bind9 on certain networks, or only using 1.1.1.1 instead of NextDNS on certain networks where adblocking isn't needed.

External DNS

Another external-dns instance is deployed in my cluster and configure to sync DNS records to Cloudflare. The only ingresses this external-dns instance looks at to gather DNS records to put in Cloudflare are ones that have an annotation of external-dns.alpha.kubernetes.io/target.


🔧 Hardware

Click to see da rack! rack
Device Count OS Disk Size Data Disk Size Ram Operating System Purpose
HP EliteDesk 800 G3 SFF 1 256GB NVMe - 8GB VyOS Router
Intel NUC8i3BEK 3 256GB NVMe - 32GB Ubuntu Kubernetes Masters
Intel NUC8i5BEH 3 240GB SSD 1TB NVMe (rook-ceph) 64GB Ubuntu Kubernetes Workers
PowerEdge T340 1 2TB SSD 8x12TB ZFS (mirrored vdevs) 64GB Ubuntu NFS + Backup Server
Lenovo SA120 1 - 6x12TB (+2 hot spares) - - DAS
Raspberry Pi 1 32GB (SD) - 4GB PiKVM Network KVM
TESmart 8 Port KVM Switch 1 - - - - Network KVM (PiKVM)
APC SMT1500RM2U w/ NIC 1 - - - - UPS
Unifi USP PDU Pro 1 - - - - PDU

Stargazers

Star History Chart


🤝 Gratitude and Thanks

Thanks to all the people who donate their time to the Kubernetes @Home Discord community. A lot of inspiration for my cluster comes from the people that have shared their clusters using the k8s-at-home GitHub topic. Be sure to check out the Kubernetes @Home search for ideas on how to deploy applications or get ideas on what you can deploy.


📜 Changelog

See my awful commit history


🔏 License

See LICENSE

More Repositories

1

cluster-template

A template for deploying a Talos Kubernetes cluster including Flux for GitOps
Python
1,757
star
2

exportarr

AIO Prometheus Exporter for Sabnzbd, Bazarr, Prowlarr, Lidarr, Readarr, Radarr, and Sonarr
Go
530
star
3

containers

My collection of container images
Dockerfile
287
star
4

k3s-gitops-arm

k3s cluster backed by Flux (GitOps) up and running on a cluster of RPi4
Shell
146
star
5

k3s-homeops-ansible

Bootstrap a k3s cluster on top of Ubuntu 20.04
HTML
54
star
6

sops-pre-commit

Sops pre-commit hook
Jinja
41
star
7

home-operations

Highly opinionated Ansible playbooks, Ansible roles, and other things that are used to maintain my home-cluster
Dockerfile
28
star
8

unofficial-builds-for-vyos

Unofficial builds for VyOS™ - Because the cost to get LTS is too damn high for our Home Labs
26
star
9

home-service

My home service stack running on a Beelink EQ12 with Fedora IoT. These podman services are supporting my home infrastructure including, DNS and Kubernetes clusters.
Shell
25
star
10

intel-gpu-exporter

Python
23
star
11

dotfiles

My fish compatible dotfiles managed by chezmoi
Shell
15
star
12

gluctl

The glue that helps maintain a Kubernetes Home Lab
JavaScript
12
star
13

kubanetics

A container with various scripts for Kubernetes
Shell
12
star
14

qbittorrent-prune

Remove torrents from qBittorrent that are reported unregistered by a tracker
Shell
8
star
15

dns-in-a-bottle

AIO container for running bind, blocky and dnsdist
Dockerfile
6
star
16

hass-config

Home Assistant configuration for my home
Python
5
star
17

opnsense-coredns

A CoreDNS FreeBSD build specifically for OPNsense which includes some additional plugins
Dockerfile
5
star
18

qbittorrent-scripts

Python
4
star
19

sonarr-episode-prune

Delete episodes from specified series in Sonarr
Python
4
star
20

containers-mirror

Stop-gap container registry mirror of upstream applications that only use Docker Hub
Dockerfile
4
star
21

radarr-exporter

Prometheus Exporter for Radarr
Go
3
star
22

sonarr-exporter

Prometheus Exporter for Sonarr
Go
3
star
23

opaws

CLI tool to sign into AWS (MFA) accounts using 1Password
Shell
2
star
24

custom-error-pages

My custom error pages for the nginx-ingress controller
HTML
2
star
25

doks-cluster

Testing Flux with Digital Ocean Kubernetes Service
HCL
2
star
26

flux-repository-collection

A collection of various (Bucket|Git|Helm|OCI) Repositories for use with Flux
2
star
27

k3s-staging

Jinja
2
star
28

pi4-cluster-example

Test Flux2 GitOps Cluster
Shell
2
star
29

fcos-build

1
star
30

vyos-config

My VyOS configuration
1
star
31

makejinja-mjfilter-example

Python
1
star
32

draft-on-labels-action

GitHub Action to update a pull request to a draft based on labels
TypeScript
1
star
33

onedr0p.github.io

Support Devin
HTML
1
star
34

onedr0p

1
star
35

.github

1
star
36

container-images-refactor

1
star