Skip to content

Commit 1d19694

Browse files
author
Priya Wadhwa
committed
Restart containerd after stopping alternate runtimes
After stopping any runtimes that aren't being used, if we're using containerd then we need to restart it. This is because it competes with cri-o to listen on port 10010, causing a necesary plugin to not be installed. After stopping cri-o, we need to restart containerd so that the plugin is installed. I also added some preflight checks when using alternative runtimes. kubeadm checks to make sure the Docker service is running, so I disabled that. It also checks if a few ports are available; these are ports that containerd uses, so I also added them to the ignore list. This should finish the work started in kubernetes#3211, which stopped alternative runtimes but didn't restart containerd. I was able to run "minikube start" with containerd locally with this change.
1 parent b69fc99 commit 1d19694

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

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

+17-7
Original file line numberDiff line numberDiff line change
@@ -295,31 +295,41 @@ func runStart(cmd *cobra.Command, args []string) {
295295
fmt.Println("Stopping extra container runtimes...")
296296

297297
containerRuntime := viper.GetString(containerRuntime)
298-
if config.VMDriver != "none" && containerRuntime != "" {
298+
if config.VMDriver != constants.DriverNone && containerRuntime != "" {
299299
if _, err := host.RunSSHCommand("sudo systemctl stop docker"); err == nil {
300300
_, err = host.RunSSHCommand("sudo systemctl stop docker.socket")
301301
}
302302
if err != nil {
303-
glog.Errorf("Error stopping docker", err)
303+
glog.Errorf("Error stopping docker: %v", err)
304304
}
305305
}
306-
if config.VMDriver != "none" && (containerRuntime != "crio" && containerRuntime != "cri-o") {
306+
if config.VMDriver != constants.DriverNone && (containerRuntime != "crio" && containerRuntime != "cri-o") {
307307
if _, err := host.RunSSHCommand("sudo systemctl stop crio"); err != nil {
308-
glog.Errorf("Error stopping crio", err)
308+
glog.Errorf("Error stopping crio: %v", err)
309309
}
310310
}
311-
if config.VMDriver != "none" && containerRuntime != "rkt" {
311+
if config.VMDriver != constants.DriverNone && containerRuntime != "rkt" {
312312
if _, err := host.RunSSHCommand("sudo systemctl stop rkt-api"); err == nil {
313313
_, err = host.RunSSHCommand("sudo systemctl stop rkt-metadata")
314314
}
315315
if err != nil {
316-
glog.Errorf("Error stopping rkt", err)
316+
glog.Errorf("Error stopping rkt: %v", err)
317+
}
318+
}
319+
320+
if config.VMDriver != constants.DriverNone && containerRuntime == constants.ContainerdRuntime {
321+
fmt.Println("Restarting containerd runtime...")
322+
// restart containerd so that it can install all plugins
323+
// this didn't happen before because one of the plugin installations was trying to use port 10010
324+
// which the cri-o runtime uses
325+
if _, err := host.RunSSHCommand("sudo systemctl restart containerd"); err != nil {
326+
glog.Errorf("Error restarting containerd: %v", err)
317327
}
318328
}
319329

320330
fmt.Println("Starting cluster components...")
321331

322-
if !exists || config.VMDriver == "none" {
332+
if !exists || config.VMDriver == constants.DriverNone {
323333
if err := k8sBootstrapper.StartCluster(kubernetesConfig); err != nil {
324334
glog.Errorln("Error starting cluster: ", err)
325335
cmdutil.MaybeReportErrorAndExit(err)

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
115115
}
116116

117117
b := bytes.Buffer{}
118+
preflights := constants.Preflights
119+
if k8s.ContainerRuntime != "" {
120+
preflights = constants.AlternateRuntimePreflights
121+
}
118122
templateContext := struct {
119123
KubeadmConfigFile string
120124
SkipPreflightChecks bool
@@ -125,7 +129,7 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
125129
SkipPreflightChecks: !VersionIsBetween(version,
126130
semver.MustParse("1.9.0-alpha.0"),
127131
semver.Version{}),
128-
Preflights: constants.Preflights,
132+
Preflights: preflights,
129133
DNSAddon: "kube-dns",
130134
}
131135
if version.GTE(semver.MustParse("1.12.0")) {

Diff for: pkg/minikube/constants/constants.go

+14
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ var Preflights = []string{
164164
"CRI",
165165
}
166166

167+
// AlternateRuntimePreflights are additional preflight checks applied when running
168+
// any container runtime that isn't Docker
169+
var AlternateRuntimePreflights = append(Preflights, []string{
170+
"Service-Docker",
171+
"Port-8443",
172+
"Port-10251",
173+
"Port-10252",
174+
"Port-2379",
175+
}...)
176+
177+
const (
178+
ContainerdRuntime = "containerd"
179+
)
180+
167181
const (
168182
DefaultUfsPort = "5640"
169183
DefaultUfsDebugLvl = 0

0 commit comments

Comments
 (0)