Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for cri-dockerd & dockerd runtimes when using none-driver on Kubernetes 1.24+ #14555

Merged
merged 14 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
klaases marked this conversation as resolved.
Show resolved Hide resolved
}
if _, err := exec.LookPath("dockerd"); err != nil {
return err
}
}
_, err := exec.LookPath("docker")
klaases marked this conversation as resolved.
Show resolved Hide resolved
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,
}
)