Skip to content

Commit

Permalink
feat: add partial config support to talosctl cluster create
Browse files Browse the repository at this point in the history
Allow passing a partial config to the machines using the `--input-dir` flag of `talosctl cluster create`.
With this change, it is not required to have talosconfig inside the input directory, neither for the configuration documents to contain a `v1alpha1` config document. They can solely contain maintenance config, e.g., `KmsgLogConfig`.

This is useful for testing scenarios such as partial machine configs being provided via cloud user data.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
  • Loading branch information
utkuozdemir committed Feb 20, 2024
1 parent 66f3ffd commit 5f46aab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/talosctl/cmd/mgmt/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,17 @@ func create(ctx context.Context, flags *pflag.FlagSet) error {
return err
}

bundleTalosconfig := configBundle.TalosConfig()
if bundleTalosconfig == nil {
if clusterWait {
return errors.New("no talosconfig in the config bundle: cannot wait for cluster")
}

if applyConfigEnabled {
return errors.New("no talosconfig in the config bundle: cannot apply config")
}
}

if skipInjectingConfig {
types := []machine.Type{machine.TypeControlPlane, machine.TypeWorker}

Expand Down Expand Up @@ -827,8 +838,13 @@ func create(ctx context.Context, flags *pflag.FlagSet) error {
return err
}

// No talosconfig in the bundle - skip the operations below
if bundleTalosconfig == nil {
return nil
}

// Create and save the talosctl configuration file.
if err = saveConfig(configBundle.TalosConfig()); err != nil {
if err = saveConfig(bundleTalosconfig); err != nil {
return err
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/provision/providers/qemu/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ func (p *provisioner) createNode(state *vm.State, clusterReq provision.ClusterRe
if !nodeReq.SkipInjectingConfig {
cmdline.Append("talos.config", "{TALOS_CONFIG_URL}") // to be patched by launcher

fmt.Printf("######## NODEREQ.CONFIG: %v\n", nodeReq.Config)

nodeConfig, err = nodeReq.Config.EncodeString()
if err != nil {
return provision.NodeInfo{}, err
Expand Down

0 comments on commit 5f46aab

Please sign in to comment.