Kubernetes manifests for a public node, and --announce
k8s/base (kustomize): StatefulSet with a volume, p2p LoadBalancer for 4001 TCP+UDP, ClusterIP for the UI, optional ingress; k8s/overlays/nodeport for clusters without a load balancer. The pod waits for 'allmende init' so the recovery phrase never goes to a log. --announce makes a node that sits behind a router or in a container announce the address others can dial (e.g. /dns4/name/tcp/4001), so a bootstrap node behind a port forward works, and the DNS records it prints name the host. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
# Running a public node on Kubernetes
|
||||
|
||||
This runs one Allmende node as a **bootstrap node**: the address new nodes
|
||||
use to find the network (`_dnsaddr.allmende.stinnesbeck.com`). It serves the
|
||||
DHT and relays for nodes behind a NAT. It also works behind your home router.
|
||||
|
||||
```
|
||||
k8s/base/ namespace, StatefulSet (+1 Gi volume), Services, config
|
||||
k8s/base/ingress.yaml optional: the web UI on a public name (off by default)
|
||||
k8s/overlays/nodeport/ variant for a cluster without a load balancer
|
||||
```
|
||||
|
||||
## Does it work behind a router?
|
||||
|
||||
Yes, with a port forward. A bootstrap node must be dialable from the internet,
|
||||
so:
|
||||
|
||||
1. **Forward port 4001, TCP and UDP**, on the router to the cluster (the
|
||||
LoadBalancer address, or with the `nodeport` overlay a node's address on
|
||||
port 30401). UDP matters: it carries QUIC, which most nodes prefer.
|
||||
2. **Give the router's public IP a DNS name** (an A record, or dynamic DNS if
|
||||
your IP changes) and put it in `base/config.env` as `PUBLIC_HOST`.
|
||||
A node in a pod or behind a router cannot know its own public address, so
|
||||
it announces that name (`--announce`) instead. Because the name, not an IP,
|
||||
goes into the DNS records below, a changing IP only needs the A record
|
||||
updated, not the `_dnsaddr` records.
|
||||
3. If your provider puts you behind carrier-grade NAT (no real public IPv4),
|
||||
forwarding cannot work. Use a small VPS instead, or IPv6 if your network
|
||||
gives you a routable address.
|
||||
|
||||
## Setup
|
||||
|
||||
1. **Image.** Build it from the `Dockerfile` in the repository root, push it
|
||||
to a registry the cluster can pull from, and set `images:` in
|
||||
`base/kustomization.yaml`.
|
||||
```
|
||||
docker build -t registry.example.com/allmende:latest . && docker push registry.example.com/allmende:latest
|
||||
```
|
||||
2. **Name.** Edit `base/config.env` (`PUBLIC_HOST`, and `PUBLIC_PORT` if the
|
||||
router cannot forward 4001 to 4001).
|
||||
3. **Apply.**
|
||||
```
|
||||
kubectl apply -k k8s/base # with a LoadBalancer (MetalLB, kube-vip, ...)
|
||||
kubectl apply -k k8s/overlays/nodeport # or: NodePort 30401, no load balancer
|
||||
```
|
||||
The pod starts and waits: it has no identity yet.
|
||||
4. **Create the identity, once.** This shows the 12-word recovery phrase; it is
|
||||
done by hand so the phrase never lands in a log.
|
||||
```
|
||||
kubectl -n allmende exec -it allmende-0 -- allmende init
|
||||
```
|
||||
Write the words down. The node starts by itself a few seconds later. Keys
|
||||
and the database are on the volume (`data-allmende-0`): keep it, and back
|
||||
it up if you can; the phrase can recover the identity (`allmende recover`)
|
||||
but not the listings of other people.
|
||||
5. **Publish the DNS records.** The node prints them at start:
|
||||
```
|
||||
kubectl -n allmende logs allmende-0 | grep dnsaddr=
|
||||
```
|
||||
Add each line as a TXT record at `_dnsaddr.allmende.stinnesbeck.com` (the
|
||||
value is the whole `dnsaddr=...` text). Check:
|
||||
```
|
||||
dig +short TXT _dnsaddr.allmende.stinnesbeck.com
|
||||
```
|
||||
6. **Try it from outside your network** (a phone on mobile data, or a VPS):
|
||||
```
|
||||
allmende init && allmende run # no --bootstrap needed
|
||||
```
|
||||
Within a minute its status (`/api/v1/status`) should show a peer.
|
||||
|
||||
## Good to know
|
||||
|
||||
- **One replica only.** A second pod would be a second node with its own
|
||||
identity, not a copy.
|
||||
- **The sign-in link is in the log.** `allmende run` prints the owner sign-in
|
||||
link, token included, to the terminal, which in Kubernetes is the pod log.
|
||||
A bootstrap node does not need it; if your logs are shared, read the token
|
||||
from `/data/admin.token` yourself and rotate it by recovering the identity
|
||||
(`allmende recover`) if it was exposed.
|
||||
- **The web UI** is not published by default. For a look at it:
|
||||
`kubectl -n allmende port-forward svc/allmende-http 8080:8080`. To publish
|
||||
it, enable `ingress.yaml` in `base/kustomization.yaml` (read its note first:
|
||||
the same port serves the owner API).
|
||||
- **Regions.** A bootstrap node follows none. To make it also keep listings,
|
||||
open the UI through the port-forward, sign in and choose regions.
|
||||
- **More than one bootstrap node** on different networks makes the network
|
||||
independent of any single one. Run this on a second cluster or a VPS and add
|
||||
its records next to the first.
|
||||
- **Upgrades.** Build and push a new image tag, change `newTag`, apply again.
|
||||
The pod restarts; peers reconnect on their own.
|
||||
Reference in New Issue
Block a user