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:
2026-11-18 11:40:25 +01:00
co-authored by Claude Sonnet 5.5
parent dd229895f4
commit 819df6d512
15 changed files with 431 additions and 1 deletions
+32
View File
@@ -7,6 +7,7 @@ import (
"io"
"log/slog"
"os"
"strings"
"testing"
"time"
@@ -406,3 +407,34 @@ func TestANodeWithoutRegionsFollowsTheFirstOneWhenChosen(t *testing.T) {
}
eventually(t, "the first region is followed and caught up", func() bool { return count(b) == 1 })
}
func TestAnnouncedAddressesReplaceTheLocalOnes(t *testing.T) {
const want = "/dns4/node.example.org/tcp/4001"
n := startNodeWith(t, nil, func(c *Config) { c.Announce = []string{want} }, "u1x")
addrs := n.Addrs()
if len(addrs) != 1 || !strings.HasPrefix(addrs[0], want+"/p2p/") {
t.Fatalf("a node behind a router announces only what it was told: %v", addrs)
}
}
func TestABadAnnounceAddressIsRefused(t *testing.T) {
dev, _ := identity.Enroll(mustRoot(t), time.Now().Add(-time.Hour), 90*24*time.Hour)
s, err := store.Open(":memory:", store.Options{})
if err != nil {
t.Fatal(err)
}
defer s.Close()
_, err = New(context.Background(), Config{Device: dev, Store: s, ListenAddrs: []string{"/ip4/127.0.0.1/tcp/0"}, Announce: []string{"not an address"}})
if err == nil || !strings.Contains(err.Error(), "announce address") {
t.Fatalf("err = %v", err)
}
}
func mustRoot(t *testing.T) *identity.Identity {
t.Helper()
root, _, err := identity.NewRoot()
if err != nil {
t.Fatal(err)
}
return root
}