未验证 提交 c03aee83 编写于 作者: S Sharif Elgamal 提交者: GitHub

Refactor config.Config to prepare for multinode (#5889)

* Refactor config.Config to prepare for multinode

* merge conflict
上级 fb5430fd
......@@ -82,7 +82,7 @@ var ProfileCmd = &cobra.Command{
out.ErrT(out.Sad, `Error loading profile config: {{.error}}`, out.V{"error": err})
}
if err == nil {
if cc.MachineConfig.KeepContext {
if cc.KeepContext {
out.SuccessT("Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.", out.V{"profile_name": profile})
out.SuccessT("To connect to this cluster, use: kubectl --context={{.profile_name}}", out.V{"profile_name": profile})
} else {
......
......@@ -68,7 +68,7 @@ var printProfilesTable = func() {
exit.UsageT("No minikube profile was found. You can create one using `minikube start`.")
}
for _, p := range validProfiles {
validData = append(validData, []string{p.Name, p.Config.MachineConfig.VMDriver, p.Config.KubernetesConfig.NodeIP, strconv.Itoa(p.Config.KubernetesConfig.NodePort), p.Config.KubernetesConfig.KubernetesVersion})
validData = append(validData, []string{p.Name, p.Config[0].VMDriver, p.Config[0].KubernetesConfig.NodeIP, strconv.Itoa(p.Config[0].KubernetesConfig.NodePort), p.Config[0].KubernetesConfig.KubernetesVersion})
}
table.AppendBulk(validData)
......
......@@ -142,7 +142,7 @@ func EnableOrDisableAddon(name string, val string) error {
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
}
host, err := cluster.CheckIfHostExistsAndLoad(api, cfg.MachineConfig.Name)
host, err := cluster.CheckIfHostExistsAndLoad(api, cfg.Name)
if err != nil {
return errors.Wrap(err, "getting host")
}
......
......@@ -74,10 +74,10 @@ var dashboardCmd = &cobra.Command{
exit.WithError("Error getting client", err)
}
if _, err = api.Load(cc.MachineConfig.Name); err != nil {
if _, err = api.Load(cc.Name); err != nil {
switch err := errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
exit.WithCodeT(exit.Unavailable, "{{.name}} cluster does not exist", out.V{"name": cc.MachineConfig.Name})
exit.WithCodeT(exit.Unavailable, "{{.name}} cluster does not exist", out.V{"name": cc.Name})
default:
exit.WithError("Error getting cluster", err)
}
......@@ -119,7 +119,7 @@ var dashboardCmd = &cobra.Command{
}
out.ErrT(out.Launch, "Launching proxy ...")
p, hostPort, err := kubectlProxy(kubectl, cc.MachineConfig.Name)
p, hostPort, err := kubectlProxy(kubectl, cc.Name)
if err != nil {
exit.WithError("kubectl proxy", err)
}
......
......@@ -194,7 +194,7 @@ func deleteProfile(profile *pkg_config.Profile) error {
return DeletionError{Err: delErr, Errtype: MissingProfile}
}
if err == nil && driver.BareMetal(cc.MachineConfig.VMDriver) {
if err == nil && driver.BareMetal(cc.VMDriver) {
if err := uninstallKubernetes(api, cc.KubernetesConfig, viper.GetString(cmdcfg.Bootstrapper)); err != nil {
deletionError, ok := err.(DeletionError)
if ok {
......
......@@ -344,14 +344,14 @@ var dockerEnvCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.MachineConfig.Name)
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.Name)
if err != nil {
exit.WithError("Error getting host", err)
}
if host.Driver.DriverName() == driver.None {
exit.UsageT(`'none' driver does not support 'minikube docker-env' command`)
}
hostSt, err := cluster.GetHostStatus(api, cc.MachineConfig.Name)
hostSt, err := cluster.GetHostStatus(api, cc.Name)
if err != nil {
exit.WithError("Error getting host status", err)
}
......
......@@ -42,11 +42,11 @@ var ipCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := api.Load(cc.MachineConfig.Name)
host, err := api.Load(cc.Name)
if err != nil {
switch err := errors.Cause(err).(type) {
case mcnerror.ErrHostDoesNotExist:
exit.WithCodeT(exit.NoInput, `"{{.profile_name}}" host does not exist, unable to show an IP`, out.V{"profile_name": cc.MachineConfig.Name})
exit.WithCodeT(exit.NoInput, `"{{.profile_name}}" host does not exist, unable to show an IP`, out.V{"profile_name": cc.Name})
default:
exit.WithError("Error getting host", err)
}
......
......@@ -58,7 +58,7 @@ var logsCmd = &cobra.Command{
}
defer api.Close()
h, err := api.Load(cfg.MachineConfig.Name)
h, err := api.Load(cfg.Name)
if err != nil {
exit.WithError("api load", err)
}
......
......@@ -106,7 +106,7 @@ var mountCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := api.Load(cc.MachineConfig.Name)
host, err := api.Load(cc.Name)
if err != nil {
exit.WithError("Error loading api", err)
......
......@@ -36,6 +36,6 @@ var sshKeyCmd = &cobra.Command{
if err != nil {
exit.WithError("Getting machine config failed", err)
}
out.Ln(filepath.Join(localpath.MiniPath(), "machines", cc.MachineConfig.Name, "id_rsa"))
out.Ln(filepath.Join(localpath.MiniPath(), "machines", cc.Name, "id_rsa"))
},
}
......@@ -46,7 +46,7 @@ var sshCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.MachineConfig.Name)
host, err := cluster.CheckIfHostExistsAndLoad(api, cc.Name)
if err != nil {
exit.WithError("Error getting host", err)
}
......
......@@ -311,7 +311,7 @@ func runStart(cmd *cobra.Command, args []string) {
}
if !driver.BareMetal(driverName) {
if err := cluster.CacheISO(config.MachineConfig); err != nil {
if err := cluster.CacheISO(config); err != nil {
exit.WithError("Failed to cache ISO", err)
}
}
......@@ -342,7 +342,7 @@ func runStart(cmd *cobra.Command, args []string) {
waitCacheImages(&cacheGroup)
// Must be written before bootstrap, otherwise health checks may flake due to stale IP
kubeconfig, err := setupKubeconfig(host, &config)
kubeconfig, err := setupKubeconfig(host, &config, config.Name)
if err != nil {
exit.WithError("Failed to setup kubeconfig", err)
}
......@@ -366,7 +366,7 @@ func runStart(cmd *cobra.Command, args []string) {
prepareNone()
}
waitCluster(bs, config)
if err := showKubectlInfo(kubeconfig, k8sVersion, config.MachineConfig.Name); err != nil {
if err := showKubectlInfo(kubeconfig, k8sVersion, config.Name); err != nil {
glog.Errorf("kubectl info: %v", err)
}
}
......@@ -389,7 +389,7 @@ func enableAddons() {
}
}
func waitCluster(bs bootstrapper.Bootstrapper, config cfg.Config) {
func waitCluster(bs bootstrapper.Bootstrapper, config cfg.MachineConfig) {
var podsToWaitFor []string
if !viper.GetBool(waitUntilHealthy) {
......@@ -427,7 +427,7 @@ func displayEnviron(env []string) {
}
}
func setupKubeconfig(h *host.Host, c *cfg.Config) (*kubeconfig.Settings, error) {
func setupKubeconfig(h *host.Host, c *cfg.MachineConfig, clusterName string) (*kubeconfig.Settings, error) {
addr, err := h.Driver.GetURL()
if err != nil {
exit.WithError("Failed to get driver URL", err)
......@@ -439,7 +439,7 @@ func setupKubeconfig(h *host.Host, c *cfg.Config) (*kubeconfig.Settings, error)
}
kcs := &kubeconfig.Settings{
ClusterName: c.MachineConfig.Name,
ClusterName: clusterName,
ClusterServerAddress: addr,
ClientCertificate: localpath.MakeMiniPath("client.crt"),
ClientKey: localpath.MakeMiniPath("client.key"),
......@@ -472,12 +472,12 @@ func handleDownloadOnly(cacheGroup *errgroup.Group, k8sVersion string) {
}
func startMachine(config *cfg.Config) (runner command.Runner, preExists bool, machineAPI libmachine.API, host *host.Host) {
func startMachine(config *cfg.MachineConfig) (runner command.Runner, preExists bool, machineAPI libmachine.API, host *host.Host) {
m, err := machine.NewAPIClient()
if err != nil {
exit.WithError("Failed to get machine client", err)
}
host, preExists = startHost(m, config.MachineConfig)
host, preExists = startHost(m, *config)
runner, err = machine.CommandRunner(host)
if err != nil {
exit.WithError("Failed to get command runner", err)
......@@ -553,8 +553,7 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName st
return nil
}
// selectDriver returns which driver to choose based on flags, existing configs, and hypervisor detection
func selectDriver(existing *cfg.Config) string {
func selectDriver(existing *cfg.MachineConfig) string {
name := viper.GetString("vm-driver")
glog.Infof("selectDriver: flag=%q, old=%v", name, existing)
options := driver.Choices()
......@@ -567,8 +566,8 @@ func selectDriver(existing *cfg.Config) string {
// By default, the driver is whatever we used last time
if existing != nil {
pick, alts := driver.Choose(existing.MachineConfig.VMDriver, options)
out.T(out.Sparkle, `Selecting '{{.driver}}' driver from existing profile (alternates: {{.alternates}})`, out.V{"driver": existing.MachineConfig.VMDriver, "alternates": alts})
pick, alts := driver.Choose(existing.VMDriver, options)
out.T(out.Sparkle, `Selecting '{{.driver}}' driver from existing profile (alternates: {{.alternates}})`, out.V{"driver": existing.VMDriver, "alternates": alts})
return pick.Name
}
......@@ -585,7 +584,7 @@ func selectDriver(existing *cfg.Config) string {
}
// validateDriver validates that the selected driver appears sane, exits if not
func validateDriver(name string, existing *cfg.Config) {
func validateDriver(name string, existing *cfg.MachineConfig) {
glog.Infof("validating driver %q against %+v", name, existing)
if !driver.Supported(name) {
exit.WithCodeT(exit.Unavailable, "The driver '{{.driver}}' is not supported on {{.os}}", out.V{"driver": name, "os": runtime.GOOS})
......@@ -605,7 +604,7 @@ func validateDriver(name string, existing *cfg.Config) {
out.ErrLn("")
if !st.Installed && !viper.GetBool(force) {
if existing != nil && name == existing.MachineConfig.VMDriver {
if existing != nil && name == existing.VMDriver {
exit.WithCodeT(exit.Unavailable, "{{.driver}} does not appear to be installed, but is specified by an existing profile. Please run 'minikube delete' or install {{.driver}}", out.V{"driver": name})
}
exit.WithCodeT(exit.Unavailable, "{{.driver}} does not appear to be installed", out.V{"driver": name})
......@@ -845,10 +844,10 @@ func waitCacheImages(g *errgroup.Group) {
}
// generateCfgFromFlags generates cfg.Config based on flags and supplied arguments
func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string) (cfg.Config, error) {
func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string) (cfg.MachineConfig, error) {
r, err := cruntime.New(cruntime.Config{Type: viper.GetString(containerRuntime)})
if err != nil {
return cfg.Config{}, err
return cfg.MachineConfig{}, err
}
// Pick good default values for --network-plugin and --enable-default-cni based on runtime.
......@@ -889,38 +888,36 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string)
out.T(out.SuccessType, "Using image repository {{.name}}", out.V{"name": repository})
}
cfg := cfg.Config{
MachineConfig: cfg.MachineConfig{
Name: viper.GetString(cfg.MachineProfile),
KeepContext: viper.GetBool(keepContext),
EmbedCerts: viper.GetBool(embedCerts),
MinikubeISO: viper.GetString(isoURL),
Memory: pkgutil.CalculateSizeInMB(viper.GetString(memory)),
CPUs: viper.GetInt(cpus),
DiskSize: pkgutil.CalculateSizeInMB(viper.GetString(humanReadableDiskSize)),
VMDriver: drvName,
ContainerRuntime: viper.GetString(containerRuntime),
HyperkitVpnKitSock: viper.GetString(vpnkitSock),
HyperkitVSockPorts: viper.GetStringSlice(vsockPorts),
NFSShare: viper.GetStringSlice(nfsShare),
NFSSharesRoot: viper.GetString(nfsSharesRoot),
DockerEnv: dockerEnv,
DockerOpt: dockerOpt,
InsecureRegistry: insecureRegistry,
RegistryMirror: registryMirror,
HostOnlyCIDR: viper.GetString(hostOnlyCIDR),
HypervVirtualSwitch: viper.GetString(hypervVirtualSwitch),
KVMNetwork: viper.GetString(kvmNetwork),
KVMQemuURI: viper.GetString(kvmQemuURI),
KVMGPU: viper.GetBool(kvmGPU),
KVMHidden: viper.GetBool(kvmHidden),
Downloader: pkgutil.DefaultDownloader{},
DisableDriverMounts: viper.GetBool(disableDriverMounts),
UUID: viper.GetString(uuid),
NoVTXCheck: viper.GetBool(noVTXCheck),
DNSProxy: viper.GetBool(dnsProxy),
HostDNSResolver: viper.GetBool(hostDNSResolver),
},
cfg := cfg.MachineConfig{
Name: viper.GetString(cfg.MachineProfile),
KeepContext: viper.GetBool(keepContext),
EmbedCerts: viper.GetBool(embedCerts),
MinikubeISO: viper.GetString(isoURL),
Memory: pkgutil.CalculateSizeInMB(viper.GetString(memory)),
CPUs: viper.GetInt(cpus),
DiskSize: pkgutil.CalculateSizeInMB(viper.GetString(humanReadableDiskSize)),
VMDriver: drvName,
ContainerRuntime: viper.GetString(containerRuntime),
HyperkitVpnKitSock: viper.GetString(vpnkitSock),
HyperkitVSockPorts: viper.GetStringSlice(vsockPorts),
NFSShare: viper.GetStringSlice(nfsShare),
NFSSharesRoot: viper.GetString(nfsSharesRoot),
DockerEnv: dockerEnv,
DockerOpt: dockerOpt,
InsecureRegistry: insecureRegistry,
RegistryMirror: registryMirror,
HostOnlyCIDR: viper.GetString(hostOnlyCIDR),
HypervVirtualSwitch: viper.GetString(hypervVirtualSwitch),
KVMNetwork: viper.GetString(kvmNetwork),
KVMQemuURI: viper.GetString(kvmQemuURI),
KVMGPU: viper.GetBool(kvmGPU),
KVMHidden: viper.GetBool(kvmHidden),
Downloader: pkgutil.DefaultDownloader{},
DisableDriverMounts: viper.GetBool(disableDriverMounts),
UUID: viper.GetString(uuid),
NoVTXCheck: viper.GetBool(noVTXCheck),
DNSProxy: viper.GetBool(dnsProxy),
HostDNSResolver: viper.GetBool(hostDNSResolver),
KubernetesConfig: cfg.KubernetesConfig{
KubernetesVersion: k8sVersion,
NodePort: viper.GetInt(apiServerPort),
......@@ -1112,7 +1109,7 @@ func tryRegistry(r command.Runner) {
}
// getKubernetesVersion ensures that the requested version is reasonable
func getKubernetesVersion(old *cfg.Config) (string, bool) {
func getKubernetesVersion(old *cfg.MachineConfig) (string, bool) {
rawVersion := viper.GetString(kubernetesVersion)
isUpgrade := false
if rawVersion == "" {
......@@ -1151,8 +1148,8 @@ func getKubernetesVersion(old *cfg.Config) (string, bool) {
if nvs.LT(ovs) {
nv = version.VersionPrefix + ovs.String()
profileArg := ""
if old.MachineConfig.Name != constants.DefaultMachineName {
profileArg = fmt.Sprintf("-p %s", old.MachineConfig.Name)
if old.Name != constants.DefaultMachineName {
profileArg = fmt.Sprintf("-p %s", old.Name)
}
exit.WithCodeT(exit.Config, `Error: You have selected Kubernetes v{{.new}}, but the existing cluster for your profile is running Kubernetes v{{.old}}. Non-destructive downgrades are not supported, but you can proceed by performing one of the following options:
......@@ -1260,6 +1257,6 @@ func configureMounts() {
}
// saveConfig saves profile cluster configuration in $MINIKUBE_HOME/profiles/<profilename>/config.json
func saveConfig(clusterCfg *cfg.Config) error {
func saveConfig(clusterCfg *cfg.MachineConfig) error {
return cfg.CreateProfile(viper.GetString(cfg.MachineProfile), clusterCfg)
}
......@@ -71,7 +71,7 @@ func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) {
t.Fatalf("Got unexpected error %v during config generation", err)
}
// ignored proxy should not be in config
for _, v := range config.MachineConfig.DockerEnv {
for _, v := range config.DockerEnv {
if v == test.proxy && test.proxyIgnored {
t.Fatalf("Value %v not expected in dockerEnv but occurred", v)
}
......
......@@ -80,7 +80,7 @@ var tunnelCmd = &cobra.Command{
if err != nil {
exit.WithError("Error getting config", err)
}
done, err := manager.StartTunnel(ctx, cc.MachineConfig.Name, api, config.DefaultLoader, clientset.CoreV1())
done, err := manager.StartTunnel(ctx, cc.Name, api, config.DefaultLoader, clientset.CoreV1())
if err != nil {
exit.WithError("error starting tunnel", err)
}
......
......@@ -124,14 +124,14 @@ func encode(w io.Writer, m MinikubeConfig) error {
}
// Load loads the kubernetes and machine config for the current machine
func Load() (*Config, error) {
func Load() (*MachineConfig, error) {
machine := viper.GetString(MachineProfile)
return DefaultLoader.LoadConfigFromFile(machine)
}
// Loader loads the kubernetes and machine config based on the machine profile name
type Loader interface {
LoadConfigFromFile(profile string, miniHome ...string) (*Config, error)
LoadConfigFromFile(profile string, miniHome ...string) (*MachineConfig, error)
}
type simpleConfigLoader struct{}
......@@ -139,8 +139,8 @@ type simpleConfigLoader struct{}
// DefaultLoader is the default config loader
var DefaultLoader Loader = &simpleConfigLoader{}
func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...string) (*Config, error) {
var cc Config
func (c *simpleConfigLoader) LoadConfigFromFile(profileName string, miniHome ...string) (*MachineConfig, error) {
var cc MachineConfig
// Move to profile package
path := profileFilePath(profileName, miniHome...)
......
......@@ -35,10 +35,17 @@ func (p *Profile) IsValid() bool {
if p.Config == nil {
return false
}
if p.Config.MachineConfig.VMDriver == "" {
if len(p.Config) == 0 {
return false
}
if p.Config.KubernetesConfig.KubernetesVersion == "" {
// This will become a loop for multinode
if p.Config[0] == nil {
return false
}
if p.Config[0].VMDriver == "" {
return false
}
if p.Config[0].KubernetesConfig.KubernetesVersion == "" {
return false
}
return true
......@@ -68,12 +75,12 @@ func ProfileExists(name string, miniHome ...string) bool {
// CreateEmptyProfile creates an empty profile stores in $MINIKUBE_HOME/profiles/<profilename>/config.json
func CreateEmptyProfile(name string, miniHome ...string) error {
cfg := &Config{}
cfg := &MachineConfig{}
return CreateProfile(name, cfg, miniHome...)
}
// CreateProfile creates an profile out of the cfg and stores in $MINIKUBE_HOME/profiles/<profilename>/config.json
func CreateProfile(name string, cfg *Config, miniHome ...string) error {
func CreateProfile(name string, cfg *MachineConfig, miniHome ...string) error {
data, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
return err
......@@ -153,7 +160,7 @@ func LoadProfile(name string, miniHome ...string) (*Profile, error) {
cfg, err := DefaultLoader.LoadConfigFromFile(name, miniHome...)
p := &Profile{
Name: name,
Config: cfg,
Config: []*MachineConfig{cfg},
}
return p, err
}
......
......@@ -54,8 +54,8 @@ func TestListProfiles(t *testing.T) {
if val[tt.index].Name != tt.expectName {
t.Errorf("expected %s got %v", tt.expectName, val[tt.index].Name)
}
if val[tt.index].Config.MachineConfig.VMDriver != tt.vmDriver {
t.Errorf("expected %s got %v", tt.vmDriver, val[tt.index].Config.MachineConfig.VMDriver)
if val[tt.index].Config[0].VMDriver != tt.vmDriver {
t.Errorf("expected %s got %v", tt.vmDriver, val[tt.index].Config[0].VMDriver)
}
}
......@@ -164,15 +164,15 @@ func TestCreateProfile(t *testing.T) {
var testCases = []struct {
name string
cfg *Config
cfg *MachineConfig
expectErr bool
}{
{"p_empty_config", &Config{}, false},
{"p_partial_config", &Config{KubernetesConfig: KubernetesConfig{
ShouldLoadCachedImages: false}}, false},
{"p_partial_config2", &Config{MachineConfig: MachineConfig{
KeepContext: false}, KubernetesConfig: KubernetesConfig{
{"p_empty_config", &MachineConfig{}, false},
{"p_partial_config", &MachineConfig{KubernetesConfig: KubernetesConfig{
ShouldLoadCachedImages: false}}, false},
{"p_partial_config2", &MachineConfig{
KeepContext: false, KubernetesConfig: KubernetesConfig{
ShouldLoadCachedImages: false}}, false},
}
for _, tc := range testCases {
n := tc.name // capturing loop variable
......
{
"MachineConfig": {
"KeepContext": false,
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
"Memory": 2000,
"CPUs": 2,
"DiskSize": 20000,
"VMDriver": "hyperkit",
"ContainerRuntime": "docker",
"HyperkitVpnKitSock": "",
"HyperkitVSockPorts": [],
"XhyveDiskDriver": "ahci-hd",
"DockerEnv": null,
"InsecureRegistry": null,
"RegistryMirror": null,
"HostOnlyCIDR": "192.168.99.1/24",
"HypervVirtualSwitch": "",
"KVMNetwork": "default",
"KVMQemuURI": "qemu:///system",
"KVMGPU": false,
"KVMHidden": false,
"DockerOpt": null,
"DisableDriverMounts": false,
"NFSShare": [],
"NFSSharesRoot": "/nfsshares",
"UUID": "",
"NoVTXCheck": false,
"DNSProxy": false,
"HostDNSResolver": true
},
"Name": "p1",
"KeepContext": false,
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
"Memory": 2000,
"CPUs": 2,
"DiskSize": 20000,
"VMDriver": "hyperkit",
"ContainerRuntime": "docker",
"HyperkitVpnKitSock": "",
"HyperkitVSockPorts": [],
"XhyveDiskDriver": "ahci-hd",
"DockerEnv": null,
"InsecureRegistry": null,
"RegistryMirror": null,
"HostOnlyCIDR": "192.168.99.1/24",
"HypervVirtualSwitch": "",
"KVMNetwork": "default",
"KVMQemuURI": "qemu:///system",
"KVMGPU": false,
"KVMHidden": false,
"DockerOpt": null,
"DisableDriverMounts": false,
"NFSShare": [],
"NFSSharesRoot": "/nfsshares",
"UUID": "",
"NoVTXCheck": false,
"DNSProxy": false,
"HostDNSResolver": true,
"KubernetesConfig": {
"KubernetesVersion": "v1.15.0",
"NodeIP": "192.168.64.75",
......
{
"MachineConfig": {
"KeepContext": false,
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
"Memory": 2000,
"CPUs": 2,
"DiskSize": 20000,
"VMDriver": "virtualbox",
"ContainerRuntime": "docker",
"HyperkitVpnKitSock": "",
"HyperkitVSockPorts": [],
"DockerEnv": null,
"InsecureRegistry": null,
"RegistryMirror": null,
"HostOnlyCIDR": "192.168.99.1/24",
"HypervVirtualSwitch": "",
"KVMNetwork": "default",
"KVMQemuURI": "qemu:///system",
"KVMGPU": false,
"KVMHidden": false,
"DockerOpt": null,
"DisableDriverMounts": false,
"NFSShare": [],
"NFSSharesRoot": "/nfsshares",
"UUID": "",
"NoVTXCheck": false,
"DNSProxy": false,
"HostDNSResolver": true
},
"Name": "p2",
"KeepContext": false,
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
"Memory": 2000,
"CPUs": 2,
"DiskSize": 20000,
"VMDriver": "virtualbox",
"ContainerRuntime": "docker",
"HyperkitVpnKitSock": "",
"HyperkitVSockPorts": [],
"DockerEnv": null,
"InsecureRegistry": null,
"RegistryMirror": null,
"HostOnlyCIDR": "192.168.99.1/24",
"HypervVirtualSwitch": "",
"KVMNetwork": "default",
"KVMQemuURI": "qemu:///system",
"KVMGPU": false,
"KVMHidden": false,
"DockerOpt": null,
"DisableDriverMounts": false,
"NFSShare": [],
"NFSSharesRoot": "/nfsshares",
"UUID": "",
"NoVTXCheck": false,
"DNSProxy": false,
"HostDNSResolver": true,
"KubernetesConfig": {
"KubernetesVersion": "v1.15.0",
"NodeIP": "192.168.99.136",
......
{
"MachineConfig": {
"KeepContext": false,
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
"Memory": 2000,
"CPUs": 2,
"DiskSize": 20000,
"ContainerRuntime": "docker",
"HyperkitVpnKitSock": "",
"HyperkitVSockPorts": [],
"XhyveDiskDriver": "ahci-hd",
"DockerEnv": null,
"InsecureRegistry": null,
"RegistryMirror": null,
"HostOnlyCIDR": "192.168.99.1/24",
"HypervVirtualSwitch": "",
"KVMNetwork": "default",
"KVMQemuURI": "qemu:///system",
"KVMGPU": false,
"KVMHidden": false,
"DockerOpt": null,
"DisableDriverMounts": false,
"NFSShare": [],
"NFSSharesRoot": "/nfsshares",
"UUID": "",
"NoVTXCheck": false,
"DNSProxy": false,
"HostDNSResolver": true
},
"KeepContext": false,
"MinikubeISO": "https://storage.googleapis.com/minikube/iso/minikube-v1.2.0.iso",
"Memory": 2000,
"CPUs": 2,
"DiskSize": 20000,
"ContainerRuntime": "docker",
"HyperkitVpnKitSock": "",
"HyperkitVSockPorts": [],
"XhyveDiskDriver": "ahci-hd",
"DockerEnv": null,
"InsecureRegistry": null,
"RegistryMirror": null,
"HostOnlyCIDR": "192.168.99.1/24",
"HypervVirtualSwitch": "",
"KVMNetwork": "default",
"KVMQemuURI": "qemu:///system",
"KVMGPU": false,
"KVMHidden": false,
"DockerOpt": null,
"DisableDriverMounts": false,
"NFSShare": [],
"NFSSharesRoot": "/nfsshares",
"UUID": "",
"NoVTXCheck": false,
"DNSProxy": false,
"HostDNSResolver": true,
"KubernetesConfig": {
"NodePort": 8443,
"NodeName": "minikube",
......
......@@ -26,13 +26,7 @@ import (
// Profile represents a minikube profile
type Profile struct {
Name string
Config *Config
}
// Config contains machine and k8s config
type Config struct {
MachineConfig MachineConfig
KubernetesConfig KubernetesConfig
Config []*MachineConfig
}
// MachineConfig contains the parameters used to start a cluster.
......@@ -66,6 +60,7 @@ type MachineConfig struct {
NoVTXCheck bool // Only used by virtualbox
DNSProxy bool // Only used by virtualbox
HostDNSResolver bool // Only used by virtualbox
KubernetesConfig KubernetesConfig
}
// KubernetesConfig contains the parameters used to configure the VM Kubernetes.
......
......@@ -135,7 +135,7 @@ func CacheAndLoadImages(images []string) error {
if err != nil {
return err
}
h, err := api.Load(cc.MachineConfig.Name)
h, err := api.Load(cc.Name)
if err != nil {
return err
}
......
......@@ -64,7 +64,7 @@ func (m *clusterInspector) getStateAndRoute() (HostState, *Route, error) {
if err != nil {
return hostState, nil, err
}
var c *config.Config
var c *config.MachineConfig
c, err = m.configLoader.LoadConfigFromFile(m.machineName)
if err != nil {
err = errors.Wrapf(err, "error loading config for %s", m.machineName)
......@@ -80,7 +80,7 @@ func (m *clusterInspector) getStateAndRoute() (HostState, *Route, error) {
return hostState, route, nil
}
func getRoute(host *host.Host, clusterConfig config.Config) (*Route, error) {
func getRoute(host *host.Host, clusterConfig config.MachineConfig) (*Route, error) {
hostDriverIP, err := host.Driver.GetIP()
if err != nil {
return nil, errors.Wrapf(err, "error getting host IP for %s", host.Name)
......
......@@ -62,7 +62,7 @@ func TestMinikubeCheckReturnsHostInformation(t *testing.T) {
}
configLoader := &stubConfigLoader{
c: &config.Config{
c: &config.MachineConfig{
KubernetesConfig: config.KubernetesConfig{
ServiceCIDR: "96.0.0.0/12",
},
......@@ -100,7 +100,7 @@ func TestMinikubeCheckReturnsHostInformation(t *testing.T) {
}
func TestUnparseableCIDR(t *testing.T) {
cfg := config.Config{
cfg := config.MachineConfig{
KubernetesConfig: config.KubernetesConfig{
ServiceCIDR: "bad.cidr.0.0/12",
}}
......@@ -120,7 +120,7 @@ func TestUnparseableCIDR(t *testing.T) {
func TestRouteIPDetection(t *testing.T) {
expectedTargetCIDR := "10.96.0.0/12"
cfg := config.Config{
cfg := config.MachineConfig{
KubernetesConfig: config.KubernetesConfig{
ServiceCIDR: expectedTargetCIDR,
},
......
......@@ -82,10 +82,10 @@ func (r *fakeRouter) Inspect(route *Route) (exists bool, conflict string, overla
}
type stubConfigLoader struct {
c *config.Config
c *config.MachineConfig
e error
}
func (l *stubConfigLoader) LoadConfigFromFile(profile string, miniHome ...string) (*config.Config, error) {
func (l *stubConfigLoader) LoadConfigFromFile(profile string, miniHome ...string) (*config.MachineConfig, error) {
return l.c, l.e
}
......@@ -423,7 +423,7 @@ func TestTunnel(t *testing.T) {
},
}
configLoader := &stubConfigLoader{
c: &config.Config{
c: &config.MachineConfig{
KubernetesConfig: config.KubernetesConfig{
ServiceCIDR: tc.serviceCIDR,
}},
......@@ -478,7 +478,7 @@ func TestErrorCreatingTunnel(t *testing.T) {
}
configLoader := &stubConfigLoader{
c: &config.Config{
c: &config.MachineConfig{
KubernetesConfig: config.KubernetesConfig{
ServiceCIDR: "10.96.0.0/12",
}},
......
......@@ -330,7 +330,7 @@ func configureAuth(p *BuildrootProvisioner) error {
return err
}
if config.MachineConfig.ContainerRuntime == "" {
if config.ContainerRuntime == "" {
if err := p.Service("docker", serviceaction.Enable); err != nil {
return err
......
......@@ -107,7 +107,7 @@ func TestDownloadOnly(t *testing.T) {
got := ""
for _, p := range ps["valid"] {
if p.Name == profile {
got = p.Config.MachineConfig.VMDriver
got = p.Config[0].VMDriver
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册