Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically add extra options for none driver on ubuntu #4465

Merged
merged 5 commits into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}