Skip to content

Commit 3e839c4

Browse files
authored
Merge pull request #14555 from klaases/doc1
none-driver: check cri-dockerd & dockerd runtimes
2 parents 4f20418 + 14ba826 commit 3e839c4

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

pkg/minikube/cruntime/docker.go

+9
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ func (r *Docker) SocketPath() string {
106106

107107
// Available returns an error if it is not possible to use this runtime on a host
108108
func (r *Docker) Available() error {
109+
// If Kubernetes version >= 1.24, require both cri-dockerd and dockerd.
110+
if r.KubernetesVersion.GTE(semver.Version{Major: 1, Minor: 24}) {
111+
if _, err := exec.LookPath("cri-dockerd"); err != nil {
112+
return err
113+
}
114+
if _, err := exec.LookPath("dockerd"); err != nil {
115+
return err
116+
}
117+
}
109118
_, err := exec.LookPath("docker")
110119
return err
111120
}

pkg/minikube/driver/driver.go

+5
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ func IsMock(name string) bool {
157157
return name == Mock
158158
}
159159

160+
// IsNone checks if the driver is a none
161+
func IsNone(name string) bool {
162+
return name == None
163+
}
164+
160165
// IsKVM checks if the driver is a KVM[2]
161166
func IsKVM(name string) bool {
162167
return name == KVM2 || name == AliasKVM

pkg/minikube/machine/start.go

+19
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"strings"
2929
"time"
3030

31+
"github.com/blang/semver"
3132
"github.com/docker/machine/libmachine"
3233
"github.com/docker/machine/libmachine/drivers"
3334
"github.com/docker/machine/libmachine/engine"
@@ -313,6 +314,24 @@ func postStartSetup(h *host.Host, mc config.ClusterConfig) error {
313314
return nil
314315
}
315316

317+
// If none driver with docker container-runtime, require cri-dockerd and dockerd.
318+
if driver.IsNone(h.DriverName) && mc.KubernetesConfig.ContainerRuntime == constants.Docker {
319+
// If Kubernetes version >= 1.24, require both cri-dockerd and dockerd.
320+
k8sVer, err := semver.ParseTolerant(mc.KubernetesConfig.KubernetesVersion)
321+
if err != nil {
322+
klog.Errorf("unable to parse Kubernetes version: %s", mc.KubernetesConfig.KubernetesVersion)
323+
return err
324+
}
325+
if k8sVer.GTE(semver.Version{Major: 1, Minor: 24}) {
326+
if _, err := exec.LookPath("cri-dockerd"); err != nil {
327+
exit.Message(reason.NotFoundCriDockerd, "\n\n")
328+
}
329+
if _, err := exec.LookPath("dockerd"); err != nil {
330+
exit.Message(reason.NotFoundDockerd, "\n\n")
331+
}
332+
}
333+
}
334+
316335
klog.Infof("creating required directories: %v", requiredDirectories)
317336

318337
r, err := CommandRunner(h)

pkg/minikube/reason/reason.go

+21
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,25 @@ var (
460460
`),
461461
Style: style.SeeNoEvil,
462462
}
463+
464+
NotFoundCriDockerd = Kind{
465+
ID: "NOT_FOUND_CRI_DOCKERD",
466+
ExitCode: ExProgramNotFound,
467+
Advice: translate.T(`The none driver with Kubernetes v1.24+ and the docker container-runtime requires cri-dockerd.
468+
469+
Please install cri-dockerd using these instructions:
470+
471+
https://github.com/Mirantis/cri-dockerd#build-and-install`),
472+
Style: style.Docker,
473+
}
474+
NotFoundDockerd = Kind{
475+
ID: "NOT_FOUND_DOCKERD",
476+
ExitCode: ExProgramNotFound,
477+
Advice: translate.T(`The none driver with Kubernetes v1.24+ and the docker container-runtime requires dockerd.
478+
479+
Please install dockerd using these instructions:
480+
481+
https://docs.docker.com/engine/install/`),
482+
Style: style.Docker,
483+
}
463484
)

0 commit comments

Comments
 (0)