m/node/allocs: split new package off m/node

The metropolis/node package contains various unrelated things. One of
these things are node-wide allocations of identifiers.
These are moved here to the new metropolis/node/allocs package.
Additionally, the constants are renamed to move the type of identifier
in front.

Change-Id: Ibc841ca64d4450a7054463e6d2d44753a118e07a
Reviewed-on: https://review.monogon.dev/c/monogon/+/4566
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/test/launch/BUILD.bazel b/metropolis/test/launch/BUILD.bazel
index b2530c5..f93cda8 100644
--- a/metropolis/test/launch/BUILD.bazel
+++ b/metropolis/test/launch/BUILD.bazel
@@ -48,6 +48,7 @@
         "//metropolis/cli/metroctl/core",
         "//metropolis/installer/install",
         "//metropolis/node",
+        "//metropolis/node/allocs",
         "//metropolis/node/core/curator/proto/api",
         "//metropolis/node/core/rpc",
         "//metropolis/node/core/rpc/resolver",
diff --git a/metropolis/test/launch/cli/launch-cluster/BUILD.bazel b/metropolis/test/launch/cli/launch-cluster/BUILD.bazel
index 339ea4c..0e9795b 100644
--- a/metropolis/test/launch/cli/launch-cluster/BUILD.bazel
+++ b/metropolis/test/launch/cli/launch-cluster/BUILD.bazel
@@ -14,7 +14,7 @@
     deps = [
         "//metropolis/cli/flagdefs",
         "//metropolis/cli/metroctl/core",
-        "//metropolis/node",
+        "//metropolis/node/allocs",
         "//metropolis/proto/common",
         "//metropolis/test/launch",
         "@io_bazel_rules_go//go/runfiles",
diff --git a/metropolis/test/launch/cli/launch-cluster/main.go b/metropolis/test/launch/cli/launch-cluster/main.go
index 1aec556..e94f0cf 100644
--- a/metropolis/test/launch/cli/launch-cluster/main.go
+++ b/metropolis/test/launch/cli/launch-cluster/main.go
@@ -20,7 +20,7 @@
 
 	"source.monogon.dev/metropolis/cli/flagdefs"
 	metroctl "source.monogon.dev/metropolis/cli/metroctl/core"
-	"source.monogon.dev/metropolis/node"
+	"source.monogon.dev/metropolis/node/allocs"
 	cpb "source.monogon.dev/metropolis/proto/common"
 	mlaunch "source.monogon.dev/metropolis/test/launch"
 )
@@ -183,7 +183,7 @@
 	apiserver := cl.Nodes[cl.NodeIDs[0]].ManagementAddress
 	// Wait for the API server to start listening.
 	for {
-		conn, err := cl.DialNode(ctx, net.JoinHostPort(apiserver, node.KubernetesAPIWrappedPort.PortString()))
+		conn, err := cl.DialNode(ctx, net.JoinHostPort(apiserver, allocs.PortKubernetesAPIWrapped.PortString()))
 		if err == nil {
 			conn.Close()
 			break
diff --git a/metropolis/test/launch/cluster.go b/metropolis/test/launch/cluster.go
index c77a101..c6711c8 100644
--- a/metropolis/test/launch/cluster.go
+++ b/metropolis/test/launch/cluster.go
@@ -41,6 +41,7 @@
 	"k8s.io/client-go/rest"
 	"k8s.io/utils/ptr"
 
+	"source.monogon.dev/metropolis/node/allocs"
 	ipb "source.monogon.dev/metropolis/node/core/curator/proto/api"
 	apb "source.monogon.dev/metropolis/proto/api"
 	cpb "source.monogon.dev/metropolis/proto/common"
@@ -141,17 +142,17 @@
 }
 
 // NodePorts is the list of ports a fully operational Metropolis node listens on
-var NodePorts = []node.Port{
-	node.ConsensusPort,
+var NodePorts = []allocs.Port{
+	allocs.PortConsensus,
 
-	node.CuratorServicePort,
-	node.DebugServicePort,
+	allocs.PortCuratorService,
+	allocs.PortDebugService,
 
-	node.KubernetesAPIPort,
-	node.KubernetesAPIWrappedPort,
-	node.CuratorServicePort,
-	node.DebuggerPort,
-	node.MetricsPort,
+	allocs.PortKubernetesAPI,
+	allocs.PortKubernetesAPIWrapped,
+	allocs.PortCuratorService,
+	allocs.PortDebugger,
+	allocs.PortMetrics,
 }
 
 // setupRuntime creates the node's QEMU runtime directory, together with all
@@ -579,10 +580,10 @@
 // ClusterPorts contains all ports handled by Nanoswitch.
 var ClusterPorts = []uint16{
 	// Forwarded to the first node.
-	uint16(node.CuratorServicePort),
-	uint16(node.DebugServicePort),
-	uint16(node.KubernetesAPIPort),
-	uint16(node.KubernetesAPIWrappedPort),
+	uint16(allocs.PortCuratorService),
+	uint16(allocs.PortDebugService),
+	uint16(allocs.PortKubernetesAPI),
+	uint16(allocs.PortKubernetesAPIWrapped),
 
 	// SOCKS proxy to the switch network
 	SOCKSPort,
@@ -694,7 +695,7 @@
 // information as NodeInCluster.
 func firstConnection(ctx context.Context, socksDialer proxy.Dialer) (*tls.Certificate, *NodeInCluster, error) {
 	// Dial external service.
-	remote := fmt.Sprintf("10.1.0.2:%s", node.CuratorServicePort.PortString())
+	remote := fmt.Sprintf("10.1.0.2:%s", allocs.PortCuratorService.PortString())
 	initCreds, err := rpc.NewEphemeralCredentials(InsecurePrivateKey, rpc.WantInsecure())
 	if err != nil {
 		return nil, nil, fmt.Errorf("NewEphemeralCredentials: %w", err)
@@ -1320,7 +1321,7 @@
 		panic(err)
 	}
 
-	host := net.JoinHostPort(c.NodeIDs[0], node.KubernetesAPIWrappedPort.PortString())
+	host := net.JoinHostPort(c.NodeIDs[0], allocs.PortKubernetesAPIWrapped.PortString())
 	clientConfig := rest.Config{
 		Host: host,
 		TLSClientConfig: rest.TLSClientConfig{