Article · 6 min read · Home lab
kubespin: The mesh network
One private network between all your devices: servers, boards, laptops and phones. Once it’s on, you can ssh or open VNC from one device to another by name, such as debian-laptop.mesh.internal, wherever each one is.
One private network between all your devices: servers, boards, laptops and phones. Once it’s on, you can ssh or open VNC from one device to another by name, such as debian-laptop.mesh.internal, wherever each one is.
How it works
- kubespin runs the control server, Headscale. It only hands out the keys, the addresses and the list of devices. Traffic goes straight between your devices, encrypted end to end with WireGuard, and kubespin never sees it.
- Where two devices can’t reach each other directly, traffic goes through an encrypted relay. The relay passes it on and can’t read it.
- Each device’s private key is made on the device and never leaves it.
- Your mesh is your account’s own. No other account’s devices can see or reach yours.
Devices join with Tailscale’s client, so phones and laptops use the Tailscale app.
Turn it on
- Choose Mesh in the menu, then Turn on.
- Choose Add device. Under Your servers, choose Join beside a server, or Join all.
Joining a server installs Tailscale’s client over SSH if it’s missing (about a minute), then joins with a key that works once and lasts 10 minutes. The server keeps its own DNS settings, and kubespin’s own connection to the agent is unchanged: the mesh sits beside it.
Before installing anything, the server checks it can reach the mesh’s control server. If it can’t, the join stops within seconds and the server’s row says why, for example that something else answered for the mesh’s address, or that it got no answer at all (a DNS or network problem).
Add a phone or laptop
Choose Add device, or + Add a phone or laptop on the map.
Laptop or desktop (Linux, macOS, Windows):
- Install Tailscale from tailscale.com/download.
- Make a key, then run the command the page shows. The key works once, for 10 minutes. On Windows, leave out
sudo.
Phone or tablet (iOS, Android):
- Install the Tailscale app.
- Point it at kubespin: on iOS, Settings › Tailscale › Alternate coordination server; on Android, the menu › Change server. Enter the address the page shows.
- Sign in from the app. It shows a link ending in
/register/…. Paste it into the page.
The device appears on the map.
The map
The Mesh page is a map of your devices, filling the page. Drag to move it, scroll or pinch to zoom, or use +, − and Fit.
- Each device is linked to every other. Links between devices that are online are solid; links to an offline device are dashed.
- A device that carries the others’ internet traffic (an exit node) has a dashed amber ring, and moving lines show traffic going through it to the internet.
- The map fits a phone, and stops moving for anyone who has reduced motion turned on.
Choose a device to see its details: its mesh address and name, online or when it was last seen, Open server for a server, and Leave the mesh (a server) or Remove from the mesh (a phone or laptop). Removing a device stops its key working at once.
Settings on the map lists every server, whether it’s on the mesh, joining, or couldn’t join and why, with Join or Leave, and every device. A number on Settings counts servers that couldn’t join.
On Servers, each server on the mesh is marked Mesh · 100.64.x.y, or “Mesh: joining…” or “Mesh: couldn’t join”. Its Overview shows its mesh address under Reached.
Reach a device by name
Each device’s name follows its name in kubespin, and ends in .mesh.internal, for example ssh adam@debian-laptop.mesh.internal. These names resolve only on devices on the mesh. They’re listed on DNS › Names as Mesh only (kubespin: DNS names and providers).
Deleting a server from kubespin removes it from the mesh.
Who can reach what
Only your own devices can reach each other. kubespin writes the access rules to Headscale, reads them back, and won’t turn the mesh on, make a key or add a device until they match. It checks them again every 10 minutes and puts them back if they’ve gone.
You can add rules in plain words, for example “Phones can reach servers on 22, 5900 and 443 only”.
In a team, members get the team’s mesh, limited by their role. Viewers see the devices but can’t connect.
Your home network from anywhere
A server can offer its home network to the mesh, so your phone can reach the printer at home, or act as an exit node for your traffic. Both are off until you turn them on, and the page says what each does first.
Command line
The kubespin command has no mesh commands yet. Use kubespin api, or a script with an API token:
kubespin api POST /mesh/servers/join-all
On a device on the mesh, tailscale status lists the others.
API
curl -s -X POST https://kubespin.io/api/v1/mesh/servers/$SERVER_ID/join \
-H "Authorization: Bearer $KUBESPIN_TOKEN"
The join carries on in the background. GET /api/v1/mesh returns whether the mesh is on, the login_server, the devices (each with its address, name, whether it’s online and when it was last seen) and the servers with their mesh state.
POST /api/v1/mesh/onturns it on.POST /api/v1/mesh/servers/join-allandPOST /api/v1/mesh/servers/{id}/leave.POST /api/v1/mesh/devices/keymakes a key for a laptop;POST /api/v1/mesh/devices/registerwith{"link": "…"}, the link from the phone’s app, adds a phone.DELETE /api/v1/mesh/devices/{device id}removes a device.
[!permissions] Permissions Area: Servers
Step Needs Default roles See the mesh View Admin, Developer, Operator, Viewer Turn it on, join or remove servers and devices Manage Admin API token: Read only to look; Read and change for the rest.
For whoever runs kubespin
The mesh is off until it’s set up: KUBESPIN_MESH=1, MESH_URL, a Headscale API key in MESH_API_KEY, and UDP port 3478 open for the relay. docs/INSTALL.md, step 9, has the steps and how to check accounts can’t see each other.