Commit 8c55c9ca authored by Sharif Elgamal's avatar Sharif Elgamal

holy crap cyclical import hell sucks

parent b427dc56
......@@ -26,7 +26,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/cluster"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
......@@ -69,7 +68,7 @@ var addonsOpenCmd = &cobra.Command{
defer api.Close()
profileName := viper.GetString(pkg_config.MachineProfile)
if !cluster.IsHostRunning(api, profileName) {
if !machine.IsHostRunning(api, profileName) {
os.Exit(1)
}
addon, ok := assets.Addons[addonName] // validate addon input
......
......@@ -23,7 +23,6 @@ import (
"strconv"
"strings"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
......@@ -76,7 +75,7 @@ var printProfilesTable = func() {
defer api.Close()
for _, p := range validProfiles {
p.Status, err = cluster.GetHostStatus(api, p.Name)
p.Status, err = machine.GetHostStatus(api, p.Name)
if err != nil {
glog.Warningf("error getting host status for %s: %v", p.Name, err)
}
......@@ -118,7 +117,7 @@ var printProfilesJSON = func() {
validProfiles, invalidProfiles, err := config.ListProfiles()
for _, v := range validProfiles {
status, err := cluster.GetHostStatus(api, v.Name)
status, err := machine.GetHostStatus(api, v.Name)
if err != nil {
glog.Warningf("error getting host status for %s: %v", v.Name, err)
}
......
......@@ -35,7 +35,6 @@ import (
"github.com/spf13/viper"
pkgaddons "k8s.io/minikube/pkg/addons"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/cluster"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
......@@ -102,7 +101,7 @@ var dashboardCmd = &cobra.Command{
exit.WithCodeT(exit.NoInput, "kubectl not found in PATH, but is required for the dashboard. Installation guide: https://kubernetes.io/docs/tasks/tools/install-kubectl/")
}
if !cluster.IsHostRunning(api, profileName) {
if !machine.IsHostRunning(api, profileName) {
os.Exit(1)
}
......
......@@ -42,7 +42,6 @@ import (
"k8s.io/minikube/pkg/minikube/kubeconfig"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
)
......@@ -207,7 +206,7 @@ func deleteProfile(profile *pkg_config.Profile) error {
out.T(out.FailureType, "Failed to kill mount process: {{.error}}", out.V{"error": err})
}
if err = cluster.DeleteHost(api, profile.Name); err != nil {
if err = machine.DeleteHost(api, profile.Name); err != nil {
switch errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
glog.Infof("%s cluster does not exist. Proceeding ahead with cleanup.", profile.Name)
......@@ -275,12 +274,12 @@ func profileDeletionErr(profileName string, additionalInfo string) error {
func uninstallKubernetes(api libmachine.API, profile string, kc pkg_config.KubernetesConfig, bsName string) error {
out.T(out.Resetting, "Uninstalling Kubernetes {{.kubernetes_version}} using {{.bootstrapper_name}} ...", out.V{"kubernetes_version": kc.KubernetesVersion, "bootstrapper_name": bsName})
clusterBootstrapper, err := node.Bootstrapper(api, bsName)
clusterBootstrapper, err := cluster.Bootstrapper(api, bsName)
if err != nil {
return DeletionError{Err: fmt.Errorf("unable to get bootstrapper: %v", err), Errtype: Fatal}
}
host, err := cluster.CheckIfHostExistsAndLoad(api, profile)
host, err := machine.CheckIfHostExistsAndLoad(api, profile)
if err != nil {
exit.WithError("Error getting host", err)
}
......
......@@ -34,7 +34,6 @@ import (
"github.com/spf13/viper"
"k8s.io/minikube/pkg/drivers/kic"
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/driver"
......@@ -151,7 +150,7 @@ var dockerEnvCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.Name)
host, err := machine.CheckIfHostExistsAndLoad(api, cc.Name)
if err != nil {
exit.WithError("Error getting host", err)
}
......@@ -159,7 +158,7 @@ var dockerEnvCmd = &cobra.Command{
exit.UsageT(`'none' driver does not support 'minikube docker-env' command`)
}
hostSt, err := cluster.GetHostStatus(api, cc.Name)
hostSt, err := machine.GetHostStatus(api, cc.Name)
if err != nil {
exit.WithError("Error getting host status", err)
}
......
......@@ -20,12 +20,12 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/logs"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/node"
)
const (
......@@ -67,7 +67,7 @@ var logsCmd = &cobra.Command{
if err != nil {
exit.WithError("command runner", err)
}
bs, err := node.Bootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
bs, err := cluster.Bootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
if err != nil {
exit.WithError("Error getting cluster bootstrapper", err)
}
......
......@@ -54,7 +54,7 @@ var nodeAddCmd = &cobra.Command{
exit.WithError("Error adding node to cluster", err)
}
_, err = node.Start(mc, n, false, nil)
_, err = node.Start(*mc, *n, false, nil)
if err != nil {
exit.WithError("Error starting node", err)
}
......
......@@ -44,7 +44,7 @@ var nodeDeleteCmd = &cobra.Command{
exit.WithError("loading config", err)
}
err = node.Delete(cc, name)
err = node.Delete(*cc, name)
if err != nil {
out.FatalT("Failed to delete node {{.name}}", out.V{"name": name})
}
......
......@@ -21,7 +21,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
......@@ -46,7 +45,7 @@ var nodeStartCmd = &cobra.Command{
exit.WithError("creating api client", err)
}
if cluster.IsHostRunning(api, name) {
if machine.IsHostRunning(api, name) {
out.T(out.Check, "{{.name}} is already running", out.V{"name": name})
os.Exit(0)
}
......@@ -62,7 +61,7 @@ var nodeStartCmd = &cobra.Command{
}
// Start it up baby
_, err = node.Start(cc, n, false, nil)
_, err = node.Start(*cc, *n, false, nil)
if err != nil {
out.FatalT("Failed to start node {{.name}}", out.V{"name": name})
}
......
......@@ -18,7 +18,6 @@ package cmd
import (
"github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/out"
......@@ -40,7 +39,7 @@ var nodeStopCmd = &cobra.Command{
exit.WithError("creating api client", err)
}
err = cluster.StopHost(api, name)
err = machine.StopHost(api, name)
if err != nil {
out.FatalT("Failed to stop node {{.name}}", out.V{"name": name})
}
......
......@@ -63,7 +63,7 @@ func runPause(cmd *cobra.Command, args []string) {
}
glog.Infof("config: %+v", cc)
host, err := cluster.CheckIfHostExistsAndLoad(api, cname)
host, err := machine.CheckIfHostExistsAndLoad(api, cname)
if err != nil {
exit.WithError("Error getting host", err)
}
......
......@@ -32,7 +32,6 @@ import (
"github.com/docker/machine/libmachine/state"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/driver"
......@@ -120,7 +119,7 @@ var podmanEnvCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.Name)
host, err := machine.CheckIfHostExistsAndLoad(api, cc.Name)
if err != nil {
exit.WithError("Error getting host", err)
}
......@@ -128,7 +127,7 @@ var podmanEnvCmd = &cobra.Command{
exit.UsageT(`'none' driver does not support 'minikube podman-env' command`)
}
hostSt, err := cluster.GetHostStatus(api, cc.Name)
hostSt, err := machine.GetHostStatus(api, cc.Name)
if err != nil {
exit.WithError("Error getting host status", err)
}
......
......@@ -27,7 +27,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/machine"
......@@ -74,7 +73,7 @@ var serviceCmd = &cobra.Command{
defer api.Close()
profileName := viper.GetString(pkg_config.MachineProfile)
if !cluster.IsHostRunning(api, profileName) {
if !machine.IsHostRunning(api, profileName) {
os.Exit(1)
}
......
......@@ -23,7 +23,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
......@@ -46,7 +45,7 @@ var sshCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.Name)
host, err := machine.CheckIfHostExistsAndLoad(api, cc.Name)
if err != nil {
exit.WithError("Error getting host", err)
}
......@@ -59,7 +58,7 @@ var sshCmd = &cobra.Command{
ssh.SetDefaultClient(ssh.External)
}
err = cluster.CreateSSHShell(api, args)
err = machine.CreateSSHShell(api, args)
if err != nil {
// This is typically due to a non-zero exit code, so no need for flourish.
out.ErrLn("ssh: %v", err)
......
......@@ -332,7 +332,7 @@ func runStart(cmd *cobra.Command, args []string) {
if existing != nil && existing.Addons != nil {
existingAddons = existing.Addons
}
kubeconfig, err := node.Start(&mc, &n, true, existingAddons)
kubeconfig, err := node.Start(mc, n, true, existingAddons)
if err != nil {
exit.WithError("Starting node", err)
}
......
......@@ -137,7 +137,7 @@ func status(api libmachine.API, name string) (*Status, error) {
Kubeconfig: Nonexistent,
}
hs, err := cluster.GetHostStatus(api, name)
hs, err := machine.GetHostStatus(api, name)
glog.Infof("%s host status = %q (err=%v)", name, hs, err)
if err != nil {
return st, errors.Wrap(err, "host")
......@@ -179,7 +179,7 @@ func status(api libmachine.API, name string) (*Status, error) {
st.Kubeconfig = Configured
}
host, err := cluster.CheckIfHostExistsAndLoad(api, name)
host, err := machine.CheckIfHostExistsAndLoad(api, name)
if err != nil {
return st, err
}
......
......@@ -24,7 +24,6 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
pkg_config "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/kubeconfig"
......@@ -53,7 +52,7 @@ func runStop(cmd *cobra.Command, args []string) {
nonexistent := false
stop := func() (err error) {
err = cluster.StopHost(api, profile)
err = machine.StopHost(api, profile)
if err == nil {
return nil
}
......
......@@ -54,7 +54,7 @@ var unpauseCmd = &cobra.Command{
os.Exit(1)
}
glog.Infof("config: %+v", cc)
host, err := cluster.CheckIfHostExistsAndLoad(api, cname)
host, err := machine.CheckIfHostExistsAndLoad(api, cname)
if err != nil {
exit.WithError("Error getting host", err)
}
......
......@@ -28,7 +28,6 @@ import (
"github.com/pkg/errors"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit"
......@@ -143,8 +142,8 @@ func enableOrDisableAddon(name, val, profile string) error {
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
}
host, err := cluster.CheckIfHostExistsAndLoad(api, profile)
if err != nil || !cluster.IsHostRunning(api, profile) {
host, err := machine.CheckIfHostExistsAndLoad(api, profile)
if err != nil || !machine.IsHostRunning(api, profile) {
glog.Warningf("%q is not running, writing %s=%v to disk and skipping enablement (err=%v)", profile, addon.Name(), enable, err)
return nil
}
......@@ -244,7 +243,7 @@ func enableOrDisableStorageClasses(name, val, profile string) error {
}
defer api.Close()
if !cluster.IsHostRunning(api, profile) {
if !machine.IsHostRunning(api, profile) {
glog.Warningf("%q is not running, writing %s=%v to disk and skipping enablement", profile, name, val)
return enableOrDisableAddon(name, val, profile)
}
......
......@@ -18,9 +18,14 @@ package cluster
import (
"flag"
"fmt"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/ssh"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
"k8s.io/minikube/pkg/minikube/exit"
)
......@@ -35,3 +40,19 @@ func init() {
// Setting the default client to native gives much better performance.
ssh.SetDefaultClient(ssh.Native)
}
// Bootstrapper returns a new bootstrapper for the cluster
func Bootstrapper(api libmachine.API, bootstrapperName string) (bootstrapper.Bootstrapper, error) {
var b bootstrapper.Bootstrapper
var err error
switch bootstrapperName {
case bootstrapper.Kubeadm:
b, err = kubeadm.NewBootstrapper(api)
if err != nil {
return nil, errors.Wrap(err, "getting a new kubeadm bootstrapper")
}
default:
return nil, fmt.Errorf("unknown bootstrapper: %s", bootstrapperName)
}
return b, nil
}
......@@ -27,6 +27,7 @@ import (
"github.com/pkg/errors"
"k8s.io/minikube/pkg/drivers/kic"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/machine"
)
// GetVMHostIP gets the ip address to be used for mapping host -> VM and VM -> host
......@@ -74,7 +75,7 @@ func GetVMHostIP(host *host.Host) (net.IP, error) {
// GetHostDriverIP gets the ip address of the current minikube cluster
func GetHostDriverIP(api libmachine.API, machineName string) (net.IP, error) {
host, err := CheckIfHostExistsAndLoad(api, machineName)
host, err := machine.CheckIfHostExistsAndLoad(api, machineName)
if err != nil {
return nil, err
}
......
/*
Copyright 2020 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/state"
"github.com/pkg/errors"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config"
)
// CreateSSHShell creates a new SSH shell / client
func CreateSSHShell(api libmachine.API, args []string) error {
machineName := viper.GetString(config.MachineProfile)
host, err := CheckIfHostExistsAndLoad(api, machineName)
if err != nil {
return errors.Wrap(err, "host exists and load")
}
currentState, err := host.Driver.GetState()
if err != nil {
return errors.Wrap(err, "state")
}
if currentState != state.Running {
return errors.Errorf("%q is not running", machineName)
}
client, err := host.CreateSSHClient()
if err != nil {
return errors.Wrap(err, "Creating ssh client")
}
return client.Shell(args...)
}
......@@ -31,7 +31,6 @@ import (
"golang.org/x/sync/errgroup"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
......@@ -139,7 +138,7 @@ func CacheAndLoadImages(images []string) error {
}
for _, p := range profiles { // loading images to all running profiles
pName := p.Name // capture the loop variable
status, err := cluster.GetHostStatus(api, pName)
status, err := GetHostStatus(api, pName)
if err != nil {
glog.Warningf("skipping loading cache for profile %s", pName)
glog.Errorf("error getting status for %s: %v", pName, err)
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"fmt"
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"os/exec"
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"fmt"
......@@ -62,7 +62,7 @@ func localAssets() ([]assets.CopyableFile, error) {
return fs, nil
}
// assetsFromDir generates assets from a local filepath, with/without a flattened hierarchy
// AssetsFromDir generates assets from a local filepath, with/without a flattened hierarchy
func assetsFromDir(localRoot string, destRoot string, flatten bool) ([]assets.CopyableFile, error) {
glog.Infof("Scanning %s for local assets ...", localRoot)
fs := []assets.CopyableFile{}
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"io/ioutil"
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"fmt"
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"io/ioutil"
......@@ -25,8 +25,6 @@ import (
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/mem"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/out"
)
......@@ -97,22 +95,3 @@ func logRemoteOsRelease(drv drivers.Driver) {
glog.Infof("Provisioned with %s", osReleaseInfo.PrettyName)
}
// showHostInfo shows host information
func showHostInfo(cfg config.MachineConfig) {
if driver.BareMetal(cfg.Driver) {
info, err := getHostInfo()
if err == nil {
out.T(out.StartingNone, "Running on localhost (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) ...", out.V{"number_of_cpus": info.CPUs, "memory_size": info.Memory, "disk_size": info.DiskSize})
}
return
}
if driver.IsKIC(cfg.Driver) {
info, err := getHostInfo() // TODO medyagh: get docker-machine info for non linux
if err == nil {
out.T(out.StartingVM, "Creating Kubernetes in {{.driver_name}} container with (CPUs={{.number_of_cpus}}), Memory={{.memory_size}}MB ({{.host_memory_size}}MB available) ...", out.V{"driver_name": cfg.Driver, "number_of_cpus": cfg.CPUs, "number_of_host_cpus": info.CPUs, "memory_size": cfg.Memory, "host_memory_size": info.Memory})
}
return
}
out.T(out.StartingVM, "Creating {{.driver_name}} VM (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) ...", out.V{"driver_name": cfg.Driver, "number_of_cpus": cfg.CPUs, "memory_size": cfg.Memory, "disk_size": cfg.DiskSize})
}
......@@ -20,10 +20,13 @@ import (
"io/ioutil"
"path/filepath"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/state"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/cluster"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/localpath"
)
......@@ -90,7 +93,7 @@ func Load(name string) (*Machine, error) {
return nil, err
}
h, err := cluster.CheckIfHostExistsAndLoad(api, name)
h, err := CheckIfHostExistsAndLoad(api, name)
if err != nil {
return nil, err
}
......@@ -119,3 +122,27 @@ func machineDirs(miniHome ...string) (dirs []string, err error) {
}
return dirs, err
}
// CreateSSHShell creates a new SSH shell / client
func CreateSSHShell(api libmachine.API, args []string) error {
machineName := viper.GetString(config.MachineProfile)
host, err := CheckIfHostExistsAndLoad(api, machineName)
if err != nil {
return errors.Wrap(err, "host exists and load")
}
currentState, err := host.Driver.GetState()
if err != nil {
return errors.Wrap(err, "state")
}
if currentState != state.Running {
return errors.Errorf("%q is not running", machineName)
}
client, err := host.CreateSSHClient()
if err != nil {
return errors.Wrap(err, "Creating ssh client")
}
return client.Shell(args...)
}
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"encoding/json"
......@@ -223,3 +223,22 @@ func acquireMachinesLock(name string) (mutex.Releaser, error) {
}
return r, err
}
// showHostInfo shows host information
func showHostInfo(cfg config.MachineConfig) {
if driver.BareMetal(cfg.Driver) {
info, err := getHostInfo()
if err == nil {
out.T(out.StartingNone, "Running on localhost (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) ...", out.V{"number_of_cpus": info.CPUs, "memory_size": info.Memory, "disk_size": info.DiskSize})
}
return
}
if driver.IsKIC(cfg.Driver) {
info, err := getHostInfo() // TODO medyagh: get docker-machine info for non linux
if err == nil {
out.T(out.StartingVM, "Creating Kubernetes in {{.driver_name}} container with (CPUs={{.number_of_cpus}}), Memory={{.memory_size}}MB ({{.host_memory_size}}MB available) ...", out.V{"driver_name": cfg.Driver, "number_of_cpus": cfg.CPUs, "number_of_host_cpus": info.CPUs, "memory_size": cfg.Memory, "host_memory_size": info.Memory})
}
return
}
out.T(out.StartingVM, "Creating {{.driver_name}} VM (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) ...", out.V{"driver_name": cfg.Driver, "number_of_cpus": cfg.CPUs, "memory_size": cfg.Memory, "disk_size": cfg.DiskSize})
}
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"github.com/docker/machine/libmachine"
......
......@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cluster
package machine
import (
"github.com/docker/machine/libmachine"
......
......@@ -27,12 +27,10 @@ import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/spf13/viper"
cmdcfg "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
......@@ -40,7 +38,6 @@ import (
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/kubeconfig"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/logs"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/util/lock"
)
......@@ -85,7 +82,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 {
bs, err := Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper))
bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper))
if err != nil {
exit.WithError("Failed to get bootstrapper", err)
}
......@@ -132,30 +129,6 @@ func setupKubeconfig(h *host.Host, c *config.MachineConfig, n *config.Node, clus
return kcs, nil
}
// Bootstrapper returns a new bootstrapper for the node
func Bootstrapper(api libmachine.API, bootstrapperName string) (bootstrapper.Bootstrapper, error) {
var b bootstrapper.Bootstrapper