AstrionLabs logoASTRION_LABSarrow_back

lab notes · systems

Self-hosting on orion: a notes server, and the rest of the house.

Follow-up toBuilding orion. That note is the platform. This one is what we put on it.

Most of the lab stays private, reached by name over the home network or Tailscale. Joplin is the exception: phones and laptops sync notes through one public URL, and the laptop never opens a port.

Joplin Server 3.7.2Web editor 3.7.21Cloudflare TunnelCloudNativePGVictoriaMetricsGrafana 11.2

One notes sync · six hops · the laptop stays behind NAT

clientPhone / laptopJoplin app or browser
→
edgeCloudflareTLS for the public name
→
tunnelcloudflaredoutbound, its own tunnel
→
frontnginxjoplin-web
→
appJoplin Server:22300
→
dataPostgresexisting cluster
01

Access

door_openTwo doors, one machine

The platform note ends at Tailscale: *.orion.lab works from a phone on cellular once the mesh and the private CA are in place. That door is still how we reach Grafana, Portainer, and ClickHouse. It is the wrong door for a notes app.

Joplin on a phone wants a normal HTTPS URL. It will not install our private CA, and it cannot complete a Cloudflare Access login. So notes get their own public name, joplin.astrionlabs.com, on a Cloudflare Tunnel that only this service uses. The connector dials out. Nothing on the router is forwarded.

Core concept · private by default, public by exception

Dashboards and databases stay on the private namespace. A service is public only when a device that cannot join the mesh still has to reach it. Notes are that case. Signup on the public site is off, and there is no mailer.

02

The service

edit_noteJoplin, three processes

Three pods in their own namespace, plus a database on the Postgres we already had.

ProcessImageJob
cloudflaredcloudflare/cloudflaredHolds the tunnel. The public hostname is set in Cloudflare, not in git.
joplin-webjoplin-web:3.7.21nginx. /app is the editor. Everything else is proxied.
joplin-serverjoplin/server:3.7.2Sync API on port 22300. One process, 1 GiB, enough for a household.

The web image is not on a registry. It is built from Joplin's v3.7.21 tag on another machine, for the laptop's linux/amd64 CPU, then imported into k3s. The deployment's pull policy is Never: if the image isn't already on the node, the pod stays down. orion does not compile it.

Apps sync against Joplin Server at that same public URL. End-to-end encryption is turned on in the client after the first sync. It is not a server setting. The editor at /app is the same login, and it is not the admin page.

03

Naming

linkOne hostname, on purpose

Every other HTTP service on orion is <name>.orion.lab, because the wildcard DNS and the wildcard certificate already cover it. Joplin refuses that pattern. The server accepts only the host in APP_BASE_URL. A request with any other Host is a 404, "Invalid origin". There is no joplin.orion.lab ingress.

The editor has the same constraint: it has to be served from that host. Putting it on a second origin is rejected. So nginx on the tunnel's target does both jobs. /app/ is a static site with a fallback to its own index.html. Every other path is proxied to the server, and the original Host is forwarded unchanged.

Gotcha · the probe needs the public host

A readiness check against the pod IP fails the origin check even when the process is healthy. The probe sends Host: joplin.astrionlabs.com. Running is not the same as answering the name the app expects.

04

TLS, inside the cluster

cookieSecure cookies, on an HTTP hop

Visitors use HTTPS. Cloudflare terminates it and redirects plain HTTP. The tunnel's origin is HTTP to nginx, and nginx talks to Joplin Server over HTTP inside the cluster. The proxy does set X-Forwarded-Proto: https. Joplin ignores that header.

With COOKIES_SECURE=true, login dies with "Cannot send secure cookie over unencrypted connection", because the server only sees its own socket. The flag stays false. The browser still only speaks HTTPS to Cloudflare.

Core concept · the app and the edge disagree about the scheme

Terminating TLS at the edge is normal. It only works when the app believes the forwarded scheme. This one doesn't, so the cookie flag follows what the process sees, and the public name stays HTTPS at the edge.

05

Storage

databaseNo second database server

Joplin stores notes in Postgres. orion already runs one CloudNativePG cluster, a single instance, volume on the 1 TB disk. Joplin gets a database and a role on that cluster. Deleting the Joplin manifests does not drop the data: the database and the role both use a retain reclaim policy.

A second Postgres would have been a second volume, a second backup story, and more RAM on a 12 GB laptop. The operator already knew how to add a database.

06

The house

dnsWhat else is running

Same machine as the platform note: a 2017 IdeaPad, Ubuntu, k3s. Private names resolve only on the LAN and over Tailscale. Joplin is the public row.

ServiceNameWhat it does
Joplinjoplin.astrionlabs.comNotes sync, and the web editor at /app. The one public service.
Grafanagrafana.orion.labDashboards. VictoriaMetrics for metrics, ClickHouse for telemetry.
Portainerportainer.orion.labThe cluster UI.
CH-UIchui.orion.labA browser for ClickHouse.
ClickHouseclickhouse.orion.labColumnar store for logs and telemetry. Data on the 1 TB disk.
Postgresin-clusterCloudNativePG, one instance. Joplin's database lives here.
NATSin-clusterJetStream. The queue in front of ClickHouse.
VictoriaMetricsin-clusterPromQL metrics, 30-day retention. Scrapes the node, kube-state, Traefik, ClickHouse, Postgres, NATS, and cAdvisor.

VictoriaMetrics replaced a full Prometheus install. It scrapes node-exporter and kube-state-metrics, plus Traefik, ClickHouse, Postgres, NATS, and the kubelet's cAdvisor endpoint, and keeps 30 days on the big disk. Grafana is the only dashboard in front of that, at grafana.orion.lab, with ClickHouse as a second datasource for the telemetry SQL.

Where the platform note left off

k3s, CoreDNS, the private CA, Traefik, ClickHouse, NATS, and Tailscale are the floor. Joplin, Grafana, Portainer, CH-UI, CloudNativePG, and VictoriaMetrics are what that floor is holding up.

##

Reference

menu_bookNames from this note

Joplin Server
The sync API. Apps talk to it; it is not the editor.
APP_BASE_URL
The only hostname Joplin Server will accept. A second name is a 404.
Cloudflare Tunnel
An outbound connector. The laptop is not port-forwarded.
CloudNativePG
The Postgres operator. One cluster, many databases.
VictoriaMetrics
A single-binary Prometheus replacement. Grafana's metrics datasource.

Private lab, one public door

The platform is the same laptop as before. Joplin is the piece you can open without the mesh:joplin.astrionlabs.com.