Skip to content

Commit ed8f712

Browse files
priyawadhwabalopat
priyawadhwa
authored andcommitted
Only restart docker service if container runtime is docker (#3426)
* 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.
1 parent bf815dd commit ed8f712

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

Diff for: cmd/minikube/cmd/start.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ func runStart(cmd *cobra.Command, args []string) {
161161
GPU: viper.GetBool(gpu),
162162
}
163163

164+
// Write profile cluster configuration to file
165+
clusterConfig := cfg.Config{
166+
MachineConfig: config,
167+
}
168+
169+
if err := saveConfig(clusterConfig); err != nil {
170+
glog.Errorln("Error saving profile cluster configuration: ", err)
171+
}
172+
164173
fmt.Printf("Starting local Kubernetes %s cluster...\n", viper.GetString(kubernetesVersion))
165174
fmt.Println("Starting VM...")
166175
var host *host.Host
@@ -235,7 +244,7 @@ func runStart(cmd *cobra.Command, args []string) {
235244
}
236245

237246
// Write profile cluster configuration to file
238-
clusterConfig := cfg.Config{
247+
clusterConfig = cfg.Config{
239248
MachineConfig: config,
240249
KubernetesConfig: kubernetesConfig,
241250
}

Diff for: pkg/minikube/bootstrapper/kubeadm/kubeadm.go

+11
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,18 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
118118
preflights := constants.Preflights
119119
if k8s.ContainerRuntime != "" {
120120
preflights = constants.AlternateRuntimePreflights
121+
out, err := k.c.CombinedOutput("sudo modprobe br_netfilter")
122+
if err != nil {
123+
glog.Infoln(out)
124+
return errors.Wrap(err, "sudo modprobe br_netfilter")
125+
}
126+
out, err = k.c.CombinedOutput("sudo sh -c \"echo '1' > /proc/sys/net/ipv4/ip_forward\"")
127+
if err != nil {
128+
glog.Infoln(out)
129+
return errors.Wrap(err, "creating /proc/sys/net/ipv4/ip_forward")
130+
}
121131
}
132+
122133
templateContext := struct {
123134
KubeadmConfigFile string
124135
SkipPreflightChecks bool

Diff for: pkg/provision/buildroot.go

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/pkg/errors"
3838
"k8s.io/minikube/pkg/minikube/assets"
3939
"k8s.io/minikube/pkg/minikube/bootstrapper"
40+
"k8s.io/minikube/pkg/minikube/config"
4041
"k8s.io/minikube/pkg/minikube/sshutil"
4142
"k8s.io/minikube/pkg/util"
4243
)
@@ -288,6 +289,15 @@ func configureAuth(p *BuildrootProvisioner) error {
288289
}
289290
}
290291

292+
config, err := config.Load()
293+
if err != nil {
294+
return errors.Wrap(err, "getting cluster config")
295+
}
296+
297+
if config.MachineConfig.ContainerRuntime != "" {
298+
return nil
299+
}
300+
291301
dockerCfg, err := p.GenerateDockerOptions(engine.DefaultPort)
292302
if err != nil {
293303
return errors.Wrap(err, "generating docker options")

0 commit comments

Comments
 (0)