Skip to content

Commit

Permalink
Automatically add extra options for none driver on ubuntu
Browse files Browse the repository at this point in the history
Automatically add extra options for none driver on ubuntu
  • Loading branch information
medyagh authored Jun 13, 2019
1 parent eb96756 commit 6ecc105
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"strings"
"time"

"k8s.io/minikube/pkg/minikube/drivers/none"

"github.com/blang/semver"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
Expand Down Expand Up @@ -350,6 +352,11 @@ func validateConfig() {
exit.Usage("Sorry, the --hidden feature is currently only supported with --vm-driver=kvm2")
}

err := autoSetOptions(viper.GetString(vmDriver))
if err != nil {
glog.Errorf("Error autoSetOptions : %v", err)
}

// check that kubeadm extra args contain only whitelisted parameters
for param := range extraOptions.AsMap().Get(kubeadm.Kubeadm) {
if !pkgutil.ContainsString(kubeadm.KubeadmExtraArgsWhitelist[kubeadm.KubeadmCmdParam], param) &&
Expand Down Expand Up @@ -486,6 +493,17 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
return cfg, nil
}

// autoSetOptions sets the options needed for specific configuration automatically.
func autoSetOptions(vmDriver string) error {
// options for none driver
if vmDriver == constants.DriverNone {
if o := none.AutoOptions(); o != "" {
return extraOptions.Set(o)
}
}
return nil
}

// prepareNone prepares the user and host for the joy of the "none" driver
func prepareNone() {
if viper.GetBool(cfg.WantNoneDriverWarning) {
Expand Down
11 changes: 11 additions & 0 deletions pkg/minikube/drivers/none/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package none

import (
"fmt"
"os"

"github.com/docker/machine/libmachine/drivers"
"k8s.io/minikube/pkg/drivers/none"
Expand Down Expand Up @@ -47,3 +48,13 @@ func createNoneHost(config cfg.MachineConfig) interface{} {
ContainerRuntime: config.ContainerRuntime,
})
}

// AutoOptions returns suggested extra options based on the current config
func AutoOptions() string {
// for more info see: https://github.com/kubernetes/minikube/issues/3511
f := "/run/systemd/resolve/resolv.conf"
if _, err := os.Stat(f); err != nil {
return ""
}
return fmt.Sprintf("kubelet.resolv-conf=%s", f)
}

0 comments on commit 6ecc105

Please sign in to comment.