AstrionLabs logoASTRION_LABSarrow_back

lab notes · systems

Building orion: bare metal to a service you reach from your phone.

The whole story and every core concept behind it: a single machine turned into something that behaves like a production Kubernetes platform. Each layer below builds on the one before it, in the exact order it has to be built.

Ubuntu 26.04k3s v1.36Traefik v3.7CoreDNS · orion.labmkcert CATailscale

One HTTPS request · seven layers · every box is one you built

clientPhone / laptopon cellular
→
tunnelTailscaleWireGuard
→
routerorion subnet192.168.1.0/24
→
nameCoreDNS*.orion.lab
→
gatewayTraefikTLS :443
→
clusterk3s ServiceClusterIP
→
appPodthe container
01

The foundation

memoryOne machine, two disks

orion is a single physical computer running Ubuntu Server 26.04 LTS, and it's worth saying plainly what that computer is: a 2017 Lenovo IdeaPad laptop, Intel Core i5 (7th gen), 12 GB RAM, 4 cores. Not a rack server, not a NUC, just an old laptop that would otherwise be gathering dust. Everything in this write-up runs on that.

2017 IdeaPadCore i5 · 7th gen4 cores12 GB RAMSSD + 1 TB HDD

The one hardware fact that shapes every later decision is that it has two disks.

DiskSizeJob
sda · SSD112 GBOS, k3s, images (fast, small)
sdb · HDD1 TBAll database data (big, cheap, persistent)

Databases want lots of durable space, not necessarily fast space, so their data belongs on the 1 TB HDD at /data, never on the small OS disk. That rule is why every database points at /data.

Core concept · a server is a role, not a product

A seven-year-old laptop is proof of it. A "server" is any machine left on, given a fixed address, and configured to accept connections; the label is a job description, not a price tag. Everything else in this document is software, and software doesn't care that the metal is old.

02

Orchestration

deployed_codeKubernetes, the small edition

We don't run apps directly on the OS. We run them as containers and let Kubernetes decide where they run, restart them when they die, give them addresses, and wire them together. On orion that's k3s: full Kubernetes packed into a single lightweight binary on one node.

Container

An app plus everything it needs, sealed in an image. Runs the same anywhere.

Pod

The smallest unit Kubernetes schedules: containers that live and die together, with their own IP.

Control plane

The brain reconciling "what you asked for" against "what's running".

Declarative

You write YAML describing the end state and apply it. You never script the steps.

This is why the whole lab lives as text in a git repo and rebuilding is one command, not a runbook.

03

Persistence

databaseMaking data outlive the pod

Pods are disposable: delete one and its filesystem is gone. Kubernetes separates compute from storage: a PersistentVolume is real storage that exists on its own (a directory on the HDD); a PersistentVolumeClaim is a pod's request that binds to a matching volume, exclusively.

Static vs dynamic: we declare database volumes up front so their data lands exactly on the big disk (static); small state like Portainer's lets k3s auto-provision one (dynamic). Convenient, but it lands on the default disk, which is wrong for databases.

Core concept · capacity is a promise, not a fence

A volume's "200 GB" is bookkeeping for the scheduler; nothing physically stops a process writing more. Real retention comes from application-level TTLs that auto-expire old rows.

04

Naming

dnsA private namespace: orion.lab

Reaching services by IP:port is ugly and can't get a clean certificate. So we invented a private DNS namespace, orion.lab, that exists only inside the home network. Only CoreDNS, running on orion, answers for it.

# the wildcard resolves every name, even before it exists
dig +short whoami.orion.lab   → 192.168.1.17
dig +short grafana.orion.lab  → 192.168.1.17

The wildcard (*.orion.lab) is the quiet superpower: every future service already has a working name with zero DNS work.

Gotcha · the NXDOMAIN pool trap

Listing a public resolver as a "backup" DNS doesn't give redundancy: the OS treats DNS servers as a pool, and a "no such host" for orion.lab from the public one is a valid answer, so resolution breaks intermittently. A per-domain resolver avoids it: orion down means only orion.lab stops, the internet is untouched.

05

Trust

encryptedBecoming your own Certificate Authority

We want the padlock: real HTTPS, no warnings. But Let's Encrypt won't issue a certificate for orion.lab, because it only vouches for domains you publicly own. So we do what the internet does internally: run our own Certificate Authority with mkcert.

Browsers don't trust individual certificates; they trust Certificate Authorities, and anything a trusted CA signs. Install the CA's public root into a device once, and it trusts every certificate that CA signs, present and future. One wildcard certificate for *.orion.lab then covers every service.

Core concept · identity vs direction

DNS and TLS are independent. DNS answers "what address is this name?"; TLS answers "is the server really who it claims to be?" A working name with an untrusted cert still shows a warning, exactly what a new device without the root CA sees.

06

The front door

hubTraefik: one gateway, many services

One reverse proxy, Traefik (bundled with k3s), is the single front door on ports 80/443. It reads the Host header and routes to the right service, terminates TLS with the wildcard cert, and load-balances across pods. Adding a service is the same recipe every time, with zero DNS or certificate work:

