- Shell 93%
- Python 3.9%
- jq 1.8%
- JavaScript 1.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .claude | ||
| .forgejo/workflows | ||
| config | ||
| docs | ||
| gitops | ||
| manifests | ||
| schemas/longhorn.io | ||
| scripts | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| .kube-linter-rendered.yaml | ||
| .markdownlint.yml | ||
| .pre-commit-config.yaml | ||
| .shellcheckrc | ||
| .v8rrc.yml | ||
| .yamllint.yml | ||
| CLAUDE.md | ||
| mise.toml | ||
| README.md | ||
| renovate.json | ||
turingpi-kubernetes
GitOps-managed k3s cluster on a Turing Pi 2, built by adapting Turing Pi's
own documentation to a 4-node cluster at 192.168.5.11-14:
- Kubernetes Installation
- Helm and Arkade
- Network Configuration
- Cluster Storage
- Argo CD
- Sample App Deployment
Detailed, per-topic write-ups adapted from each guide live in docs/. This
file is the quick path from bare metal to a running, GitOps-managed sample
app.
What's here vs. what the guides show
Two deliberate departures from the source guides, both explained in more
detail in docs/:
- Operated from your workstation, not from Node1 over SSH. The guides
install Helm on Node1 and run every
kubectl/helmcommand there. This repo fetches the kubeconfig to your machine once (scripts/03-fetch-kubeconfig.sh) and runs everything after that locally. SSH into a node is only used for OS-level steps: hostnames, OS packages, k3s itself, and storage packages. - The sample app is actually deployed via ArgoCD, not
kubectl apply. The guides deploy Redis by hand and mention ArgoCD as something you could also use. Here, the Redis manifests live ingitops/apps/and ArgoCD is what applies them — that's the GitOps part.
Everything else (node roles, install flags, MetalLB pool sizing, storage choice) mirrors the source guides directly, with IPs substituted for this cluster.
Beyond the source guides
None of this is part of the six Turing Pi guides. All of it is added the
same way as everything else here: as ArgoCD-managed apps under
gitops/argocd-apps/.
- Monitoring — Prometheus + Grafana for metrics, Loki + Grafana Alloy
for logs, with a retention period set in
gitops/argocd-apps/loki.yaml. It reaches past the cluster: machines on the LAN send syslog to a receiver in the cluster, and the Home Assistant box's own system metrics are scraped and dashboarded. See 07-monitoring.md. Gatus checks every service from the outside — cluster UIs through LAN DNS and Traefik, esle.fi, home devices — and the game servers are monitored as well; see 12-gatus-homepage.md. - Secrets — every application credential the cluster uses lives in a 1Password vault and is rendered into Kubernetes Secrets by External Secrets Operator. No secret value is in git. See 10-secrets.md.
- Dependency updates — Renovate runs as a CronJob and keeps every repository on git.esle.fi current, this one included. Here, patch and minor updates merge themselves once CI passes, in a window when someone is around; the updates that need a manual step wait for review. See 11-renovate.md.
- Backups — every Longhorn volume except Prometheus's is backed up on a schedule to an S3 bucket on esle.fi, with a system backup for restoring the whole cluster; a missed backup raises an alert. See 04-storage.md.
- Automations — Node-RED builds them as flows rather than code: it reads and acts on Home Assistant entities over its websocket API, and glues services together. See 13-node-red.md.
- Network map — Scanopy scans every VLAN on a schedule and reads the UniFi console, and draws hosts, services and links from what it finds. See 16-scanopy.md.
- Remote access — a Tailscale subnet router puts the whole LAN on a tailnet, so every service is reachable from anywhere exactly as at home, with no port opened on the router. See 14-tailscale.md.
- Shared authentication across services (Authentik), built in three
phases:
- Local DNS + wildcard certs — AdGuard Home and an ACME wildcard
cert for
*.t.9b11.xyz. See 08-dns-and-certs.md. - Hostname routing through Traefik — Grafana, Longhorn, ArgoCD,
AdGuard Home, Authentik, Gatus, Homepage, Node-RED, Scanopy, Kavita,
Kavita upload, MetaKavita and Audiobookshelf each get a
.t.9b11.xyzroute (gitops/apps/ingress-routes/), and a placeholder landing page answers on the baret.9b11.xyz. Grafana also keeps its direct MetalLB IP; Longhorn's and ArgoCD's Services are ClusterIP only. - Authentik itself — native OIDC for Grafana, ArgoCD, Scanopy and
Kavita and Audiobookshelf, forward-auth for the services with no
native OIDC support:
Longhorn, AdGuard Home, Gatus, Homepage, Node-RED, Kavita upload and
MetaKavita. Its
Providers/Applications are declared as blueprints in git
(
gitops/apps/authentik-blueprints/, and the OIDC blueprint ingitops/apps/external-secrets-config/authentik.yaml); the first-login setup wizard is the manual step. See 09-authentik.md.
- Local DNS + wildcard certs — AdGuard Home and an ACME wildcard
cert for
Node reference
| Node | IP | Boot disk | Role |
|---|---|---|---|
| BMC | 192.168.5.10 | — | Turing Pi 2 control board (not a k8s node — power control, flashing, BMC web UI) |
| Node1 (RK1) | 192.168.5.11 | NVMe, 983G | control-plane + worker + Longhorn storage |
| Node2 (RK1) | 192.168.5.12 | NVMe, 983G | worker + Longhorn storage |
| Node3 (RK1) | 192.168.5.13 | NVMe, 983G | worker + Longhorn storage (or NFS server) |
| Node4 (RK1) | 192.168.5.14 | NVMe, 983G | worker + Longhorn storage (reflashed from eMMC — see 04-storage.md) |
Check the MetalLB pool (METALLB_POOL in config/cluster.env) against
your router's DHCP lease range before running run-all.sh. On UniFi
the default range contains the whole pool; see
03-networking.md.
Prerequisites
On your workstation:
sshaccess to all four nodes (key-based, no password prompts — the scripts don't handle interactive auth)kubectlandhelm— pinned inmise.toml(mise install); install some other way if you don't use miseopenssl(for token generation; present by default on macOS/Linux)op(1Password CLI) andjq— pinned inmise.toml; used byscripts/12-seed-onepassword-vault.shandscripts/13-create-onepassword-token.sh- a 1Password account, to hold the vault and the read-only service account the cluster reads it with (see 10-secrets.md)
On the nodes: Ubuntu, reachable over SSH as the ubuntu user with
passwordless sudo (the default for cloud-init's ubuntu user on a
stock image). Every privileged remote command in scripts/ runs over a
non-interactive ssh host command, which can't answer a sudo password
prompt — if your image asks for one, add a NOPASSWD sudoers entry for
ubuntu before running anything here.
Quick start
cp config/cluster.env.example config/cluster.env
# edit config/cluster.env if your IPs/pool/SSH user differ from the defaults
./scripts/run-all.sh
run-all.sh runs the scripts in its STEPS list, in that order, and stops
on the first failure. The rest need manual input first or are run on
demand. What each one does:
| Script | What it does |
|---|---|
00-generate-token.sh |
Generates the k3s cluster join token (config/k3s-token) |
00b-set-hostnames.sh |
Sets every node's hostname to <name>.t.9b11.xyz |
00c-install-prerequisites.sh |
Installs OS packages k3s expects but doesn't bundle (iptables) |
01-install-k3s-master.sh |
Installs k3s server on Node1 |
02-install-k3s-workers.sh |
Joins Node2-4 as workers |
03-fetch-kubeconfig.sh |
Pulls kubeconfig to config/kubeconfig, plus a personal copy at ~/.kube/configs/turingpi.conf |
04-label-nodes.sh |
Labels every node node-type=worker; gates which nodes Longhorn may use |
05-install-metallb.sh |
Installs MetalLB + the address pool |
06-prepare-storage-nodes.sh |
Installs Longhorn's node-level dependencies |
07b-setup-nfs-server.sh + 07b-install-nfs-provisioner.sh |
Alternative to Longhorn — see docs/04-storage.md |
08-install-argocd.sh |
Installs ArgoCD, prints the admin password |
09-argocd-ui.sh |
Port-forwards the ArgoCD UI to localhost:8080 |
10-bootstrap-gitops.sh |
Applies the ArgoCD "app of apps" once GIT_REPO_URL is set |
12-seed-onepassword-vault.sh |
Writes the vault items every Secret is rendered from, copying live values — see docs/10-secrets.md |
13-create-onepassword-token.sh |
Stores the 1Password service account token the operator reads the vault with — see docs/10-secrets.md |
17-sync-grafana-admin-password.sh |
Makes Grafana's stored admin password match its Secret, so provisioning reloads work — see docs/07-monitoring.md |
generate-grafana-dashboards.sh |
Regenerates the dashboards in gitops/apps/grafana-dashboards/ from pinned sources — see docs/07-monitoring.md |
generate-crd-schemas.py |
Regenerates schemas/, kubeconform's schemas for the Longhorn CRDs, from the chart version gitops/apps/longhorn/kustomization.yaml pins — Renovate runs it on a bump; run it after a manual one |
sync-promtool-version.sh |
Sets promtool in mise.toml to the Prometheus the pinned kube-prometheus-stack chart deploys — Renovate runs it on a bump; run it after a manual one |
restore-test.sh |
Restores a volume's latest backup into <pvc>-restore-test, verifies it, then cleans up (KEEP=1 keeps it) — see docs/04-storage.md |
release-argocd-ownership.sh |
After 08-install-argocd.sh, once argocd-config has synced: drops kubectl's field ownership of ArgoCD's objects — see docs/05-argocd.md |
cluster-maintenance.sh |
down stops everything holding a Longhorn volume and waits for them to detach so the nodes can be powered off; up restores it — see docs/15-maintenance.md |
After the cluster is up
export KUBECONFIG=config/kubeconfig
kubectl get nodes -o wide
Then hand the sample app to ArgoCD:
git remote add origin <your-remote-url>
git push -u origin main
# add GIT_REPO_URL=<your-remote-url> to config/cluster.env, then:
./scripts/10-bootstrap-gitops.sh
./scripts/09-argocd-ui.sh # http://localhost:8080, user: admin
The script substitutes GIT_REPO_URL into the root Application only
(manifests/argocd/root-app.yaml). The child Applications in
gitops/argocd-apps/ that deploy manifests from this repository name
https://git.esle.fi/ivuorinen/turingpi-cluster.git directly. In a fork,
change their repoURL to your remote before running the script, or set it
to __GIT_REPO_URL__: the script then rewrites those files and stops so you
can commit and push them, and applies root when re-run. Skip this and
root reads your fork while its children keep syncing from the original
repository.
Every Application autosyncs once it exists, with no manual Sync click (sync
policy: 05-argocd.md). The apps that need credentials
wait on the 1Password setup in 10-secrets.md; do that
before bootstrapping (see that doc for recovering if bootstrap came first).
Once root has picked up its children, confirm the sample app as in
06-sample-app-gitops.md.
For the monitoring stack, see 07-monitoring.md.
For local DNS and the wildcard cert (including the bunny.net API key
acme-wildcard-cert needs before it'll do anything, which comes from
1Password), see 08-dns-and-certs.md.
For hostname routing and shared authentication (Authentik), including its
one manual step (the first-login setup wizard), see
09-authentik.md.
Repository layout
mise.toml # pinned tool versions
renovate.json # this repository's Renovate config (docs/11-renovate.md)
.forgejo/workflows/ # CI: pre-commit hooks, bats tests, Helm render validation
config/
cluster.env.example # copy to cluster.env (gitignored) and edit
scripts/ # numbered bootstrap scripts, idempotent where possible
ci/ # checkers run by the hooks and CI, not part of bootstrap
grafana-dashboards/ # inputs for generate-grafana-dashboards.sh
node-red-flows/ # Node-RED flow sources, imported by hand (see its README)
manifests/
metallb/ # IPAddressPool + L2Advertisement (templated)
traefik/ # HelmChartConfig pinning Traefik's IP (templated)
argocd/ # the root "app of apps" Application (templated)
gitops/
argocd-apps/ # one Application per app — this is what root points at
apps/
crds/ # CRDs ArgoCD cannot apply, installed by hook Jobs
redis-sample/ # raw manifests for the sample app
renovate/ # Renovate's CronJob and global config
gatus/ # Gatus: service checks, status page, ServiceMonitor
longhorn/ # Longhorn: chart via Kustomize helmCharts + kube-linter annotations
longhorn-backup/ # Longhorn RecurringJobs: trim, backups, system backup
homepage/ # Homepage: the start page and its read-only RBAC
landing/ # nginx: the t.9b11.xyz placeholder page + exporter sidecar
node-red/ # Node-RED: flow editor, pinned palette, flows on a PVC
scanopy/ # Scanopy: network map — Postgres, server, host-network daemon
kavita/ # Kavita: ebooks and comics, with a copyparty uploader in its pod
audiobookshelf/ # Audiobookshelf: audiobooks, with copyparty for SFTP in its pod
metakavita/ # MetaKavita: fills in Kavita's series metadata
tailscale-config/ # Tailscale: the subnet router and its ProxyClass
acme-wildcard-cert/ # raw manifests: RBAC, PVC, CronJob for cert issuance
ingress-routes/ # TLSStore + per-service IngressRoutes + auth Middleware
argocd-config/ # ArgoCD itself: upstream install.yaml + its ConfigMaps
authentik-blueprints/ # ConfigMap of Authentik Providers/Applications
cluster-dns/ # coredns-custom override for in-cluster name resolution
external-secrets-config/ # ClusterSecretStore + ExternalSecrets from 1Password
grafana-dashboards/ # generated dashboard ConfigMaps
monitoring-alerts/ # PrometheusRule for this cluster's known failure modes
monitoring-targets/ # monitors for components not installed by a chart here
tests/ # bats suites, run by the bats hook and CI; each header states its scope
schemas/ # kubeconform schemas for CRDs the catalog lags on (generate-crd-schemas.py)
docs/ # per-topic write-ups, one per source guide, plus extras
Everything under gitops/apps/ is the path: of exactly one Application in
gitops/argocd-apps/.
Docs
- 01-installation.md — k3s master/worker setup
- 02-helm-arkade.md — Helm (and optionally Arkade)
- 03-networking.md — MetalLB pool, Traefik
- 04-storage.md — Longhorn vs. NFS, and Longhorn's backups
- 05-argocd.md — ArgoCD install, UI access, sync policy
- 06-sample-app-gitops.md — the Redis app, GitOps-style
- 07-monitoring.md — Prometheus, Grafana, Loki, Alloy
- 08-dns-and-certs.md — AdGuard Home, Traefik's pinned IP, wildcard cert via acme.sh
- 09-authentik.md — hostname routing, native OIDC where a service supports it, forward-auth where it does not
- 10-secrets.md — 1Password + External Secrets Operator: where every credential lives and how it reaches the cluster
- 11-renovate.md — Renovate: what it updates, when updates merge, the PRs that need a manual step
- 12-gatus-homepage.md — Gatus service checks, game-server monitoring, and the start page
- 13-node-red.md — Node-RED: flows on a volume, the pinned palette, and the Home Assistant connection
- 14-tailscale.md — Tailscale: the subnet router, the ACL policy it depends on, and split DNS
- 15-maintenance.md — taking the whole cluster down for physical work, and bringing it back
- 16-scanopy.md — Scanopy: a map of every VLAN from its own sweep and the UniFi console, its secrets, and the steps done in its UI
- 17-library.md — Kavita for ebooks and comics, its copyparty uploader with SFTP access, signing in through Authentik, and the OPDS feed; Audiobookshelf for audiobooks, with SFTP and its phone app; MetaKavita, which fills in Kavita's metadata
Linting
Tool versions are pinned in mise.toml; hooks are defined in
.pre-commit-config.yaml and run via prek
(a faster, Rust-based pre-commit-compatible runner — reads the same config
format, no Python venv bootstrap required):
mise install
prek run --all-files
What's wired up, and why, is .pre-commit-config.yaml itself: a hook
defined here has a name: saying what it checks, a hook taken from another
repository is described there, and where a hook needs explaining, the
comment above it says why it is there and what its files: pattern must
reach.
Install the git hooks with prek install. Hooks run at commit unless their
stages: says pre-push; those fetch charts or remote sources, too slow for
every commit. Both are optional — prek run --all-files works standalone,
and prek run --all-files --stage pre-push runs the push-stage hooks by
hand. CI's render job runs the same push-stage scripts.
Notes on secrets
config/cluster.env, config/k3s-token, and config/kubeconfig are all
gitignored. Nothing sensitive is meant to reach this repo's git history —
the only things that live in tracked files are cluster topology and
non-secret config (IPs, pool ranges, manifests).
License
No LICENSE file, deliberately — this is a personal homelab setup, not a project intended for reuse or redistribution.