diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index 93d370e730a8..bc2ecab54fd5 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -106,6 +106,15 @@ func (r *Docker) SocketPath() string { // Available returns an error if it is not possible to use this runtime on a host func (r *Docker) Available() error { + // If Kubernetes version >= 1.24, require both cri-dockerd and dockerd. + if r.KubernetesVersion.GTE(semver.Version{Major: 1, Minor: 24}) { + if _, err := exec.LookPath("cri-dockerd"); err != nil { + return err + } + if _, err := exec.LookPath("dockerd"); err != nil { + return err + } + } _, err := exec.LookPath("docker") return err } diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go index 88be616ed197..332daf753700 100644 --- a/pkg/minikube/driver/driver.go +++ b/pkg/minikube/driver/driver.go @@ -157,6 +157,11 @@ func IsMock(name string) bool { return name == Mock } +// IsNone checks if the driver is a none +func IsNone(name string) bool { + return name == None +} + // IsKVM checks if the driver is a KVM[2] func IsKVM(name string) bool { return name == KVM2 || name == AliasKVM diff --git a/pkg/minikube/machine/start.go b/pkg/minikube/machine/start.go index 895d2993d858..37f2cc4320c5 100644 --- a/pkg/minikube/machine/start.go +++ b/pkg/minikube/machine/start.go @@ -28,6 +28,7 @@ import ( "strings" "time" + "github.com/blang/semver" "github.com/docker/machine/libmachine" "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/engine" @@ -313,6 +314,24 @@ func postStartSetup(h *host.Host, mc config.ClusterConfig) error { return nil } + // If none driver with docker container-runtime, require cri-dockerd and dockerd. + if driver.IsNone(h.DriverName) && mc.KubernetesConfig.ContainerRuntime == constants.Docker { + // If Kubernetes version >= 1.24, require both cri-dockerd and dockerd. + k8sVer, err := semver.ParseTolerant(mc.KubernetesConfig.KubernetesVersion) + if err != nil { + klog.Errorf("unable to parse Kubernetes version: %s", mc.KubernetesConfig.KubernetesVersion) + return err + } + if k8sVer.GTE(semver.Version{Major: 1, Minor: 24}) { + if _, err := exec.LookPath("cri-dockerd"); err != nil { + exit.Message(reason.NotFoundCriDockerd, "\n\n") + } + if _, err := exec.LookPath("dockerd"); err != nil { + exit.Message(reason.NotFoundDockerd, "\n\n") + } + } + } + klog.Infof("creating required directories: %v", requiredDirectories) r, err := CommandRunner(h) diff --git a/pkg/minikube/reason/reason.go b/pkg/minikube/reason/reason.go index e990ebce4d94..d8eebd74bb0e 100644 --- a/pkg/minikube/reason/reason.go +++ b/pkg/minikube/reason/reason.go @@ -460,4 +460,25 @@ var ( `), Style: style.SeeNoEvil, } + + NotFoundCriDockerd = Kind{ + ID: "NOT_FOUND_CRI_DOCKERD", + ExitCode: ExProgramNotFound, + Advice: translate.T(`The none driver with Kubernetes v1.24+ and the docker container-runtime requires cri-dockerd. + + Please install cri-dockerd using these instructions: + + https://github.com/Mirantis/cri-dockerd#build-and-install`), + Style: style.Docker, + } + NotFoundDockerd = Kind{ + ID: "NOT_FOUND_DOCKERD", + ExitCode: ExProgramNotFound, + Advice: translate.T(`The none driver with Kubernetes v1.24+ and the docker container-runtime requires dockerd. + + Please install dockerd using these instructions: + + https://docs.docker.com/engine/install/`), + Style: style.Docker, + } )