metropolis: add cluster domain config and metroctl param

This adds a --cluster parameter to metroctl and a cluster domain field
to the bootstrap configuration. It is not yet used anywhere, but later
the cluster domain will be used to identify the cluster.

The length of the cluster domain is limited to 80, to allow for
constructing subdomains. This limit could be increased later if needed,
but it cannot easily be decreased, so I chose a conservative value that
should be enough in most cases.

Change-Id: I627cca8eb1d92c4b06e4dfd6b6926a013e8f33ae
Reviewed-on: https://review.monogon.dev/c/monogon/+/3508
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/cmd_install.go b/metropolis/cli/metroctl/cmd_install.go
index fff13e9..c40c9ed 100644
--- a/metropolis/cli/metroctl/cmd_install.go
+++ b/metropolis/cli/metroctl/cmd_install.go
@@ -17,6 +17,7 @@
 
 	"source.monogon.dev/metropolis/cli/flagdefs"
 	"source.monogon.dev/metropolis/cli/metroctl/core"
+	common "source.monogon.dev/metropolis/node"
 	"source.monogon.dev/osbase/blkio"
 	"source.monogon.dev/osbase/fat32"
 )
@@ -44,6 +45,13 @@
 
 	var params *api.NodeParameters
 	if *bootstrap {
+		if flags.cluster == "" {
+			return nil, fmt.Errorf("when bootstrapping a cluster, the --cluster parameter is required")
+		}
+		if err := common.ValidateClusterDomain(flags.cluster); err != nil {
+			return nil, fmt.Errorf("invalid cluster domain: %w", err)
+		}
+
 		// TODO(lorenz): Have a key management story for this
 		priv, err := core.GetOrMakeOwnerKey(flags.configPath)
 		if err != nil {
@@ -55,6 +63,7 @@
 				ClusterBootstrap: &api.NodeParameters_ClusterBootstrap{
 					OwnerPublicKey: pub,
 					InitialClusterConfiguration: &cpb.ClusterConfiguration{
+						ClusterDomain:         flags.cluster,
 						StorageSecurityPolicy: *bootstrapStorageSecurityPolicy,
 						TpmMode:               *bootstrapTPMMode,
 					},