changes and things
parent
744e389a66
commit
8536fb7641
|
@ -80,7 +80,7 @@ func createTestProfile(t *testing.T) {
|
|||
if err := os.MkdirAll(config.ProfileFolderPath(name), 0777); err != nil {
|
||||
t.Fatalf("error creating temporary directory")
|
||||
}
|
||||
if err := config.DefaultLoader.WriteConfigToFile(name, &config.MachineConfig{}); err != nil {
|
||||
if err := config.DefaultLoader.WriteConfigToFile(name, &config.ClusterConfig{}); err != nil {
|
||||
t.Fatalf("error creating temporary profile config: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ var logsCmd = &cobra.Command{
|
|||
if err != nil {
|
||||
exit.WithError("command runner", err)
|
||||
}
|
||||
bs, err := cluster.Bootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
|
||||
bs, err := cluster.Bootstrapper(api, viper.GetString(cmdcfg.Bootstrapper), viper.GetString(config.MachineProfile))
|
||||
if err != nil {
|
||||
exit.WithError("Error getting cluster bootstrapper", err)
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ func updateDriver(driverName string) {
|
|||
}
|
||||
}
|
||||
|
||||
func cacheISO(cfg *config.MachineConfig, driverName string) {
|
||||
func cacheISO(cfg *config.ClusterConfig, driverName string) {
|
||||
if !driver.BareMetal(driverName) && !driver.IsKIC(driverName) {
|
||||
if err := cluster.CacheISO(*cfg); err != nil {
|
||||
exit.WithError("Failed to cache ISO", err)
|
||||
|
@ -429,7 +429,7 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName st
|
|||
return nil
|
||||
}
|
||||
|
||||
func selectDriver(existing *config.MachineConfig) registry.DriverState {
|
||||
func selectDriver(existing *config.ClusterConfig) registry.DriverState {
|
||||
// Technically unrelated, but important to perform before detection
|
||||
driver.SetLibvirtURI(viper.GetString(kvmQemuURI))
|
||||
|
||||
|
@ -464,7 +464,7 @@ func selectDriver(existing *config.MachineConfig) registry.DriverState {
|
|||
}
|
||||
|
||||
// validateDriver validates that the selected driver appears sane, exits if not
|
||||
func validateDriver(ds registry.DriverState, existing *config.MachineConfig) {
|
||||
func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
|
||||
name := ds.Name
|
||||
glog.Infof("validating driver %q against %+v", name, existing)
|
||||
if !driver.Supported(name) {
|
||||
|
@ -717,10 +717,10 @@ func validateRegistryMirror() {
|
|||
}
|
||||
|
||||
// generateCfgFromFlags generates config.Config based on flags and supplied arguments
|
||||
func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string) (config.MachineConfig, config.Node, error) {
|
||||
func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string) (config.ClusterConfig, config.Node, error) {
|
||||
r, err := cruntime.New(cruntime.Config{Type: viper.GetString(containerRuntime)})
|
||||
if err != nil {
|
||||
return config.MachineConfig{}, config.Node{}, err
|
||||
return config.ClusterConfig{}, config.Node{}, err
|
||||
}
|
||||
|
||||
// Pick good default values for --network-plugin and --enable-default-cni based on runtime.
|
||||
|
@ -775,7 +775,7 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string)
|
|||
Worker: true,
|
||||
}
|
||||
|
||||
cfg := config.MachineConfig{
|
||||
cfg := config.ClusterConfig{
|
||||
Name: viper.GetString(config.MachineProfile),
|
||||
KeepContext: viper.GetBool(keepContext),
|
||||
EmbedCerts: viper.GetBool(embedCerts),
|
||||
|
@ -881,7 +881,7 @@ func autoSetDriverOptions(cmd *cobra.Command, drvName string) (err error) {
|
|||
}
|
||||
|
||||
// getKubernetesVersion ensures that the requested version is reasonable
|
||||
func getKubernetesVersion(old *config.MachineConfig) string {
|
||||
func getKubernetesVersion(old *config.ClusterConfig) string {
|
||||
paramVersion := viper.GetString(kubernetesVersion)
|
||||
|
||||
if paramVersion == "" { // if the user did not specify any version then ...
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestGetKuberneterVersion(t *testing.T) {
|
|||
description string
|
||||
expectedVersion string
|
||||
paramVersion string
|
||||
cfg *cfg.MachineConfig
|
||||
cfg *cfg.ClusterConfig
|
||||
}{
|
||||
{
|
||||
description: "kubernetes-version not given, no config",
|
||||
|
@ -42,7 +42,7 @@ func TestGetKuberneterVersion(t *testing.T) {
|
|||
description: "kubernetes-version not given, config available",
|
||||
expectedVersion: "v1.15.0",
|
||||
paramVersion: "",
|
||||
cfg: &cfg.MachineConfig{KubernetesConfig: cfg.KubernetesConfig{KubernetesVersion: "v1.15.0"}},
|
||||
cfg: &cfg.ClusterConfig{KubernetesConfig: cfg.KubernetesConfig{KubernetesVersion: "v1.15.0"}},
|
||||
},
|
||||
{
|
||||
description: "kubernetes-version given, no config",
|
||||
|
@ -53,7 +53,7 @@ func TestGetKuberneterVersion(t *testing.T) {
|
|||
description: "kubernetes-version given, config available",
|
||||
expectedVersion: "v1.16.0",
|
||||
paramVersion: "v1.16.0",
|
||||
cfg: &cfg.MachineConfig{KubernetesConfig: cfg.KubernetesConfig{KubernetesVersion: "v1.15.0"}},
|
||||
cfg: &cfg.ClusterConfig{KubernetesConfig: cfg.KubernetesConfig{KubernetesVersion: "v1.15.0"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ func run(name, value, profile string, fns []setFn) error {
|
|||
}
|
||||
|
||||
// SetBool sets a bool value
|
||||
func SetBool(m *config.MachineConfig, name string, val string) error {
|
||||
func SetBool(m *config.ClusterConfig, name string, val string) error {
|
||||
b, err := strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -44,7 +44,7 @@ func createTestProfile(t *testing.T) string {
|
|||
if err := os.MkdirAll(config.ProfileFolderPath(name), 0777); err != nil {
|
||||
t.Fatalf("error creating temporary directory")
|
||||
}
|
||||
if err := config.DefaultLoader.WriteConfigToFile(name, &config.MachineConfig{}); err != nil {
|
||||
if err := config.DefaultLoader.WriteConfigToFile(name, &config.ClusterConfig{}); err != nil {
|
||||
t.Fatalf("error creating temporary profile config: %v", err)
|
||||
}
|
||||
return name
|
||||
|
|
|
@ -23,7 +23,7 @@ type setFn func(string, string, string) error
|
|||
// Addon represents an addon
|
||||
type Addon struct {
|
||||
name string
|
||||
set func(*config.MachineConfig, string, string) error
|
||||
set func(*config.ClusterConfig, string, string) error
|
||||
validations []setFn
|
||||
callbacks []setFn
|
||||
}
|
||||
|
|
|
@ -35,10 +35,11 @@ type LogOptions struct {
|
|||
|
||||
// Bootstrapper contains all the methods needed to bootstrap a kubernetes cluster
|
||||
type Bootstrapper interface {
|
||||
StartCluster(config.MachineConfig) error
|
||||
UpdateCluster(config.MachineConfig) error
|
||||
StartCluster(config.ClusterConfig) error
|
||||
UpdateCluster(config.ClusterConfig) error
|
||||
DeleteCluster(config.KubernetesConfig) error
|
||||
WaitForCluster(config.MachineConfig, time.Duration) error
|
||||
WaitForCluster(config.ClusterConfig, time.Duration) error
|
||||
JoinCluster(config.ClusterConfig, config.Node, string) error
|
||||
// LogCommands returns a map of log type to a command which will display that log.
|
||||
LogCommands(LogOptions) map[string]string
|
||||
SetupCerts(config.KubernetesConfig, config.Node) error
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
const remoteContainerRuntime = "remote"
|
||||
|
||||
// GenerateKubeadmYAML generates the kubeadm.yaml file
|
||||
func GenerateKubeadmYAML(mc config.MachineConfig, r cruntime.Manager) ([]byte, error) {
|
||||
func GenerateKubeadmYAML(mc config.ClusterConfig, r cruntime.Manager) ([]byte, error) {
|
||||
k8s := mc.KubernetesConfig
|
||||
version, err := ParseKubernetesVersion(k8s.KubernetesVersion)
|
||||
if err != nil {
|
||||
|
|
|
@ -106,9 +106,9 @@ func TestGenerateKubeadmYAMLDNS(t *testing.T) {
|
|||
name string
|
||||
runtime string
|
||||
shouldErr bool
|
||||
cfg config.MachineConfig
|
||||
cfg config.ClusterConfig
|
||||
}{
|
||||
{"dns", "docker", false, config.MachineConfig{KubernetesConfig: config.KubernetesConfig{DNSDomain: "1.1.1.1"}}},
|
||||
{"dns", "docker", false, config.ClusterConfig{KubernetesConfig: config.KubernetesConfig{DNSDomain: "1.1.1.1"}}},
|
||||
}
|
||||
for _, version := range versions {
|
||||
for _, tc := range tests {
|
||||
|
@ -172,17 +172,17 @@ func TestGenerateKubeadmYAML(t *testing.T) {
|
|||
name string
|
||||
runtime string
|
||||
shouldErr bool
|
||||
cfg config.MachineConfig
|
||||
cfg config.ClusterConfig
|
||||
}{
|
||||
{"default", "docker", false, config.MachineConfig{}},
|
||||
{"containerd", "containerd", false, config.MachineConfig{}},
|
||||
{"crio", "crio", false, config.MachineConfig{}},
|
||||
{"options", "docker", false, config.MachineConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: extraOpts}}},
|
||||
{"crio-options-gates", "crio", false, config.MachineConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: extraOpts, FeatureGates: "a=b"}}},
|
||||
{"unknown-component", "docker", true, config.MachineConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: config.ExtraOptionSlice{config.ExtraOption{Component: "not-a-real-component", Key: "killswitch", Value: "true"}}}}},
|
||||
{"containerd-api-port", "containerd", false, config.MachineConfig{Nodes: []config.Node{{Port: 12345}}}},
|
||||
{"containerd-pod-network-cidr", "containerd", false, config.MachineConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: extraOptsPodCidr}}},
|
||||
{"image-repository", "docker", false, config.MachineConfig{KubernetesConfig: config.KubernetesConfig{ImageRepository: "test/repo"}}},
|
||||
{"default", "docker", false, config.ClusterConfig{}},
|
||||
{"containerd", "containerd", false, config.ClusterConfig{}},
|
||||
{"crio", "crio", false, config.ClusterConfig{}},
|
||||
{"options", "docker", false, config.ClusterConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: extraOpts}}},
|
||||
{"crio-options-gates", "crio", false, config.ClusterConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: extraOpts, FeatureGates: "a=b"}}},
|
||||
{"unknown-component", "docker", true, config.ClusterConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: config.ExtraOptionSlice{config.ExtraOption{Component: "not-a-real-component", Key: "killswitch", Value: "true"}}}}},
|
||||
{"containerd-api-port", "containerd", false, config.ClusterConfig{Nodes: []config.Node{{Port: 12345}}}},
|
||||
{"containerd-pod-network-cidr", "containerd", false, config.ClusterConfig{KubernetesConfig: config.KubernetesConfig{ExtraOptions: extraOptsPodCidr}}},
|
||||
{"image-repository", "docker", false, config.ClusterConfig{KubernetesConfig: config.KubernetesConfig{ImageRepository: "test/repo"}}},
|
||||
}
|
||||
for _, version := range versions {
|
||||
for _, tc := range tests {
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
// NewKubeletConfig generates a new systemd unit containing a configured kubelet
|
||||
// based on the options present in the KubernetesConfig.
|
||||
func NewKubeletConfig(mc config.MachineConfig, nc config.Node, r cruntime.Manager) ([]byte, error) {
|
||||
func NewKubeletConfig(mc config.ClusterConfig, nc config.Node, r cruntime.Manager) ([]byte, error) {
|
||||
k8s := mc.KubernetesConfig
|
||||
version, err := ParseKubernetesVersion(k8s.KubernetesVersion)
|
||||
if err != nil {
|
||||
|
|
|
@ -30,13 +30,13 @@ import (
|
|||
func TestGenerateKubeletConfig(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
cfg config.MachineConfig
|
||||
cfg config.ClusterConfig
|
||||
expected string
|
||||
shouldErr bool
|
||||
}{
|
||||
{
|
||||
description: "old docker",
|
||||
cfg: config.MachineConfig{
|
||||
cfg: config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
KubernetesVersion: constants.OldestKubernetesVersion,
|
||||
ContainerRuntime: "docker",
|
||||
|
@ -61,7 +61,7 @@ ExecStart=/var/lib/minikube/binaries/v1.11.10/kubelet --allow-privileged=true --
|
|||
},
|
||||
{
|
||||
description: "newest cri runtime",
|
||||
cfg: config.MachineConfig{
|
||||
cfg: config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
KubernetesVersion: constants.NewestKubernetesVersion,
|
||||
ContainerRuntime: "cri-o",
|
||||
|
@ -86,7 +86,7 @@ ExecStart=/var/lib/minikube/binaries/v1.17.2/kubelet --authorization-mode=Webhoo
|
|||
},
|
||||
{
|
||||
description: "default containerd runtime",
|
||||
cfg: config.MachineConfig{
|
||||
cfg: config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
KubernetesVersion: constants.DefaultKubernetesVersion,
|
||||
ContainerRuntime: "containerd",
|
||||
|
@ -111,7 +111,7 @@ ExecStart=/var/lib/minikube/binaries/v1.17.2/kubelet --authorization-mode=Webhoo
|
|||
},
|
||||
{
|
||||
description: "default containerd runtime with IP override",
|
||||
cfg: config.MachineConfig{
|
||||
cfg: config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
KubernetesVersion: constants.DefaultKubernetesVersion,
|
||||
ContainerRuntime: "containerd",
|
||||
|
@ -143,7 +143,7 @@ ExecStart=/var/lib/minikube/binaries/v1.17.2/kubelet --authorization-mode=Webhoo
|
|||
},
|
||||
{
|
||||
description: "docker with custom image repository",
|
||||
cfg: config.MachineConfig{
|
||||
cfg: config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
KubernetesVersion: constants.DefaultKubernetesVersion,
|
||||
ContainerRuntime: "docker",
|
||||
|
|
|
@ -35,7 +35,6 @@ import (
|
|||
"github.com/docker/machine/libmachine/state"
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
kconst "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/minikube/pkg/drivers/kic"
|
||||
|
@ -64,8 +63,7 @@ type Bootstrapper struct {
|
|||
}
|
||||
|
||||
// NewBootstrapper creates a new kubeadm.Bootstrapper
|
||||
func NewBootstrapper(api libmachine.API) (*Bootstrapper, error) {
|
||||
name := viper.GetString(config.MachineProfile)
|
||||
func NewBootstrapper(api libmachine.API, name string) (*Bootstrapper, error) {
|
||||
h, err := api.Load(name)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting api client")
|
||||
|
@ -149,7 +147,7 @@ func (k *Bootstrapper) createCompatSymlinks() error {
|
|||
}
|
||||
|
||||
// StartCluster starts the cluster
|
||||
func (k *Bootstrapper) StartCluster(cfg config.MachineConfig) error {
|
||||
func (k *Bootstrapper) StartCluster(cfg config.ClusterConfig) error {
|
||||
err := bsutil.ExistingConfig(k.c)
|
||||
if err == nil { // if there is an existing cluster don't reconfigure it
|
||||
return k.restartCluster(cfg)
|
||||
|
@ -262,7 +260,7 @@ func (k *Bootstrapper) client(ip string, port int) (*kubernetes.Clientset, error
|
|||
}
|
||||
|
||||
// WaitForCluster blocks until the cluster appears to be healthy
|
||||
func (k *Bootstrapper) WaitForCluster(cfg config.MachineConfig, timeout time.Duration) error {
|
||||
func (k *Bootstrapper) WaitForCluster(cfg config.ClusterConfig, timeout time.Duration) error {
|
||||
start := time.Now()
|
||||
out.T(out.Waiting, "Waiting for cluster to come online ...")
|
||||
cp, err := config.PrimaryControlPlane(cfg)
|
||||
|
@ -295,7 +293,7 @@ func (k *Bootstrapper) WaitForCluster(cfg config.MachineConfig, timeout time.Dur
|
|||
}
|
||||
|
||||
// restartCluster restarts the Kubernetes cluster configured by kubeadm
|
||||
func (k *Bootstrapper) restartCluster(cfg config.MachineConfig) error {
|
||||
func (k *Bootstrapper) restartCluster(cfg config.ClusterConfig) error {
|
||||
glog.Infof("restartCluster start")
|
||||
|
||||
start := time.Now()
|
||||
|
@ -371,6 +369,29 @@ func (k *Bootstrapper) restartCluster(cfg config.MachineConfig) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// JoinCluster adds a node to an existing cluster
|
||||
func (k *Bootstrapper) JoinCluster(cc config.ClusterConfig, n config.Node, joinCmd string) error {
|
||||
start := time.Now()
|
||||
glog.Infof("JoinCluster: %+v", cc)
|
||||
defer func() {
|
||||
glog.Infof("JoinCluster complete in %s", time.Since(start))
|
||||
}()
|
||||
|
||||
// Join the master by specifying its token
|
||||
joinCmd = fmt.Sprintf("%s --v=10 --node-name=%s", joinCmd, n.Name)
|
||||
fmt.Println(joinCmd)
|
||||
out, err := k.c.RunCmd(exec.Command("/bin/bash", "-c", joinCmd))
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "cmd failed: %s\n%s\n", joinCmd, out)
|
||||
}
|
||||
|
||||
if _, err := k.c.RunCmd(exec.Command("/bin/bash", "-c", "sudo systemctl daemon-reload && sudo systemctl enable kubelet && sudo systemctl start kubelet")); err != nil {
|
||||
return errors.Wrap(err, "starting kubelet")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteCluster removes the components that were started earlier
|
||||
func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
|
||||
version, err := bsutil.ParseKubernetesVersion(k8s.KubernetesVersion)
|
||||
|
@ -396,7 +417,7 @@ func (k *Bootstrapper) SetupCerts(k8s config.KubernetesConfig, n config.Node) er
|
|||
}
|
||||
|
||||
// UpdateCluster updates the cluster
|
||||
func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error {
|
||||
func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
|
||||
images, err := images.Kubeadm(cfg.KubernetesConfig.ImageRepository, cfg.KubernetesConfig.KubernetesVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "kubeadm images")
|
||||
|
@ -469,7 +490,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error {
|
|||
}
|
||||
|
||||
// applyKicOverlay applies the CNI plugin needed to make kic work
|
||||
func (k *Bootstrapper) applyKicOverlay(cfg config.MachineConfig) error {
|
||||
func (k *Bootstrapper) applyKicOverlay(cfg config.ClusterConfig) error {
|
||||
cmd := exec.Command("sudo",
|
||||
path.Join(vmpath.GuestPersistentDir, "binaries", cfg.KubernetesConfig.KubernetesVersion, "kubectl"), "create", fmt.Sprintf("--kubeconfig=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
|
||||
"-f", "-")
|
||||
|
|
|
@ -42,12 +42,12 @@ func init() {
|
|||
}
|
||||
|
||||
// Bootstrapper returns a new bootstrapper for the cluster
|
||||
func Bootstrapper(api libmachine.API, bootstrapperName string) (bootstrapper.Bootstrapper, error) {
|
||||
func Bootstrapper(api libmachine.API, bootstrapperName string, machineName string) (bootstrapper.Bootstrapper, error) {
|
||||
var b bootstrapper.Bootstrapper
|
||||
var err error
|
||||
switch bootstrapperName {
|
||||
case bootstrapper.Kubeadm:
|
||||
b, err = kubeadm.NewBootstrapper(api)
|
||||
b, err = kubeadm.NewBootstrapper(api, machineName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting a new kubeadm bootstrapper")
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
// CacheISO downloads and caches ISO.
|
||||
func CacheISO(cfg config.MachineConfig) error {
|
||||
func CacheISO(cfg config.ClusterConfig) error {
|
||||
if driver.BareMetal(cfg.Driver) {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -141,19 +141,19 @@ func encode(w io.Writer, m MinikubeConfig) error {
|
|||
}
|
||||
|
||||
// Load loads the kubernetes and machine config for the current machine
|
||||
func Load(profile string) (*MachineConfig, error) {
|
||||
func Load(profile string) (*ClusterConfig, error) {
|
||||
return DefaultLoader.LoadConfigFromFile(profile)
|
||||
}
|
||||
|
||||
// Write writes the kubernetes and machine config for the current machine
|
||||
func Write(profile string, cc *MachineConfig) error {
|
||||
func Write(profile string, cc *ClusterConfig) error {
|
||||
return DefaultLoader.WriteConfigToFile(profile, cc)
|
||||
}
|
||||
|
||||
// Loader loads the kubernetes and machine config based on the machine profile name
|
||||
type Loader interface {
|
||||
LoadConfigFromFile(profile string, miniHome ...string) (*MachineConfig, error)
|
||||
WriteConfigToFile(profileName string, cc *MachineConfig, miniHome ...string) error
|
||||
LoadConfigFromFile(profile string, miniHome ...string) (*ClusterConfig, error)
|
||||
WriteConfigToFile(profileName string, cc *ClusterConfig, miniHome ...string) error
|
||||
}
|
||||
|
||||
type simpleConfigLoader struct{}
|
||||
|
@ -161,8 +161,8 @@ type simpleConfigLoader struct{}
|
|||
// DefaultLoader is the default config loader
|
||||
var DefaultLoader Loader = &simpleConfigLoader{}
|
||||
|
||||
func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...string) (*MachineConfig, error) {
|
||||
var cc MachineConfig
|
||||
func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...string) (*ClusterConfig, error) {
|
||||
var cc ClusterConfig
|
||||
// Move to profile package
|
||||
path := profileFilePath(profileName, miniHome...)
|
||||
|
||||
|
@ -184,7 +184,7 @@ func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...
|
|||
return &cc, nil
|
||||
}
|
||||
|
||||
func (c *simpleConfigLoader) WriteConfigToFile(profileName string, cc *MachineConfig, miniHome ...string) error {
|
||||
func (c *simpleConfigLoader) WriteConfigToFile(profileName string, cc *ClusterConfig, miniHome ...string) error {
|
||||
// Move to profile package
|
||||
path := profileFilePath(profileName, miniHome...)
|
||||
contents, err := json.MarshalIndent(cc, "", " ")
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package config
|
||||
|
||||
// AddNode adds a new node config to an existing cluster.
|
||||
func AddNode(cc *MachineConfig, name string, controlPlane bool, k8sVersion string, profileName string) error {
|
||||
func AddNode(cc *ClusterConfig, name string, controlPlane bool, k8sVersion string, profileName string) error {
|
||||
node := Node{
|
||||
Name: name,
|
||||
Worker: true,
|
||||
|
|
|
@ -52,7 +52,7 @@ func (p *Profile) IsValid() bool {
|
|||
}
|
||||
|
||||
// PrimaryControlPlane gets the node specific config for the first created control plane
|
||||
func PrimaryControlPlane(cc MachineConfig) (Node, error) {
|
||||
func PrimaryControlPlane(cc ClusterConfig) (Node, error) {
|
||||
for _, n := range cc.Nodes {
|
||||
if n.ControlPlane {
|
||||
return n, nil
|
||||
|
@ -86,12 +86,12 @@ func ProfileExists(name string, miniHome ...string) bool {
|
|||
|
||||
// CreateEmptyProfile creates an empty profile and stores in $MINIKUBE_HOME/profiles/<profilename>/config.json
|
||||
func CreateEmptyProfile(name string, miniHome ...string) error {
|
||||
cfg := &MachineConfig{}
|
||||
cfg := &ClusterConfig{}
|
||||
return SaveProfile(name, cfg, miniHome...)
|
||||
}
|
||||
|
||||
// SaveProfile creates an profile out of the cfg and stores in $MINIKUBE_HOME/profiles/<profilename>/config.json
|
||||
func SaveProfile(name string, cfg *MachineConfig, miniHome ...string) error {
|
||||
func SaveProfile(name string, cfg *ClusterConfig, miniHome ...string) error {
|
||||
data, err := json.MarshalIndent(cfg, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -164,13 +164,13 @@ func TestCreateProfile(t *testing.T) {
|
|||
|
||||
var testCases = []struct {
|
||||
name string
|
||||
cfg *MachineConfig
|
||||
cfg *ClusterConfig
|
||||
expectErr bool
|
||||
}{
|
||||
{"p_empty_config", &MachineConfig{}, false},
|
||||
{"p_partial_config", &MachineConfig{KubernetesConfig: KubernetesConfig{
|
||||
{"p_empty_config", &ClusterConfig{}, false},
|
||||
{"p_partial_config", &ClusterConfig{KubernetesConfig: KubernetesConfig{
|
||||
ShouldLoadCachedImages: false}}, false},
|
||||
{"p_partial_config2", &MachineConfig{
|
||||
{"p_partial_config2", &ClusterConfig{
|
||||
KeepContext: false, KubernetesConfig: KubernetesConfig{
|
||||
ShouldLoadCachedImages: false}}, false},
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"MachineConfig": {
|
||||
"ClusterConfig": {
|
||||
"KeepContext": false,
|
||||
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
|
||||
"Memory": 2000,
|
||||
|
|
|
@ -27,11 +27,11 @@ import (
|
|||
type Profile struct {
|
||||
Name string
|
||||
Status string // running, stopped
|
||||
Config *MachineConfig
|
||||
Config *ClusterConfig
|
||||
}
|
||||
|
||||
// MachineConfig contains the parameters used to start a cluster.
|
||||
type MachineConfig struct {
|
||||
// ClusterConfig contains the parameters used to start a cluster.
|
||||
type ClusterConfig struct {
|
||||
Name string
|
||||
KeepContext bool // used by start and profile command to or not to switch kubectl's current context
|
||||
EmbedCerts bool // used by kubeconfig.Setup
|
||||
|
|
|
@ -61,7 +61,7 @@ func CacheImagesForBootstrapper(imageRepository string, version string, clusterB
|
|||
}
|
||||
|
||||
// LoadImages loads previously cached images into the container runtime
|
||||
func LoadImages(cc *config.MachineConfig, runner command.Runner, images []string, cacheDir string) error {
|
||||
func LoadImages(cc *config.ClusterConfig, runner command.Runner, images []string, cacheDir string) error {
|
||||
glog.Infof("LoadImages start: %s", images)
|
||||
start := time.Now()
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ type MockDownloader struct{}
|
|||
func (d MockDownloader) GetISOFileURI(isoURL string) string { return "" }
|
||||
func (d MockDownloader) CacheMinikubeISOFromURL(isoURL string) error { return nil }
|
||||
|
||||
func createMockDriverHost(c config.MachineConfig) (interface{}, error) {
|
||||
func createMockDriverHost(c config.ClusterConfig) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func RegisterMockDriver(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
var defaultMachineConfig = config.MachineConfig{
|
||||
var defaultClusterConfig = config.ClusterConfig{
|
||||
Driver: driver.Mock,
|
||||
MinikubeISO: constants.DefaultISOURL,
|
||||
Downloader: MockDownloader{},
|
||||
|
@ -76,7 +76,7 @@ func TestCreateHost(t *testing.T) {
|
|||
t.Fatal("Machine already exists.")
|
||||
}
|
||||
|
||||
_, err := createHost(api, defaultMachineConfig)
|
||||
_, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating host: %v", err)
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func TestStartHostExists(t *testing.T) {
|
|||
RegisterMockDriver(t)
|
||||
api := tests.NewMockAPI(t)
|
||||
// Create an initial host.
|
||||
ih, err := createHost(api, defaultMachineConfig)
|
||||
ih, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating host: %v", err)
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ func TestStartHostExists(t *testing.T) {
|
|||
md := &tests.MockDetector{Provisioner: &tests.MockProvisioner{}}
|
||||
provision.SetDetector(md)
|
||||
|
||||
mc := defaultMachineConfig
|
||||
mc := defaultClusterConfig
|
||||
mc.Name = ih.Name
|
||||
// This should pass without calling Create because the host exists already.
|
||||
h, err := StartHost(api, mc)
|
||||
|
@ -151,7 +151,7 @@ func TestStartHostErrMachineNotExist(t *testing.T) {
|
|||
api := tests.NewMockAPI(t)
|
||||
// Create an incomplete host with machine does not exist error(i.e. User Interrupt Cancel)
|
||||
api.NotExistError = true
|
||||
h, err := createHost(api, defaultMachineConfig)
|
||||
h, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating host: %v", err)
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func TestStartHostErrMachineNotExist(t *testing.T) {
|
|||
md := &tests.MockDetector{Provisioner: &tests.MockProvisioner{}}
|
||||
provision.SetDetector(md)
|
||||
|
||||
mc := defaultMachineConfig
|
||||
mc := defaultClusterConfig
|
||||
mc.Name = h.Name
|
||||
|
||||
// This should pass with creating host, while machine does not exist.
|
||||
|
@ -193,7 +193,7 @@ func TestStartStoppedHost(t *testing.T) {
|
|||
RegisterMockDriver(t)
|
||||
api := tests.NewMockAPI(t)
|
||||
// Create an initial host.
|
||||
h, err := createHost(api, defaultMachineConfig)
|
||||
h, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating host: %v", err)
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ func TestStartStoppedHost(t *testing.T) {
|
|||
|
||||
md := &tests.MockDetector{Provisioner: &tests.MockProvisioner{}}
|
||||
provision.SetDetector(md)
|
||||
mc := defaultMachineConfig
|
||||
mc := defaultClusterConfig
|
||||
mc.Name = h.Name
|
||||
h, err = StartHost(api, mc)
|
||||
if err != nil {
|
||||
|
@ -233,7 +233,7 @@ func TestStartHost(t *testing.T) {
|
|||
md := &tests.MockDetector{Provisioner: &tests.MockProvisioner{}}
|
||||
provision.SetDetector(md)
|
||||
|
||||
h, err := StartHost(api, defaultMachineConfig)
|
||||
h, err := StartHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Fatal("Error starting host.")
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ func TestStartHostConfig(t *testing.T) {
|
|||
md := &tests.MockDetector{Provisioner: &tests.MockProvisioner{}}
|
||||
provision.SetDetector(md)
|
||||
|
||||
config := config.MachineConfig{
|
||||
config := config.ClusterConfig{
|
||||
Driver: driver.Mock,
|
||||
DockerEnv: []string{"FOO=BAR"},
|
||||
DockerOpt: []string{"param=value"},
|
||||
|
@ -298,7 +298,7 @@ func TestStopHostError(t *testing.T) {
|
|||
func TestStopHost(t *testing.T) {
|
||||
RegisterMockDriver(t)
|
||||
api := tests.NewMockAPI(t)
|
||||
h, err := createHost(api, defaultMachineConfig)
|
||||
h, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Errorf("createHost failed: %v", err)
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ func TestStopHost(t *testing.T) {
|
|||
func TestDeleteHost(t *testing.T) {
|
||||
RegisterMockDriver(t)
|
||||
api := tests.NewMockAPI(t)
|
||||
if _, err := createHost(api, defaultMachineConfig); err != nil {
|
||||
if _, err := createHost(api, defaultClusterConfig); err != nil {
|
||||
t.Errorf("createHost failed: %v", err)
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ func TestDeleteHost(t *testing.T) {
|
|||
func TestDeleteHostErrorDeletingVM(t *testing.T) {
|
||||
RegisterMockDriver(t)
|
||||
api := tests.NewMockAPI(t)
|
||||
h, err := createHost(api, defaultMachineConfig)
|
||||
h, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Errorf("createHost failed: %v", err)
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ func TestDeleteHostErrorDeletingFiles(t *testing.T) {
|
|||
RegisterMockDriver(t)
|
||||
api := tests.NewMockAPI(t)
|
||||
api.RemoveError = true
|
||||
if _, err := createHost(api, defaultMachineConfig); err != nil {
|
||||
if _, err := createHost(api, defaultClusterConfig); err != nil {
|
||||
t.Errorf("createHost failed: %v", err)
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ func TestDeleteHostErrMachineNotExist(t *testing.T) {
|
|||
api := tests.NewMockAPI(t)
|
||||
// Create an incomplete host with machine does not exist error(i.e. User Interrupt Cancel)
|
||||
api.NotExistError = true
|
||||
_, err := createHost(api, defaultMachineConfig)
|
||||
_, err := createHost(api, defaultClusterConfig)
|
||||
if err != nil {
|
||||
t.Errorf("createHost failed: %v", err)
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ func TestGetHostStatus(t *testing.T) {
|
|||
|
||||
checkState(state.None.String())
|
||||
|
||||
if _, err := createHost(api, defaultMachineConfig); err != nil {
|
||||
if _, err := createHost(api, defaultClusterConfig); err != nil {
|
||||
t.Errorf("createHost failed: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ var (
|
|||
)
|
||||
|
||||
// fixHost fixes up a previously configured VM so that it is ready to run Kubernetes
|
||||
func fixHost(api libmachine.API, mc config.MachineConfig) (*host.Host, error) {
|
||||
func fixHost(api libmachine.API, mc config.ClusterConfig) (*host.Host, error) {
|
||||
out.T(out.Waiting, "Reconfiguring existing host ...")
|
||||
|
||||
start := time.Now()
|
||||
|
|
|
@ -61,7 +61,7 @@ var (
|
|||
)
|
||||
|
||||
// StartHost starts a host VM.
|
||||
func StartHost(api libmachine.API, cfg config.MachineConfig) (*host.Host, error) {
|
||||
func StartHost(api libmachine.API, cfg config.ClusterConfig) (*host.Host, error) {
|
||||
// Prevent machine-driver boot races, as well as our own certificate race
|
||||
releaser, err := acquireMachinesLock(cfg.Name)
|
||||
if err != nil {
|
||||
|
@ -85,7 +85,7 @@ func StartHost(api libmachine.API, cfg config.MachineConfig) (*host.Host, error)
|
|||
return fixHost(api, cfg)
|
||||
}
|
||||
|
||||
func engineOptions(cfg config.MachineConfig) *engine.Options {
|
||||
func engineOptions(cfg config.ClusterConfig) *engine.Options {
|
||||
o := engine.Options{
|
||||
Env: cfg.DockerEnv,
|
||||
InsecureRegistry: append([]string{constants.DefaultServiceCIDR}, cfg.InsecureRegistry...),
|
||||
|
@ -96,7 +96,7 @@ func engineOptions(cfg config.MachineConfig) *engine.Options {
|
|||
return &o
|
||||
}
|
||||
|
||||
func createHost(api libmachine.API, cfg config.MachineConfig) (*host.Host, error) {
|
||||
func createHost(api libmachine.API, cfg config.ClusterConfig) (*host.Host, error) {
|
||||
glog.Infof("createHost starting for %q (driver=%q)", cfg.Name, cfg.Driver)
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
|
@ -152,7 +152,7 @@ func createHost(api libmachine.API, cfg config.MachineConfig) (*host.Host, error
|
|||
}
|
||||
|
||||
// postStart are functions shared between startHost and fixHost
|
||||
func postStartSetup(h *host.Host, mc config.MachineConfig) error {
|
||||
func postStartSetup(h *host.Host, mc config.ClusterConfig) error {
|
||||
glog.Infof("post-start starting for %q (driver=%q)", h.Name, h.DriverName)
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
|
@ -225,7 +225,7 @@ func acquireMachinesLock(name string) (mutex.Releaser, error) {
|
|||
}
|
||||
|
||||
// showHostInfo shows host information
|
||||
func showHostInfo(cfg config.MachineConfig) {
|
||||
func showHostInfo(cfg config.ClusterConfig) {
|
||||
if driver.BareMetal(cfg.Driver) {
|
||||
info, err := getHostInfo()
|
||||
if err == nil {
|
||||
|
|
|
@ -81,7 +81,7 @@ func showVersionInfo(k8sVersion string, cr cruntime.Manager) {
|
|||
}
|
||||
|
||||
// setupKubeAdm adds any requested files into the VM before Kubernetes is started
|
||||
func setupKubeAdm(mAPI libmachine.API, cfg config.MachineConfig, node config.Node) bootstrapper.Bootstrapper {
|
||||
func setupKubeAdm(mAPI libmachine.API, cfg config.ClusterConfig, node config.Node) bootstrapper.Bootstrapper {
|
||||
bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper))
|
||||
if err != nil {
|
||||
exit.WithError("Failed to get bootstrapper", err)
|
||||
|
@ -99,7 +99,7 @@ func setupKubeAdm(mAPI libmachine.API, cfg config.MachineConfig, node config.Nod
|
|||
return bs
|
||||
}
|
||||
|
||||
func setupKubeconfig(h *host.Host, c *config.MachineConfig, n *config.Node, clusterName string) (*kubeconfig.Settings, error) {
|
||||
func setupKubeconfig(h *host.Host, c *config.ClusterConfig, n *config.Node, clusterName string) (*kubeconfig.Settings, error) {
|
||||
addr, err := h.Driver.GetURL()
|
||||
if err != nil {
|
||||
exit.WithError("Failed to get driver URL", err)
|
||||
|
|
|
@ -39,7 +39,7 @@ import (
|
|||
"k8s.io/minikube/pkg/util/retry"
|
||||
)
|
||||
|
||||
func startMachine(cfg *config.MachineConfig, node *config.Node) (runner command.Runner, preExists bool, machineAPI libmachine.API, host *host.Host) {
|
||||
func startMachine(cfg *config.ClusterConfig, node *config.Node) (runner command.Runner, preExists bool, machineAPI libmachine.API, host *host.Host) {
|
||||
m, err := machine.NewAPIClient()
|
||||
if err != nil {
|
||||
exit.WithError("Failed to get machine client", err)
|
||||
|
@ -68,7 +68,7 @@ func startMachine(cfg *config.MachineConfig, node *config.Node) (runner command.
|
|||
}
|
||||
|
||||
// startHost starts a new minikube host using a VM or None
|
||||
func startHost(api libmachine.API, mc config.MachineConfig) (*host.Host, bool) {
|
||||
func startHost(api libmachine.API, mc config.ClusterConfig) (*host.Host, bool) {
|
||||
exists, err := api.Exists(mc.Name)
|
||||
if err != nil {
|
||||
exit.WithError("Failed to check if machine exists", err)
|
||||
|
|
|
@ -38,18 +38,19 @@ const (
|
|||
)
|
||||
|
||||
// Add adds a new node config to an existing cluster.
|
||||
func Add(cc *config.MachineConfig, name string, controlPlane bool, worker bool, k8sVersion string, profileName string) (*config.Node, error) {
|
||||
func Add(cc *config.ClusterConfig, name string, controlPlane bool, worker bool, k8sVersion string, profileName string) (*config.Node, error) {
|
||||
n := config.Node{
|
||||
Name: name,
|
||||
Worker: true,
|
||||
}
|
||||
|
||||
// TODO: Deal with parameters better. Ideally we should be able to acceot any node-specific minikube start params here.
|
||||
if controlPlane {
|
||||
n.ControlPlane = true
|
||||
}
|
||||
|
||||
if worker {
|
||||
n.Worker = true
|
||||
if !worker {
|
||||
n.Worker = false
|
||||
}
|
||||
|
||||
if k8sVersion != "" {
|
||||
|
@ -69,7 +70,7 @@ func Add(cc *config.MachineConfig, name string, controlPlane bool, worker bool,
|
|||
}
|
||||
|
||||
// Delete stops and deletes the given node from the given cluster
|
||||
func Delete(cc config.MachineConfig, name string) error {
|
||||
func Delete(cc config.ClusterConfig, name string) error {
|
||||
_, index, err := Retrieve(&cc, name)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -95,7 +96,7 @@ func Delete(cc config.MachineConfig, name string) error {
|
|||
}
|
||||
|
||||
// Retrieve finds the node by name in the given cluster
|
||||
func Retrieve(cc *config.MachineConfig, name string) (*config.Node, int, error) {
|
||||
func Retrieve(cc *config.ClusterConfig, name string) (*config.Node, int, error) {
|
||||
for i, n := range cc.Nodes {
|
||||
if n.Name == name {
|
||||
return &n, i, nil
|
||||
|
@ -106,7 +107,7 @@ func Retrieve(cc *config.MachineConfig, name string) (*config.Node, int, error)
|
|||
}
|
||||
|
||||
// Save saves a node to a cluster
|
||||
func Save(cfg *config.MachineConfig, node *config.Node) error {
|
||||
func Save(cfg *config.ClusterConfig, node *config.Node) error {
|
||||
update := false
|
||||
for i, n := range cfg.Nodes {
|
||||
if n.Name == node.Name {
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
)
|
||||
|
||||
// Start spins up a guest and starts the kubernetes node.
|
||||
func Start(mc config.MachineConfig, n config.Node, primary bool, existingAddons map[string]bool) (*kubeconfig.Settings, error) {
|
||||
func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons map[string]bool) (*kubeconfig.Settings, error) {
|
||||
// Now that the ISO is downloaded, pull images in the background while the VM boots.
|
||||
var cacheGroup errgroup.Group
|
||||
beginCacheRequiredImages(&cacheGroup, mc.KubernetesConfig.ImageRepository, n.KubernetesVersion)
|
||||
|
|
|
@ -43,7 +43,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(mc config.MachineConfig) (interface{}, error) {
|
||||
func configure(mc config.ClusterConfig) (interface{}, error) {
|
||||
return kic.NewDriver(kic.Config{
|
||||
MachineName: mc.Name,
|
||||
StorePath: localpath.MiniPath(),
|
||||
|
|
|
@ -57,7 +57,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(config cfg.MachineConfig) (interface{}, error) {
|
||||
func configure(config cfg.ClusterConfig) (interface{}, error) {
|
||||
u := config.UUID
|
||||
if u == "" {
|
||||
u = uuid.NewUUID().String()
|
||||
|
|
|
@ -52,7 +52,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(config cfg.MachineConfig) (interface{}, error) {
|
||||
func configure(config cfg.ClusterConfig) (interface{}, error) {
|
||||
d := hyperv.NewDriver(config.Name, localpath.MiniPath())
|
||||
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
|
||||
d.VSwitch = config.HypervVirtualSwitch
|
||||
|
|
|
@ -67,7 +67,7 @@ type kvmDriver struct {
|
|||
ConnectionURI string
|
||||
}
|
||||
|
||||
func configure(mc config.MachineConfig) (interface{}, error) {
|
||||
func configure(mc config.ClusterConfig) (interface{}, error) {
|
||||
name := mc.Name
|
||||
return kvmDriver{
|
||||
BaseDriver: &drivers.BaseDriver{
|
||||
|
|
|
@ -42,7 +42,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(mc config.MachineConfig) (interface{}, error) {
|
||||
func configure(mc config.ClusterConfig) (interface{}, error) {
|
||||
return none.NewDriver(none.Config{
|
||||
MachineName: mc.Name,
|
||||
StorePath: localpath.MiniPath(),
|
||||
|
|
|
@ -44,7 +44,7 @@ func init() {
|
|||
|
||||
}
|
||||
|
||||
func configure(config cfg.MachineConfig) (interface{}, error) {
|
||||
func configure(config cfg.ClusterConfig) (interface{}, error) {
|
||||
d := parallels.NewDriver(config.Name, localpath.MiniPath()).(*parallels.Driver)
|
||||
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
|
||||
d.Memory = config.Memory
|
||||
|
|
|
@ -49,7 +49,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(mc config.MachineConfig) (interface{}, error) {
|
||||
func configure(mc config.ClusterConfig) (interface{}, error) {
|
||||
return kic.NewDriver(kic.Config{
|
||||
MachineName: mc.Name,
|
||||
StorePath: localpath.MiniPath(),
|
||||
|
|
|
@ -49,7 +49,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(mc config.MachineConfig) (interface{}, error) {
|
||||
func configure(mc config.ClusterConfig) (interface{}, error) {
|
||||
d := virtualbox.NewDriver(mc.Name, localpath.MiniPath())
|
||||
d.Boot2DockerURL = mc.Downloader.GetISOFileURI(mc.MinikubeISO)
|
||||
d.Memory = mc.Memory
|
||||
|
|
|
@ -39,7 +39,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(mc config.MachineConfig) (interface{}, error) {
|
||||
func configure(mc config.ClusterConfig) (interface{}, error) {
|
||||
d := vmwcfg.NewConfig(mc.Name, localpath.MiniPath())
|
||||
d.Boot2DockerURL = mc.Downloader.GetISOFileURI(mc.MinikubeISO)
|
||||
d.Memory = mc.Memory
|
||||
|
|
|
@ -44,7 +44,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func configure(config cfg.MachineConfig) (interface{}, error) {
|
||||
func configure(config cfg.ClusterConfig) (interface{}, error) {
|
||||
d := vmwarefusion.NewDriver(config.Name, localpath.MiniPath()).(*vmwarefusion.Driver)
|
||||
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
|
||||
d.Memory = config.Memory
|
||||
|
|
|
@ -60,7 +60,7 @@ type Registry interface {
|
|||
}
|
||||
|
||||
// Configurator emits a struct to be marshalled into JSON for Machine Driver
|
||||
type Configurator func(config.MachineConfig) (interface{}, error)
|
||||
type Configurator func(config.ClusterConfig) (interface{}, error)
|
||||
|
||||
// Loader is a function that loads a byte stream and creates a driver.
|
||||
type Loader func() drivers.Driver
|
||||
|
|
|
@ -64,7 +64,7 @@ func (m *clusterInspector) getStateAndRoute() (HostState, *Route, error) {
|
|||
if err != nil {
|
||||
return hostState, nil, err
|
||||
}
|
||||
var c *config.MachineConfig
|
||||
var c *config.ClusterConfig
|
||||
c, err = m.configLoader.LoadConfigFromFile(m.machineName)
|
||||
if err != nil {
|
||||
err = errors.Wrapf(err, "error loading config for %s", m.machineName)
|
||||
|
@ -80,7 +80,7 @@ func (m *clusterInspector) getStateAndRoute() (HostState, *Route, error) {
|
|||
return hostState, route, nil
|
||||
}
|
||||
|
||||
func getRoute(host *host.Host, clusterConfig config.MachineConfig) (*Route, error) {
|
||||
func getRoute(host *host.Host, clusterConfig config.ClusterConfig) (*Route, error) {
|
||||
hostDriverIP, err := host.Driver.GetIP()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error getting host IP for %s", host.Name)
|
||||
|
|
|
@ -66,7 +66,7 @@ func TestMinikubeCheckReturnsHostInformation(t *testing.T) {
|
|||
}
|
||||
|
||||
configLoader := &stubConfigLoader{
|
||||
c: &config.MachineConfig{
|
||||
c: &config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
ServiceCIDR: "96.0.0.0/12",
|
||||
},
|
||||
|
@ -104,7 +104,7 @@ func TestMinikubeCheckReturnsHostInformation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnparseableCIDR(t *testing.T) {
|
||||
cfg := config.MachineConfig{
|
||||
cfg := config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
ServiceCIDR: "bad.cidr.0.0/12",
|
||||
}}
|
||||
|
@ -124,7 +124,7 @@ func TestUnparseableCIDR(t *testing.T) {
|
|||
func TestRouteIPDetection(t *testing.T) {
|
||||
expectedTargetCIDR := "10.96.0.0/12"
|
||||
|
||||
cfg := config.MachineConfig{
|
||||
cfg := config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
ServiceCIDR: expectedTargetCIDR,
|
||||
},
|
||||
|
|
|
@ -82,14 +82,14 @@ func (r *fakeRouter) Inspect(route *Route) (exists bool, conflict string, overla
|
|||
}
|
||||
|
||||
type stubConfigLoader struct {
|
||||
c *config.MachineConfig
|
||||
c *config.ClusterConfig
|
||||
e error
|
||||
}
|
||||
|
||||
func (l *stubConfigLoader) WriteConfigToFile(profileName string, cc *config.MachineConfig, miniHome ...string) error {
|
||||
func (l *stubConfigLoader) WriteConfigToFile(profileName string, cc *config.ClusterConfig, miniHome ...string) error {
|
||||
return l.e
|
||||
}
|
||||
|
||||
func (l *stubConfigLoader) LoadConfigFromFile(profile string, miniHome ...string) (*config.MachineConfig, error) {
|
||||
func (l *stubConfigLoader) LoadConfigFromFile(profile string, miniHome ...string) (*config.ClusterConfig, error) {
|
||||
return l.c, l.e
|
||||
}
|
||||
|
|
|
@ -423,7 +423,7 @@ func TestTunnel(t *testing.T) {
|
|||
},
|
||||
}
|
||||
configLoader := &stubConfigLoader{
|
||||
c: &config.MachineConfig{
|
||||
c: &config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
ServiceCIDR: tc.serviceCIDR,
|
||||
}},
|
||||
|
@ -478,7 +478,7 @@ func TestErrorCreatingTunnel(t *testing.T) {
|
|||
}
|
||||
|
||||
configLoader := &stubConfigLoader{
|
||||
c: &config.MachineConfig{
|
||||
c: &config.ClusterConfig{
|
||||
KubernetesConfig: config.KubernetesConfig{
|
||||
ServiceCIDR: "10.96.0.0/12",
|
||||
}},
|
||||
|
|
|
@ -85,7 +85,7 @@ func init() {
|
|||
})
|
||||
}
|
||||
|
||||
func createVMwareFusionHost(config cfg.MachineConfig) interface{} {
|
||||
func createVMwareFusionHost(config cfg.ClusterConfig) interface{} {
|
||||
d := vmwarefusion.NewDriver(config.Name, localpath.MiniPath()).(*vmwarefusion.Driver)
|
||||
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
|
||||
d.Memory = config.Memory
|
||||
|
|
Loading…
Reference in New Issue