-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support disk image in talosctl cluster create
Fixes: #2973 Can now supply disk image using `--disk-image-path` flag. May need to enable `--with-apply-config` if it's necessary to bootstrap nodes properly. Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
- Loading branch information
Showing
10 changed files
with
123 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package cluster | ||
|
||
import ( | ||
"context" | ||
"crypto/tls" | ||
"io" | ||
"time" | ||
|
||
"github.com/talos-systems/go-retry/retry" | ||
|
||
machineapi "github.com/talos-systems/talos/pkg/machinery/api/machine" | ||
"github.com/talos-systems/talos/pkg/machinery/client" | ||
"github.com/talos-systems/talos/pkg/provision" | ||
) | ||
|
||
// ApplyConfigClient client to apply config. | ||
type ApplyConfigClient struct { | ||
ClientProvider | ||
Info | ||
} | ||
|
||
// ApplyConfig on the node via the API using insecure mode. | ||
func (s *APIBoostrapper) ApplyConfig(ctx context.Context, nodes []provision.NodeRequest, out io.Writer) error { | ||
for _, node := range nodes { | ||
n := node | ||
|
||
configureNode := func() error { | ||
c, err := client.New(ctx, client.WithTLSConfig(&tls.Config{ | ||
InsecureSkipVerify: true, | ||
}), client.WithEndpoints(n.IP.String())) | ||
if err != nil { | ||
return retry.UnexpectedError(err) | ||
} | ||
|
||
cfgBytes, err := n.Config.Bytes() | ||
if err != nil { | ||
return retry.UnexpectedError(err) | ||
} | ||
|
||
_, err = c.ApplyConfiguration(ctx, &machineapi.ApplyConfigurationRequest{ | ||
Data: cfgBytes, | ||
}) | ||
if err != nil { | ||
return retry.ExpectedError(err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
if err := retry.Constant(2*time.Minute, retry.WithUnits(250*time.Millisecond), retry.WithJitter(50*time.Millisecond)).Retry(configureNode); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters