Skip to content

Commit

Permalink
Merge pull request #14555 from klaases/doc1
Browse files Browse the repository at this point in the history
none-driver: check cri-dockerd & dockerd runtimes
  • Loading branch information
spowelljr authored Jul 28, 2022
2 parents 4f20418 + 14ba826 commit 3e839c4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/minikube/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions pkg/minikube/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions pkg/minikube/reason/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)

0 comments on commit 3e839c4

Please sign in to comment.