Skip to content

Commit

Permalink
Only restart docker service if container runtime is docker (#3426)
Browse files Browse the repository at this point in the history
* Only restart docker service if container runtime is docker

Only allow the buildroot provisioner to restart docker if the container
runtime is docker. This change should fix the bug in #3424, since now
docker will not be restarted if the container runtime is containerd.

* Added files to fix FileContent--proc-sys-net-bridge-bridge-nf-call-iptables precheck error

From this issue: kubernetes/kubeadm#1062
these files need to be added to prevent this precheck error (which occurs when running any container runtime that isn't docker).

Also, save the machine config on the user's filesystem earlier so that the buildprovisioner can access it.
  • Loading branch information
priyawadhwa authored and balopat committed Dec 7, 2018
1 parent bf815dd commit ed8f712
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ func runStart(cmd *cobra.Command, args []string) {
GPU: viper.GetBool(gpu),
}

// Write profile cluster configuration to file
clusterConfig := cfg.Config{
MachineConfig: config,
}

if err := saveConfig(clusterConfig); err != nil {
glog.Errorln("Error saving profile cluster configuration: ", err)
}

fmt.Printf("Starting local Kubernetes %s cluster...\n", viper.GetString(kubernetesVersion))
fmt.Println("Starting VM...")
var host *host.Host
Expand Down Expand Up @@ -235,7 +244,7 @@ func runStart(cmd *cobra.Command, args []string) {
}

// Write profile cluster configuration to file
clusterConfig := cfg.Config{
clusterConfig = cfg.Config{
MachineConfig: config,
KubernetesConfig: kubernetesConfig,
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,18 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
preflights := constants.Preflights
if k8s.ContainerRuntime != "" {
preflights = constants.AlternateRuntimePreflights
out, err := k.c.CombinedOutput("sudo modprobe br_netfilter")
if err != nil {
glog.Infoln(out)
return errors.Wrap(err, "sudo modprobe br_netfilter")
}
out, err = k.c.CombinedOutput("sudo sh -c \"echo '1' > /proc/sys/net/ipv4/ip_forward\"")
if err != nil {
glog.Infoln(out)
return errors.Wrap(err, "creating /proc/sys/net/ipv4/ip_forward")
}
}

templateContext := struct {
KubeadmConfigFile string
SkipPreflightChecks bool
Expand Down
10 changes: 10 additions & 0 deletions pkg/provision/buildroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/sshutil"
"k8s.io/minikube/pkg/util"
)
Expand Down Expand Up @@ -288,6 +289,15 @@ func configureAuth(p *BuildrootProvisioner) error {
}
}

config, err := config.Load()
if err != nil {
return errors.Wrap(err, "getting cluster config")
}

if config.MachineConfig.ContainerRuntime != "" {
return nil
}

dockerCfg, err := p.GenerateDockerOptions(engine.DefaultPort)
if err != nil {
return errors.Wrap(err, "generating docker options")
Expand Down

0 comments on commit ed8f712

Please sign in to comment.