mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-24 16:11:11 +02:00
chore: rename v1 node configs to v1alpha1
This PR moves to using v1alpha1 as the inital node config version, so we can graduate these configs a little more cleanly later on. Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
This commit is contained in:
parent
be4f7e1e6a
commit
aed8c06730
@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/talos-systems/talos/cmd/osctl/cmd/cluster/pkg/node"
|
"github.com/talos-systems/talos/cmd/osctl/cmd/cluster/pkg/node"
|
||||||
"github.com/talos-systems/talos/cmd/osctl/pkg/client/config"
|
"github.com/talos-systems/talos/cmd/osctl/pkg/client/config"
|
||||||
"github.com/talos-systems/talos/cmd/osctl/pkg/helpers"
|
"github.com/talos-systems/talos/cmd/osctl/pkg/helpers"
|
||||||
"github.com/talos-systems/talos/pkg/userdata/v1/generate"
|
"github.com/talos-systems/talos/pkg/userdata/v1alpha1/generate"
|
||||||
"github.com/talos-systems/talos/pkg/version"
|
"github.com/talos-systems/talos/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/talos-systems/talos/pkg/userdata/v1/generate"
|
"github.com/talos-systems/talos/pkg/userdata/v1alpha1/generate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request represents the set of options available for configuring a node.
|
// Request represents the set of options available for configuring a node.
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
udv0 "github.com/talos-systems/talos/pkg/userdata"
|
udv0 "github.com/talos-systems/talos/pkg/userdata"
|
||||||
udgenv0 "github.com/talos-systems/talos/pkg/userdata/generate"
|
udgenv0 "github.com/talos-systems/talos/pkg/userdata/generate"
|
||||||
"github.com/talos-systems/talos/pkg/userdata/translate"
|
"github.com/talos-systems/talos/pkg/userdata/translate"
|
||||||
udgenv1 "github.com/talos-systems/talos/pkg/userdata/v1/generate"
|
udgenv1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1/generate"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@ -135,8 +135,8 @@ var configGenerateCmd = &cobra.Command{
|
|||||||
switch genVersion {
|
switch genVersion {
|
||||||
case "v0":
|
case "v0":
|
||||||
genV0Userdata(args)
|
genV0Userdata(args)
|
||||||
case "v1":
|
case "v1alpha1":
|
||||||
genV1Userdata(args)
|
genV1Alpha1Userdata(args)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -205,8 +205,8 @@ func writeV0Userdata(input *udgenv0.Input, t udgenv0.Type, name string) (err err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func genV1Userdata(args []string) {
|
func genV1Alpha1Userdata(args []string) {
|
||||||
input, err := udgenv1.NewInput(args[0], strings.Split(args[1], ","))
|
input, err := udgenv1alpha1.NewInput(args[0], strings.Split(args[1], ","))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helpers.Fatalf("failed to generate PKI and tokens: %v", err)
|
helpers.Fatalf("failed to generate PKI and tokens: %v", err)
|
||||||
}
|
}
|
||||||
@ -218,29 +218,29 @@ func genV1Userdata(args []string) {
|
|||||||
helpers.Fatalf("failed to fetch current working dir: %v", err)
|
helpers.Fatalf("failed to fetch current working dir: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var udType udgenv1.Type
|
var udType udgenv1alpha1.Type
|
||||||
for idx, master := range strings.Split(args[1], ",") {
|
for idx, master := range strings.Split(args[1], ",") {
|
||||||
input.Index = idx
|
input.Index = idx
|
||||||
input.IP = net.ParseIP(master)
|
input.IP = net.ParseIP(master)
|
||||||
if input.Index == 0 {
|
if input.Index == 0 {
|
||||||
udType = udgenv1.TypeInit
|
udType = udgenv1alpha1.TypeInit
|
||||||
} else {
|
} else {
|
||||||
udType = udgenv1.TypeControlPlane
|
udType = udgenv1alpha1.TypeControlPlane
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = writeV1Userdata(input, udType, "master-"+strconv.Itoa(idx+1)); err != nil {
|
if err = writeV1Alpha1Userdata(input, udType, "master-"+strconv.Itoa(idx+1)); err != nil {
|
||||||
helpers.Fatalf("failed to generate userdata for %s: %v", "master-"+strconv.Itoa(idx+1), err)
|
helpers.Fatalf("failed to generate userdata for %s: %v", "master-"+strconv.Itoa(idx+1), err)
|
||||||
}
|
}
|
||||||
fmt.Println("created file", workingDir+"/master-"+strconv.Itoa(idx+1)+".yaml")
|
fmt.Println("created file", workingDir+"/master-"+strconv.Itoa(idx+1)+".yaml")
|
||||||
}
|
}
|
||||||
input.IP = nil
|
input.IP = nil
|
||||||
|
|
||||||
if err = writeV1Userdata(input, udgenv1.TypeJoin, "worker"); err != nil {
|
if err = writeV1Alpha1Userdata(input, udgenv1alpha1.TypeJoin, "worker"); err != nil {
|
||||||
helpers.Fatalf("failed to generate userdata for %s: %v", "worker", err)
|
helpers.Fatalf("failed to generate userdata for %s: %v", "worker", err)
|
||||||
}
|
}
|
||||||
fmt.Println("created file", workingDir+"/worker.yaml")
|
fmt.Println("created file", workingDir+"/worker.yaml")
|
||||||
|
|
||||||
data, err := udgenv1.Talosconfig(input)
|
data, err := udgenv1alpha1.Talosconfig(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helpers.Fatalf("failed to generate talosconfig: %v", err)
|
helpers.Fatalf("failed to generate talosconfig: %v", err)
|
||||||
}
|
}
|
||||||
@ -250,14 +250,14 @@ func genV1Userdata(args []string) {
|
|||||||
fmt.Println("created file", workingDir+"/talosconfig")
|
fmt.Println("created file", workingDir+"/talosconfig")
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeV1Userdata(input *udgenv1.Input, t udgenv1.Type, name string) (err error) {
|
func writeV1Alpha1Userdata(input *udgenv1alpha1.Input, t udgenv1alpha1.Type, name string) (err error) {
|
||||||
var data string
|
var data string
|
||||||
data, err = udgenv1.Userdata(t, input)
|
data, err = udgenv1alpha1.Userdata(t, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
trans, err := translate.NewTranslator("v1", data)
|
trans, err := translate.NewTranslator("v1alpha1", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func (c *Container) UserData() (data *userdata.UserData, err error) {
|
|||||||
if decoded, err = base64.StdEncoding.DecodeString(s); err != nil {
|
if decoded, err = base64.StdEncoding.DecodeString(s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
trans, err := translate.NewTranslator("v1", string(decoded))
|
trans, err := translate.NewTranslator("v1alpha1", string(decoded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func (suite *downloadSuite) TestV0Download() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint: dupl
|
// nolint: dupl
|
||||||
func (suite *downloadSuite) TestV1Download() {
|
func (suite *downloadSuite) TestV1Alpha1Download() {
|
||||||
// Disable logging for test
|
// Disable logging for test
|
||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(ioutil.Discard)
|
||||||
ts := testUDServer()
|
ts := testUDServer()
|
||||||
@ -57,14 +57,14 @@ func (suite *downloadSuite) TestV1Download() {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
_, err = Download(ts.URL, WithMaxWait(0.1), WithHeaders(map[string]string{"configVersion": "v1"}))
|
_, err = Download(ts.URL, WithMaxWait(0.1), WithHeaders(map[string]string{"configVersion": "v1alpha1"}))
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
_, err = Download(
|
_, err = Download(
|
||||||
ts.URL,
|
ts.URL,
|
||||||
WithFormat(b64),
|
WithFormat(b64),
|
||||||
WithRetries(1),
|
WithRetries(1),
|
||||||
WithHeaders(map[string]string{"Metadata": "true", "format": b64, "configVersion": "v1"}),
|
WithHeaders(map[string]string{"Metadata": "true", "format": b64, "configVersion": "v1alpha1"}),
|
||||||
)
|
)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
log.SetOutput(os.Stderr)
|
log.SetOutput(os.Stderr)
|
||||||
@ -74,8 +74,8 @@ func testUDServer() *httptest.Server {
|
|||||||
var count int
|
var count int
|
||||||
|
|
||||||
testMap := map[string]string{
|
testMap := map[string]string{
|
||||||
"v0": testV0Config,
|
"v0": testV0Config,
|
||||||
"v1": testV1Config,
|
"v1alpha1": testV1Alpha1Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -98,7 +98,7 @@ func testUDServer() *httptest.Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint: lll
|
// nolint: lll
|
||||||
const testV1Config = `version: v1
|
const testV1Alpha1Config = `version: v1alpha1
|
||||||
machine:
|
machine:
|
||||||
type: init
|
type: init
|
||||||
token: 57dn7x.k5jc6dum97cotlqb
|
token: 57dn7x.k5jc6dum97cotlqb
|
||||||
|
@ -18,8 +18,8 @@ type Translator interface {
|
|||||||
// NewTranslator returns an instance of the translator depending on version
|
// NewTranslator returns an instance of the translator depending on version
|
||||||
func NewTranslator(apiVersion string, nodeConfig string) (Translator, error) {
|
func NewTranslator(apiVersion string, nodeConfig string) (Translator, error) {
|
||||||
switch apiVersion {
|
switch apiVersion {
|
||||||
case "v1":
|
case "v1alpha1":
|
||||||
return &V1Translator{nodeConfig: nodeConfig}, nil
|
return &V1Alpha1Translator{nodeConfig: nodeConfig}, nil
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("unknown translator")
|
return nil, errors.New("unknown translator")
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,19 @@ func TestTranslatorSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *translatorSuite) TestTranslation() {
|
func (suite *translatorSuite) TestTranslation() {
|
||||||
tv1, err := NewTranslator("v1", testV1Config)
|
tv1a1, err := NewTranslator("v1alpha1", testV1Alpha1Config)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
ud, err := tv1.Translate()
|
ud, err := tv1a1.Translate()
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
suite.Assert().Equal(string(ud.Version), "v1")
|
suite.Assert().Equal(string(ud.Version), "v1alpha1")
|
||||||
err = ud.Validate()
|
err = ud.Validate()
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: lll
|
// nolint: lll
|
||||||
const testV1Config = `version: v1
|
const testV1Alpha1Config = `version: v1alpha1
|
||||||
machine:
|
machine:
|
||||||
type: init
|
type: init
|
||||||
token: 57dn7x.k5jc6dum97cotlqb
|
token: 57dn7x.k5jc6dum97cotlqb
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/talos-systems/talos/pkg/constants"
|
"github.com/talos-systems/talos/pkg/constants"
|
||||||
"github.com/talos-systems/talos/pkg/crypto/x509"
|
"github.com/talos-systems/talos/pkg/crypto/x509"
|
||||||
"github.com/talos-systems/talos/pkg/userdata"
|
"github.com/talos-systems/talos/pkg/userdata"
|
||||||
v1 "github.com/talos-systems/talos/pkg/userdata/v1"
|
v1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1"
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
kubeproxyconfig "k8s.io/kube-proxy/config/v1alpha1"
|
kubeproxyconfig "k8s.io/kube-proxy/config/v1alpha1"
|
||||||
@ -20,23 +20,23 @@ import (
|
|||||||
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// V1Translator holds info about a v1 machine config translation layer
|
// V1Alpha1Translator holds info about a v1alpha1 machine config translation layer
|
||||||
type V1Translator struct {
|
type V1Alpha1Translator struct {
|
||||||
nodeConfig string
|
nodeConfig string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate takes a v1 NodeConfig and translates it to a UserData struct
|
// Translate takes a v1 NodeConfig and translates it to a UserData struct
|
||||||
func (tv1 *V1Translator) Translate() (*userdata.UserData, error) {
|
func (tv1a1 *V1Alpha1Translator) Translate() (*userdata.UserData, error) {
|
||||||
nc := &v1.NodeConfig{}
|
nc := &v1alpha1.NodeConfig{}
|
||||||
|
|
||||||
err := yaml.Unmarshal([]byte(tv1.nodeConfig), nc)
|
err := yaml.Unmarshal([]byte(tv1a1.nodeConfig), nc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lay down the absolute minimum for all node types
|
// Lay down the absolute minimum for all node types
|
||||||
ud := &userdata.UserData{
|
ud := &userdata.UserData{
|
||||||
Version: "v1",
|
Version: "v1alpha1",
|
||||||
Security: &userdata.Security{},
|
Security: &userdata.Security{},
|
||||||
Services: &userdata.Services{
|
Services: &userdata.Services{
|
||||||
Init: &userdata.Init{
|
Init: &userdata.Init{
|
||||||
@ -51,32 +51,32 @@ func (tv1 *V1Translator) Translate() (*userdata.UserData, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if nc.Machine.Network != nil {
|
if nc.Machine.Network != nil {
|
||||||
translateV1Network(nc, ud)
|
translateV1Alpha1Network(nc, ud)
|
||||||
}
|
}
|
||||||
if nc.Machine.Install != nil {
|
if nc.Machine.Install != nil {
|
||||||
translateV1Install(nc, ud)
|
translateV1Alpha1Install(nc, ud)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch nc.Machine.Type {
|
switch nc.Machine.Type {
|
||||||
case "init":
|
case "init":
|
||||||
err = translateV1Init(nc, ud)
|
err = translateV1Alpha1Init(nc, ud)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
case "controlplane":
|
case "controlplane":
|
||||||
err = translateV1ControlPlane(nc, ud)
|
err = translateV1Alpha1ControlPlane(nc, ud)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
case "worker":
|
case "worker":
|
||||||
translateV1Worker(nc, ud)
|
translateV1Alpha1Worker(nc, ud)
|
||||||
}
|
}
|
||||||
return ud, nil
|
return ud, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func translateV1Network(nc *v1.NodeConfig, ud *userdata.UserData) {
|
func translateV1Alpha1Network(nc *v1alpha1.NodeConfig, ud *userdata.UserData) {
|
||||||
if ud.Networking == nil {
|
if ud.Networking == nil {
|
||||||
ud.Networking = &userdata.Networking{}
|
ud.Networking = &userdata.Networking{}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ func translateV1Network(nc *v1.NodeConfig, ud *userdata.UserData) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func translateV1Install(nc *v1.NodeConfig, ud *userdata.UserData) {
|
func translateV1Alpha1Install(nc *v1alpha1.NodeConfig, ud *userdata.UserData) {
|
||||||
|
|
||||||
ud.Install = &userdata.Install{
|
ud.Install = &userdata.Install{
|
||||||
Disk: nc.Machine.Install.Disk,
|
Disk: nc.Machine.Install.Disk,
|
||||||
@ -149,7 +149,7 @@ func translateV1Install(nc *v1.NodeConfig, ud *userdata.UserData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func translateV1Init(nc *v1.NodeConfig, ud *userdata.UserData) error {
|
func translateV1Alpha1Init(nc *v1alpha1.NodeConfig, ud *userdata.UserData) error {
|
||||||
// Convert and decode certs back to byte slices
|
// Convert and decode certs back to byte slices
|
||||||
osCert, err := base64.StdEncoding.DecodeString(nc.Machine.CA.Crt)
|
osCert, err := base64.StdEncoding.DecodeString(nc.Machine.CA.Crt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -268,7 +268,7 @@ func translateV1Init(nc *v1.NodeConfig, ud *userdata.UserData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func translateV1ControlPlane(nc *v1.NodeConfig, ud *userdata.UserData) error {
|
func translateV1Alpha1ControlPlane(nc *v1alpha1.NodeConfig, ud *userdata.UserData) error {
|
||||||
// Convert and decode certs back to byte slices
|
// Convert and decode certs back to byte slices
|
||||||
osCert, err := base64.StdEncoding.DecodeString(nc.Machine.CA.Crt)
|
osCert, err := base64.StdEncoding.DecodeString(nc.Machine.CA.Crt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -313,7 +313,7 @@ func translateV1ControlPlane(nc *v1.NodeConfig, ud *userdata.UserData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func translateV1Worker(nc *v1.NodeConfig, ud *userdata.UserData) {
|
func translateV1Alpha1Worker(nc *v1alpha1.NodeConfig, ud *userdata.UserData) {
|
||||||
//Craft a worker kubeadm config
|
//Craft a worker kubeadm config
|
||||||
workerConfig := &kubeadm.JoinConfiguration{
|
workerConfig := &kubeadm.JoinConfiguration{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
@ -2,7 +2,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
package v1
|
package v1alpha1
|
||||||
|
|
||||||
// ClusterConfig reperesents the cluster-wide config values
|
// ClusterConfig reperesents the cluster-wide config values
|
||||||
type ClusterConfig struct {
|
type ClusterConfig struct {
|
@ -2,9 +2,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// Package v1 provides user-facing v1 machine configs
|
// Package v1alpha1 provides user-facing v1alpha1 machine configs
|
||||||
// nolint: dupl
|
// nolint: dupl
|
||||||
package v1
|
package v1alpha1
|
||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
@ -5,33 +5,33 @@
|
|||||||
package generate
|
package generate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
v1 "github.com/talos-systems/talos/pkg/userdata/v1"
|
v1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1"
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func controlPlaneUd(in *Input) (string, error) {
|
func controlPlaneUd(in *Input) (string, error) {
|
||||||
|
|
||||||
machine := &v1.MachineConfig{
|
machine := &v1alpha1.MachineConfig{
|
||||||
Type: "controlplane",
|
Type: "controlplane",
|
||||||
Token: in.TrustdInfo.Token,
|
Token: in.TrustdInfo.Token,
|
||||||
CA: &v1.MachineCAConfig{
|
CA: &v1alpha1.MachineCAConfig{
|
||||||
Crt: in.Certs.OsCert,
|
Crt: in.Certs.OsCert,
|
||||||
Key: in.Certs.OsKey,
|
Key: in.Certs.OsKey,
|
||||||
},
|
},
|
||||||
Kubelet: &v1.KubeletConfig{},
|
Kubelet: &v1alpha1.KubeletConfig{},
|
||||||
Network: &v1.NetworkConfig{},
|
Network: &v1alpha1.NetworkConfig{},
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster := &v1.ClusterConfig{
|
cluster := &v1alpha1.ClusterConfig{
|
||||||
Token: in.KubeadmTokens.BootstrapToken,
|
Token: in.KubeadmTokens.BootstrapToken,
|
||||||
ControlPlane: &v1.ControlPlaneConfig{
|
ControlPlane: &v1alpha1.ControlPlaneConfig{
|
||||||
IPs: in.MasterIPs,
|
IPs: in.MasterIPs,
|
||||||
Index: in.Index,
|
Index: in.Index,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ud := v1.NodeConfig{
|
ud := v1alpha1.NodeConfig{
|
||||||
Version: "v1",
|
Version: "v1alpha1",
|
||||||
Machine: machine,
|
Machine: machine,
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
}
|
}
|
@ -9,13 +9,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
v1 "github.com/talos-systems/talos/pkg/userdata/v1"
|
v1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1"
|
||||||
udgenv1 "github.com/talos-systems/talos/pkg/userdata/v1/generate"
|
udgenv1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1/generate"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
input *udgenv1.Input
|
input *udgenv1alpha1.Input
|
||||||
)
|
)
|
||||||
|
|
||||||
type GenerateSuite struct {
|
type GenerateSuite struct {
|
||||||
@ -28,37 +28,37 @@ func TestGenerateSuite(t *testing.T) {
|
|||||||
|
|
||||||
func (suite *GenerateSuite) SetupSuite() {
|
func (suite *GenerateSuite) SetupSuite() {
|
||||||
var err error
|
var err error
|
||||||
input, err = udgenv1.NewInput("test", []string{"10.0.1.5", "10.0.1.6", "10.0.1.7"})
|
input, err = udgenv1alpha1.NewInput("test", []string{"10.0.1.5", "10.0.1.6", "10.0.1.7"})
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenerateSuite) TestGenerateInitSuccess() {
|
func (suite *GenerateSuite) TestGenerateInitSuccess() {
|
||||||
input.IP = net.ParseIP("10.0.1.5")
|
input.IP = net.ParseIP("10.0.1.5")
|
||||||
dataString, err := udgenv1.Userdata(udgenv1.TypeInit, input)
|
dataString, err := udgenv1alpha1.Userdata(udgenv1alpha1.TypeInit, input)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
data := &v1.NodeConfig{}
|
data := &v1alpha1.NodeConfig{}
|
||||||
err = yaml.Unmarshal([]byte(dataString), data)
|
err = yaml.Unmarshal([]byte(dataString), data)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenerateSuite) TestGenerateControlPlaneSuccess() {
|
func (suite *GenerateSuite) TestGenerateControlPlaneSuccess() {
|
||||||
input.IP = net.ParseIP("10.0.1.6")
|
input.IP = net.ParseIP("10.0.1.6")
|
||||||
dataString, err := udgenv1.Userdata(udgenv1.TypeControlPlane, input)
|
dataString, err := udgenv1alpha1.Userdata(udgenv1alpha1.TypeControlPlane, input)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
data := &v1.NodeConfig{}
|
data := &v1alpha1.NodeConfig{}
|
||||||
err = yaml.Unmarshal([]byte(dataString), data)
|
err = yaml.Unmarshal([]byte(dataString), data)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenerateSuite) TestGenerateWorkerSuccess() {
|
func (suite *GenerateSuite) TestGenerateWorkerSuccess() {
|
||||||
dataString, err := udgenv1.Userdata(udgenv1.TypeJoin, input)
|
dataString, err := udgenv1alpha1.Userdata(udgenv1alpha1.TypeJoin, input)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
data := &v1.NodeConfig{}
|
data := &v1alpha1.NodeConfig{}
|
||||||
err = yaml.Unmarshal([]byte(dataString), data)
|
err = yaml.Unmarshal([]byte(dataString), data)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GenerateSuite) TestGenerateTalosconfigSuccess() {
|
func (suite *GenerateSuite) TestGenerateTalosconfigSuccess() {
|
||||||
_, err := udgenv1.Talosconfig(input)
|
_, err := udgenv1alpha1.Talosconfig(input)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
}
|
}
|
@ -5,17 +5,17 @@
|
|||||||
package generate
|
package generate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
v1 "github.com/talos-systems/talos/pkg/userdata/v1"
|
v1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1"
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initUd(in *Input) (string, error) {
|
func initUd(in *Input) (string, error) {
|
||||||
|
|
||||||
machine := &v1.MachineConfig{
|
machine := &v1alpha1.MachineConfig{
|
||||||
Type: "init",
|
Type: "init",
|
||||||
Kubelet: &v1.KubeletConfig{},
|
Kubelet: &v1alpha1.KubeletConfig{},
|
||||||
Network: &v1.NetworkConfig{},
|
Network: &v1alpha1.NetworkConfig{},
|
||||||
CA: &v1.MachineCAConfig{
|
CA: &v1alpha1.MachineCAConfig{
|
||||||
Crt: in.Certs.OsCert,
|
Crt: in.Certs.OsCert,
|
||||||
Key: in.Certs.OsKey,
|
Key: in.Certs.OsKey,
|
||||||
},
|
},
|
||||||
@ -24,33 +24,33 @@ func initUd(in *Input) (string, error) {
|
|||||||
|
|
||||||
certSANs := in.GetAPIServerSANs()
|
certSANs := in.GetAPIServerSANs()
|
||||||
|
|
||||||
cluster := &v1.ClusterConfig{
|
cluster := &v1alpha1.ClusterConfig{
|
||||||
ClusterName: in.ClusterName,
|
ClusterName: in.ClusterName,
|
||||||
ControlPlane: &v1.ControlPlaneConfig{
|
ControlPlane: &v1alpha1.ControlPlaneConfig{
|
||||||
Endpoint: in.ControlPlaneEndpoint,
|
Endpoint: in.ControlPlaneEndpoint,
|
||||||
IPs: in.MasterIPs,
|
IPs: in.MasterIPs,
|
||||||
Index: in.Index,
|
Index: in.Index,
|
||||||
},
|
},
|
||||||
APIServer: &v1.APIServerConfig{
|
APIServer: &v1alpha1.APIServerConfig{
|
||||||
CertSANs: certSANs,
|
CertSANs: certSANs,
|
||||||
},
|
},
|
||||||
ControllerManager: &v1.ControllerManagerConfig{},
|
ControllerManager: &v1alpha1.ControllerManagerConfig{},
|
||||||
Scheduler: &v1.SchedulerConfig{},
|
Scheduler: &v1alpha1.SchedulerConfig{},
|
||||||
Etcd: &v1.EtcdConfig{},
|
Etcd: &v1alpha1.EtcdConfig{},
|
||||||
Network: &v1.ClusterNetworkConfig{
|
Network: &v1alpha1.ClusterNetworkConfig{
|
||||||
DNSDomain: in.ServiceDomain,
|
DNSDomain: in.ServiceDomain,
|
||||||
PodSubnet: in.PodNet,
|
PodSubnet: in.PodNet,
|
||||||
ServiceSubnet: in.ServiceNet,
|
ServiceSubnet: in.ServiceNet,
|
||||||
},
|
},
|
||||||
CA: &v1.ClusterCAConfig{
|
CA: &v1alpha1.ClusterCAConfig{
|
||||||
Crt: in.Certs.K8sCert,
|
Crt: in.Certs.K8sCert,
|
||||||
Key: in.Certs.K8sKey,
|
Key: in.Certs.K8sKey,
|
||||||
},
|
},
|
||||||
Token: in.KubeadmTokens.BootstrapToken,
|
Token: in.KubeadmTokens.BootstrapToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
ud := v1.NodeConfig{
|
ud := v1alpha1.NodeConfig{
|
||||||
Version: "v1",
|
Version: "v1alpha1",
|
||||||
Machine: machine,
|
Machine: machine,
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
}
|
}
|
@ -5,28 +5,28 @@
|
|||||||
package generate
|
package generate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
v1 "github.com/talos-systems/talos/pkg/userdata/v1"
|
v1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1"
|
||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func workerUd(in *Input) (string, error) {
|
func workerUd(in *Input) (string, error) {
|
||||||
|
|
||||||
machine := &v1.MachineConfig{
|
machine := &v1alpha1.MachineConfig{
|
||||||
Type: "worker",
|
Type: "worker",
|
||||||
Token: in.TrustdInfo.Token,
|
Token: in.TrustdInfo.Token,
|
||||||
Kubelet: &v1.KubeletConfig{},
|
Kubelet: &v1alpha1.KubeletConfig{},
|
||||||
Network: &v1.NetworkConfig{},
|
Network: &v1alpha1.NetworkConfig{},
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster := &v1.ClusterConfig{
|
cluster := &v1alpha1.ClusterConfig{
|
||||||
Token: in.KubeadmTokens.BootstrapToken,
|
Token: in.KubeadmTokens.BootstrapToken,
|
||||||
ControlPlane: &v1.ControlPlaneConfig{
|
ControlPlane: &v1alpha1.ControlPlaneConfig{
|
||||||
IPs: in.MasterIPs,
|
IPs: in.MasterIPs,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ud := v1.NodeConfig{
|
ud := v1alpha1.NodeConfig{
|
||||||
Version: "v1",
|
Version: "v1alpha1",
|
||||||
Machine: machine,
|
Machine: machine,
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
}
|
}
|
@ -2,9 +2,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// Package v1 provides user-facing v1 machine configs
|
// Package v1alpha1 provides user-facing v1alpha1 machine configs
|
||||||
//nolint: dupl
|
//nolint: dupl
|
||||||
package v1
|
package v1alpha1
|
||||||
|
|
||||||
// Install represents the installation options for preparing a node.
|
// Install represents the installation options for preparing a node.
|
||||||
type Install struct {
|
type Install struct {
|
@ -2,7 +2,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
package v1
|
package v1alpha1
|
||||||
|
|
||||||
// MachineConfig reperesents the machine-specific config values
|
// MachineConfig reperesents the machine-specific config values
|
||||||
type MachineConfig struct {
|
type MachineConfig struct {
|
@ -2,9 +2,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
// Package v1 provides user-facing v1 machine configs
|
// Package v1alpha1 provides user-facing v1alpha1 machine configs
|
||||||
// nolint: dupl
|
// nolint: dupl
|
||||||
package v1
|
package v1alpha1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
@ -2,7 +2,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
package v1
|
package v1alpha1
|
||||||
|
|
||||||
// NodeConfig holds the full representation of the node config
|
// NodeConfig holds the full representation of the node config
|
||||||
type NodeConfig struct {
|
type NodeConfig struct {
|
Loading…
x
Reference in New Issue
Block a user