mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-25 16:41:12 +02:00
* refactor(init): Allow kubeadm init on controlplane This shifts the cluster formation from init(bootstrap) and join(control plane) to init(control plane). This makes use of the previously implemented initToken to provide a TTL for cluster initialization to take place and allows us to mostly treat all control plane nodes equal. This also sets up the path for us to handle master upgrades and not be concerned with odd behavior when upgrading the previously defined init node. To facilitate kubeadm init across all control plane nodes, we make use of the initToken to run `kubeadm init phase certs` command to generate any missing certificates once. All other control plane nodes will attempt to sync the necessary certs/files via all defined trustd endpoints and being the startup process. * feat(init): Add service runner context to PreFunc Signed-off-by: Brad Beam <brad.beam@talos-systems.com>
65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
/* 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 generate_test
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
"github.com/talos-systems/talos/pkg/userdata"
|
|
"github.com/talos-systems/talos/pkg/userdata/generate"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
var (
|
|
input *generate.Input
|
|
)
|
|
|
|
type GenerateSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func TestGenerateSuite(t *testing.T) {
|
|
suite.Run(t, new(GenerateSuite))
|
|
}
|
|
|
|
func (suite *GenerateSuite) SetupSuite() {
|
|
var err error
|
|
input, err = generate.NewInput("test", []string{"10.0.1.5", "10.0.1.6", "10.0.1.7"})
|
|
suite.Require().NoError(err)
|
|
}
|
|
|
|
func (suite *GenerateSuite) TestGenerateInitSuccess() {
|
|
input.IP = net.ParseIP("10.0.1.5")
|
|
dataString, err := generate.Userdata(generate.TypeInit, input)
|
|
suite.Require().NoError(err)
|
|
data := &userdata.UserData{}
|
|
err = yaml.Unmarshal([]byte(dataString), data)
|
|
suite.Require().NoError(err)
|
|
}
|
|
|
|
func (suite *GenerateSuite) TestGenerateControlPlaneSuccess() {
|
|
input.IP = net.ParseIP("10.0.1.6")
|
|
dataString, err := generate.Userdata(generate.TypeControlPlane, input)
|
|
suite.Require().NoError(err)
|
|
data := &userdata.UserData{}
|
|
err = yaml.Unmarshal([]byte(dataString), data)
|
|
suite.Require().NoError(err)
|
|
}
|
|
|
|
func (suite *GenerateSuite) TestGenerateWorkerSuccess() {
|
|
dataString, err := generate.Userdata(generate.TypeJoin, input)
|
|
suite.Require().NoError(err)
|
|
data := &userdata.UserData{}
|
|
err = yaml.Unmarshal([]byte(dataString), data)
|
|
suite.Require().NoError(err)
|
|
}
|
|
|
|
func (suite *GenerateSuite) TestGenerateTalosconfigSuccess() {
|
|
_, err := generate.Talosconfig(input)
|
|
suite.Require().NoError(err)
|
|
}
|