Article · 4 min read · Home lab

Your own mesh server

Your [[mesh-network]] has a control server, Headscale, which hands out keys and addresses, and a relay for devices that can’t reach each other directly. Both run on one of your own servers with a public address: your mesh server. It’s also

Your kubespin: The mesh network has a control server, Headscale, which hands out keys and addresses, and a relay for devices that can’t reach each other directly. Both run on one of your own servers with a public address: your mesh server. It’s also your network’s front door, the first choice to serve your names (kubespin: Your own server in front).

kubespin is the control plane, never the data plane. It sets your mesh server up, writes its rules and reads its devices, all through that server’s agent. Your devices’ traffic never goes through kubespin, no other account shares your mesh server, and your devices keep reaching each other when kubespin is down.

What it needs

  • A server with a public address, active in kubespin. A small VPS is enough. A Plesk server is offered first, since it already holds names and certificates. Without Plesk, ports 80 and 443 on its public address must be free, and a small Caddy container handles HTTPS.
  • Port 3478/udp free, for the relay.
  • A domain connected on DNS › Domains (kubespin: Your own domains). The mesh server’s address is mesh.<your domain>, an A record kubespin keeps in your own DNS. It’s never a kubespin.io name.

What runs there

  • Headscale in a container, listening on the server’s own 127.0.0.1 only, with the relay beside it. Its database and keys stay on that server, in /var/lib/kubespin-mesh.
  • kubespin reaches it down the agent’s own connection, with an API key it keeps sealed. Nothing on the server accepts a connection from kubespin.

In kubespin

  1. Choose Mesh in the menu, then Mesh server. Until you move, it’s marked shared, and the map says your mesh runs on kubespin’s shared server.
  2. Pick the server under Server. The panel shows the address it will have, such as https://mesh.example.com.
  3. Choose Set up my mesh server. It takes a minute or two.
  4. Your servers then move over by themselves, and their old entries on the shared mesh are removed. Phones and laptops join again from Add device (kubespin: The mesh network).

To move it to another server later, pick that server and choose Move it to this server.

If something’s missing, the panel says what, for example that no domain is connected yet, that none of your servers has a public address, or that port 3478/udp is in use.

No server with a public address yet?

Use the shared server for now runs your mesh on kubespin’s shared mesh server until you have one. Its access rules keep your devices apart from every other account’s. Until your own mesh server is set up, the Mesh server panel also shows how much of your kubespin: The starter allowance kubespin is carrying for you.

A standby

With a second server that has a public address, kubespin keeps a standby of your mesh server on it, ready to take over if the first stops answering. See kubespin: The mesh server standby.

Command line

The kubespin command has no mesh commands yet. Use kubespin api, or a script with an API token:

bash
kubespin api GET /mesh/gateway

API

bash
curl -s -X POST https://kubespin.io/api/v1/mesh/gateway \
  -H "Authorization: Bearer $KUBESPIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"server_id": "'"$SERVER_ID"'"}'

It returns {"state": "setting-up", "server": "…"} and carries on in the background. Leave out server_id and kubespin picks the server.

GET /api/v1/mesh/gateway returns the state (setting-up, on or failed, with error), the server, its login_server address, the name it will have (or name_error), the choices of server, and the starter allowance in use.

[!permissions] Permissions Area: Servers

Step Needs Default roles
See where the mesh server runs View Admin, Developer, Operator, Viewer
Set it up or move it Manage Admin

API token: Read only to look; Read and change to set it up.