talos/pkg/userdata/v1alpha1/generate/controlplane.go
Spencer Smith aed8c06730 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>
2019-09-09 13:03:49 -04:00

46 lines
1015 B
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
import (
v1alpha1 "github.com/talos-systems/talos/pkg/userdata/v1alpha1"
yaml "gopkg.in/yaml.v2"
)
func controlPlaneUd(in *Input) (string, error) {
machine := &v1alpha1.MachineConfig{
Type: "controlplane",
Token: in.TrustdInfo.Token,
CA: &v1alpha1.MachineCAConfig{
Crt: in.Certs.OsCert,
Key: in.Certs.OsKey,
},
Kubelet: &v1alpha1.KubeletConfig{},
Network: &v1alpha1.NetworkConfig{},
}
cluster := &v1alpha1.ClusterConfig{
Token: in.KubeadmTokens.BootstrapToken,
ControlPlane: &v1alpha1.ControlPlaneConfig{
IPs: in.MasterIPs,
Index: in.Index,
},
}
ud := v1alpha1.NodeConfig{
Version: "v1alpha1",
Machine: machine,
Cluster: cluster,
}
udMarshal, err := yaml.Marshal(ud)
if err != nil {
return "", err
}
return string(udMarshal), nil
}