# the entire recipe for a new HTTPS service
1. Deploy the app  (Deployment + Service)
2. Copy the TLS secret into its namespace
3. Add an Ingress:  host <name>.orion.lab → service:port
4. apply

The exception · HTTP only

Ingress routes on the Host header, which only exists in HTTP. Databases speaking binary protocols get a NodePort or TCP router instead. This is about protocol, not "stateful vs stateless," a common misconception.

07

The data engine

monitoringClickHouse, built for telemetry

The lab's purpose is swallowing logs, metrics, and traces from every device in the house. ClickHouse is a columnar database built for exactly that: stores each column separately, compresses ~10×, scans billions of rows in milliseconds. We deployed it by hand (raw manifests, official image, no operator) so every concept stayed visible.

The one operational fact: every insert writes a new immutable part. One insert of 10,000 rows is one healthy part; ten thousand single-row inserts is ten thousand parts and a stall. The fix is to batch, which is the entire reason the pipeline in the next section exists.

Gotcha · the dashboard showed "no logs"

The data was perfect; the query never ran. The tool sent time filters as ISO-8601 with a trailing Z, which ClickHouse's WHERE-clause parser rejects. Found by reading ClickHouse's own system.query_log: the failing query was right there. Lesson: make the system testify, don't guess.

08

The design

account_treeNever insert directly

Because tiny inserts kill ClickHouse, nothing writes to it directly. A buffering, validating pipeline sits in front and solves several problems at once:

producersservices / IoTemit events
→
queueNATSJetStream
→
aggregatorVectorVRL + batch
→
sinkClickHousefat batches
  • Batching: buffer thousands of events, insert one part. The "too many parts" problem, solved at the right layer.
  • Validation: coerce types and fill defaults, so a device sending a string never poisons an integer column.
  • Backpressure: a disk buffer means if ClickHouse is down, Vector spools to disk; nothing is lost.
  • Dead-letter: events that fail validation route to a table instead of vanishing.

Why NATS, not Kafka? Kafka is a heavyweight log, overkill for a work queue. NATS JetStream is a ~20 MB binary with durable, at-least-once delivery, and Vector speaks it natively on both ends.

09

Anywhere access

vpn_lockThe same URL, from a phone on cellular

orion.lab only works on the home LAN. Tailscale closes the gap with an encrypted mesh where every device gets a stable address and can reach every other, anywhere. Three pieces bridge the mesh to the home network:

PieceJob
Subnet routerorion tells the mesh "reach the whole LAN through me"
IP forwardingflips orion from host to router so it relays packets
Split DNSremote devices resolve *.orion.lab via CoreDNS

How we proved it

From the phone on cellular, hitting the raw IP returned a Traefik 404, meaning the packet crossed the tunnel and reached Traefik. The tunnel's byte counters jumped from idle to active the instant it connected: packet-level proof. Adding the split-DNS entry closed the last gap, and the service loaded by name over cellular.

10

The meta-skill

bug_reportHow we actually debug this

Every problem here was solved the same way: ask the system what it sees, don't guess. The reading order rarely changes: symptom, the platform's reason, the app's reason, then prove the last mile:

kubectl get pods                 # 1. symptom: the pod's state
kubectl describe pod <pod>        # 2. Kubernetes' reason (events)
kubectl logs <pod>                # 3. the app's reason
kubectl exec <pod> -- <probe>     # 4. does it actually answer?

Core concept · Running is not the same as working

A pod being Running only means the process started. Whether the service answers is a separate question; always prove the last mile with a real request, never infer it from a green status.

##

Reference

menu_bookThe vocabulary, in one place

k3s
Lightweight single-binary Kubernetes, the orchestrator.
Pod
Smallest deployable unit; one or more containers with a shared IP.
PV / PVC
A real piece of storage / a pod's claim on it. They bind exclusively.
CoreDNS
The DNS server answering for the private orion.lab namespace.
Wildcard
*.orion.lab, one rule/cert covering every current and future name.
CA
Certificate Authority, the entity whose signature browsers trust.
mkcert
Tool that makes you a private CA for a local/private domain.
Traefik
The reverse proxy: routing + TLS termination + load balancing.
Ingress
A rule mapping a hostname to an internal service.
NodePort
Exposing a non-HTTP service on a fixed high port on the node.
MergeTree
ClickHouse's table engine; each insert writes an immutable part.
Keeper
ClickHouse's consensus service for replication metadata.
Vector
The aggregator that batches, validates, and buffers before ClickHouse.
NATS
Lightweight durable message queue feeding Vector.
Tailscale
WireGuard mesh VPN giving every device a stable private address.
Subnet router
A mesh node that relays traffic to a whole LAN behind it.
Split DNS
"For this domain, use this nameserver": resolves orion.lab remotely.

Built, broken, and rebuilt in a home lab

Ubuntu → k3s → storage → DNS → TLS → Traefik → ClickHouse → pipeline → Tailscale. Every concept above is a piece you can now explain, because it was built by hand. What landed on that floor since, including the public Joplin notes server, isthe follow-up.