One Year Later: I Finally Open-Sourced My Homelab K3s Stack
How do you publish your homelab code without accidentally publishing your whole infrastructure, passwords included? For a year I did not dare.

🌐 Also available in: Deutsch · Français · Español · Italiano · Português · Nederlands · Polski
In short: A year after the start, my homelab K3s stack is finally open source – without accidentally publishing my entire infrastructure with it. The trick is two separate Git remotes: a private Gitea instance with secrets and inventory, a public repository without them. The post shows the stack, what a single playbook run does, how secrets are handled and everything that was harder than expected.
In a few of my recent posts I mentioned that I was trying to figure out how to publish my homelab automation code *without accidentally open-sourcing my entire infrastructure along with it* 😅
Turns out that’s a surprisingly non-trivial problem when your Ansible inventory looks like a cyberpunk treasure chest full of vaults, secrets and host-specific variables. 🔐🐉
After a bit of trial, error, caffeine and questionable life choices… I finally found a setup that works beautifully:
👉 two separate git remotes.
A private self-hosted Gitea instance keeps the *real* repository — including encrypted secrets, vault files and all the spicy internal bits.
Meanwhile a public GitHub repo only receives the clean automation code, with sensitive files excluded via .gitignore and replaced by friendly .example templates. 🧼✨
Anything secret is encrypted using Ansible Vault (AES-256) anyway — so even if something somehow slips through, all an attacker gets is encrypted gobbledygook. 🧠💾
📦 Repo:
👉 github.com/aptupgrademe/www_k3s (opens in a new tab)
The project provisions either Nextcloud or WordPress on a fresh single-node K3s cluster running on AlmaLinux 9.
One command.
Zero click-ops.
Maximum nerd energy. ⚡🤓
Table of Contents
🧠 The Idea
Run:
ansible-playbook blog.yml --limit <host> --ask-vault-pass
…against a completely fresh VPS and watch it transform itself into a fully hardened, TLS-enabled, monitored WordPress or Nextcloud server like some kind of infrastructure Pokémon evolution. 🐛➡️🐉
No manual SSH fiddling.
No mystery setup steps.
No “TODO: document later” graveyard. 💀
Everything is idempotent — re-run it anytime without nuking your data or summoning configuration drift demons.
⚙️ Stack at a Glance
- 🏗️ K3s — Kubernetes without the enterprise trauma
- 🔀 F5 nginx-ingress — running as DaemonSet with
hostNetwork: true - 🔒 cert-manager — automatic Let’s Encrypt certs because browsers yearn for green locks
- 📝 WordPress 6.9-fpm + nginx sidecar + MariaDB 10.11
- ☁️ Nextcloud 33-fpm + Redis + Collabora (opens in a new tab) CODE for nerd-grade self-hosted office vibes
- 📊 Prometheus + Grafana — because if you can’t graph it, does it even exist?
- 🛡️ iptables — default DROP, portscan detection, ICMP rate limiting, tiny digital moat 🏰
- 🔐 Fail2Ban, auditd, rkhunter, dnf-automatic — paranoia as code™
🚀 What One Playbook Run Actually Does
- 🔑 Hardens SSH — custom port, key-only auth, tighter configs
- 🔥 Builds IPv4 + IPv6 firewall rules with portscan detection via
xt_recent - 🧱 Enables SELinux enforcing with correct container contexts
- ☸️ Installs K3s (opens in a new tab), Helm, cert-manager and nginx-ingress
- 📦 Deploys the full Kubernetes workload stack automatically
- 📝 Configures WordPress via WP-CLI like a civilized automation goblin
- ☁️ Configures Nextcloud (opens in a new tab) via
occincluding Redis, SMTP and trusted domains - 📈 Sets up monitoring exporters + Prometheus scraping + Grafana dashboards
- 🛡️ Deploys Fail2Ban, auditd, rkhunter scans and unattended security updates
- ☕ Probably consumes less coffee than I did while debugging it
🔐 Secrets & Security
All credentials are encrypted using Ansible Vault (AES-256).
Sensitive files like:
vault.ymlvars.ymlhosts.yml
…never touch the public repository. 🚫🌍
The GitHub repo only contains reusable automation code and .example templates:
vars.yml.example
vault.yml.example
hosts.yml.example
Clone → fill in values → encrypt → deploy. ✨
🙃 Things That Were Way Harder Than Expected
Let’s Encrypt HTTP-01 challenge returning 301
Turns out redirecting everything to HTTPS also redirects the ACME challenge. Who could have guessed? 🙃
Fixed using F5 Mergeable Ingresses (master/minion pattern) so
/.well-known/bypasses redirects.Infinite HTTPS redirect loop
My first nginx logic basically DDoSed itself philosophically.
Fixed with a cleaner three-variable redirect pattern.
mysqld_exporter dropped
DATA_SOURCE_NAMEback in v0.15.0Credentials now need a mounted
.my.cnffile.Also discovered that
0600permissions don’t help if the container runs asnobody. 🤡iptables OUTPUT DROP broke K3s internals
Because apparently Kubernetes enjoys talking to itself constantly.
Fixed with explicit ACCEPT rules for pod/service CIDRs.
Grafana dashboard 1860 showed “No data”
Modern Grafana dashboards no longer contain
__inputs.Solution: tiny Python patcher script talking to the Grafana API like a little automation goblin.
🎯 Conclusion
Sharing code without sharing secrets works – with two remotes, Vault for the secrets and a public repository that only holds the blueprint. The way there was paved with redirect loops, changed exporter options and a firewall that disturbed Kubernetes talking to itself. Now anyone can rebuild the stack, and I have a good reason to keep it clean.
🧪 Try It Yourself
git clone https://github.com/aptupgrademe/www_k3s.git
cd www_k3s
cp inventory/hosts.yml.example inventory/hosts.yml
cp inventory/host_vars/test/vars.yml.example inventory/host_vars/myhost/vars.yml
# fill in your values, then:
ansible-vault encrypt inventory/host_vars/myhost/vault.yml
ansible-playbook blog.yml --limit myhost --ask-vault-pass
The full quickstart, role overview and variable documentation live in the GitHub README.
PRs, feedback and fellow infrastructure nerds welcome. 🚀🐧☸️
Addendum (28 November 2026): The www_k3s repository is now archived and has been split: the Nextcloud part lives on in nextcloud_k3s (opens in a new tab), the blog server in www_hugo (opens in a new tab). The links in this post point to the state at the time and still work.
📚 Related posts:
- git log --since=“1 year ago”: One Year of apt-upgrade.me && Publishing the Ansible Playbooks for Nextcloud on K3s
- The Ansible Tour, Part 1: One Repository, Three Servers – How the Code Is Organised and What Happens During a Run
- Ten Points, One Branch: Taking My Ansible Code From “It Works” to “It Is Clean”
