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