Repository: kubernetes/minikube
Pull request #13328 (2022-01-11 22:09:19)

Remove deprecated global-housekeeping-interval flag
kubelet v1.23: `--global-housekeeping-interval`: `Interval between global housekeepings (default 1m0s) (DEPRECATED: This is a cadvisor flag that was mistakenly registered with the Kubelet. Due to legacy concerns, it will follow the standard CLI deprecation timeline before being removed.)`


Patch:
diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go
index c9cd853e7..5bb13c531 100644
--- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go
+++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go
@@ -649,15 +649,14 @@ func (k *Bootstrapper) GenerateToken(cc config.ClusterConfig) (string, error) {
 	joinCmd = fmt.Sprintf("%s --ignore-preflight-errors=all", strings.TrimSpace(joinCmd))
 
 	// avoid "Found multiple CRI sockets, please use --cri-socket to select one: /var/run/dockershim.sock, /var/run/crio/crio.sock" error
-	version, err := util.ParseKubernetesVersion(cc.KubernetesConfig.KubernetesVersion)
-	if err != nil {
-		return "", errors.Wrap(err, "parsing Kubernetes version")
-	}
-	cr, err := cruntime.New(cruntime.Config{Type: cc.KubernetesConfig.ContainerRuntime, Runner: k.c, Socket: cc.KubernetesConfig.CRISocket, KubernetesVersion: version})
+	cr, err := cruntime.New(cruntime.Config{Type: cc.KubernetesConfig.ContainerRuntime, Runner: k.c, Socket: cc.KubernetesConfig.CRISocket})
 	if err != nil {
 		klog.Errorf("cruntime: %v", err)
 	}
 	sp := cr.SocketPath()
+	if sp == "" {
+		sp = kconst.DefaultDockerCRISocket
+	}
 	joinCmd = fmt.Sprintf("%s --cri-socket %s", joinCmd, sp)
 
 	return joinCmd, nil
@@ -697,17 +696,21 @@ func StopKubernetes(runner command.Runner, cr cruntime.Manager) {
 
 // DeleteCluster removes the components that were started earlier
 func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
-	version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
+	cr, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: k.c, Socket: k8s.CRISocket})
 	if err != nil {
-		return errors.Wrap(err, "parsing Kubernetes version")
+		return errors.Wrap(err, "runtime")
 	}
-	cr, err := cruntime.New(cruntime.Config{Type: k8s.ContainerRuntime, Runner: k.c, Socket: k8s.CRISocket, KubernetesVersion: version})
+
+	version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
 	if err != nil {
-		return errors.Wrap(err, "runtime")
+		return errors.Wrap(err, "parsing Kubernetes version")
 	}
 
 	ka := bsutil.InvokeKubeadm(k8s.KubernetesVersion)
 	sp := cr.SocketPath()
+	if sp == "" {
+		sp = kconst.DefaultDockerCRISocket
+	}
 	cmd := fmt.Sprintf("%s reset --cri-socket %s --force", ka, sp)
 	if version.LT(semver.MustParse("1.11.0")) {
 		cmd = fmt.Sprintf("%s reset --cri-socket %s", ka, sp)
@@ -734,15 +737,9 @@ func (k *Bootstrapper) UpdateCluster(cfg config.ClusterConfig) error {
 		return errors.Wrap(err, "kubeadm images")
 	}
 
-	version, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
-	if err != nil {
-		return errors.Wrap(err, "parsing Kubernetes version")
-	}
 	r, err := cruntime.New(cruntime.Config{
-		Type:              cfg.KubernetesConfig.ContainerRuntime,
-		Runner:            k.c,
-		Socket:            cfg.KubernetesConfig.CRISocket,
-		KubernetesVersion: version,
+		Type:   cfg.KubernetesConfig.ContainerRuntime,
+		Runner: k.c, Socket: cfg.KubernetesConfig.CRISocket,
 	})
 	if err != nil {
 		return errors.Wrap(err, "runtime")
diff --git a/pkg/minikube/cruntime/cruntime.go b/pkg/minikube/cruntime/cruntime.go
index 514ad9767..5fb49e93b 100644
--- a/pkg/minikube/cruntime/cruntime.go
+++ b/pkg/minikube/cruntime/cruntime.go
@@ -208,21 +208,13 @@ func New(c Config) (Manager, error) {
 
 	switch c.Type {
 	case "", "docker":
-		sp := c.Socket
-		cs := ""
-		// There is no more dockershim socket, in Kubernetes version 1.24 and beyond
-		if sp == "" && c.KubernetesVersion.GTE(semver.MustParse("1.24.0-alpha.0")) {
-			sp = ExternalDockerCRISocket
-			cs = "cri-docker.socket"
-		}
 		return &Docker{
-			Socket:            sp,
+			Socket:            c.Socket,
 			Runner:            c.Runner,
 			ImageRepository:   c.ImageRepository,
 			KubernetesVersion: c.KubernetesVersion,
 			Init:              sm,
-			UseCRI:            (sp != ""), // !dockershim
-			CRIService:        cs,
+			UseCRI:            (c.Socket != ""), // !dockershim
 		}, nil
 	case "crio", "cri-o":
 		return &CRIO{
diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go
index fc23019c3..3ddcc449a 100644
--- a/pkg/minikube/cruntime/docker.go
+++ b/pkg/minikube/cruntime/docker.go
@@ -42,9 +42,6 @@ import (
 // KubernetesContainerPrefix is the prefix of each Kubernetes container
 const KubernetesContainerPrefix = "k8s_"
 
-const InternalDockerCRISocket = "/var/run/dockershim.sock"
-const ExternalDockerCRISocket = "/var/run/cri-dockerd.sock"
-
 // ErrISOFeature is the error returned when disk image is missing features
 type ErrISOFeature struct {
 	missing string
@@ -69,7 +66,6 @@ type Docker struct {
 	KubernetesVersion semver.Version
 	Init              sysinit.Manager
 	UseCRI            bool
-	CRIService        string
 }
 
 // Name is a human readable name for Docker
@@ -98,7 +94,7 @@ func (r *Docker) SocketPath() string {
 	if r.Socket != "" {
 		return r.Socket
 	}
-	return InternalDockerCRISocket
+	return "/var/run/dockershim.sock"
 }
 
 // Available returns an error if it is not possible to use this runtime on a host
@@ -149,20 +145,7 @@ func (r *Docker) Enable(disOthers, forceSystemd, inUserNamespace bool) error {
 		return r.Init.Restart("docker")
 	}
 
-	if err := r.Init.Start("docker"); err != nil {
-		return err
-	}
-
-	if r.CRIService != "" {
-		if err := r.Init.Enable(r.CRIService); err != nil {
-			return err
-		}
-		if err := r.Init.Start(r.CRIService); err != nil {
-			return err
-		}
-	}
-
-	return nil
+	return r.Init.Start("docker")
 }
 
 // Restart restarts Docker on a host
@@ -172,14 +155,6 @@ func (r *Docker) Restart() error {
 
 // Disable idempotently disables Docker on a host
 func (r *Docker) Disable() error {
-	if r.CRIService != "" {
-		if err := r.Init.Stop(r.CRIService); err != nil {
-			return err
-		}
-		if err := r.Init.Disable(r.CRIService); err != nil {
-			return err
-		}
-	}
 	klog.Info("disabling docker service ...")
 	// because #10373
 	if err := r.Init.ForceStop("docker.socket"); err != nil {
diff --git a/pkg/minikube/driver/driver.go b/pkg/minikube/driver/driver.go
index 6808c862c..50b8ebcd7 100644
--- a/pkg/minikube/driver/driver.go
+++ b/pkg/minikube/driver/driver.go
@@ -235,7 +235,7 @@ type FlagHints struct {
 
 // FlagDefaults returns suggested defaults based on a driver
 func FlagDefaults(name string) FlagHints {
-	fh := FlagHints{ExtraOptions: []string{"kubelet.global-housekeeping-interval=60m", "kubelet.housekeeping-interval=5m"}}
+	fh := FlagHints{ExtraOptions: []string{"kubelet.housekeeping-interval=5m"}}
 	if name != None {
 		fh.CacheImages = true
 		return fh
diff --git a/site/content/en/docs/faq/_index.md b/site/content/en/docs/faq/_index.md
index 016e3c937..ce4d74d49 100644
--- a/site/content/en/docs/faq/_index.md
+++ b/site/content/en/docs/faq/_index.md
@@ -30,23 +30,19 @@ minikube profile list
 minikube profiles are meant to be isolated from one another, with their own settings and drivers. If you want to create a single cluster with multiple nodes, try the [multi-node feature]({{< ref "/docs/tutorials/multi_node" >}}) instead.
 
 ## Can I use minikube as a Docker Desktop replacement?
-
 minikube's VM includes a Docker daemon running inside Linux for free, so you can use 
 `minikube docker-env` to point your terminal's Docker CLI to the Docker inside minikube.
 
-Note: this only works with the "docker" container runtime, not with e.g. "containerd"
-
 You would need to start minikube with a VM driver, instead of docker, such as hyperkit on macOS and Hyper-V on Windows.
 ```
-minikube start --container-runtime=docker --vm=true
+minikube start --driver=hyperv 
 ```
 Alternatively, you can use `minikube image build`  instead of `minikube docker-env` and `docker build`.
 
 ## Can I start minikube without Kubernetes running?
-
 Yes! If you want to use minikube only as a Docker Desktop replacement without starting Kubernetes itself, try:
 ```
-minikube start --container-runtime=docker --no-kubernetes
+minikube start --no-kubernetes
 ```
 
 Alternatively, if you want to temporarily turn off Kubernetes, you can pause and later unpause Kubernetes 


Test patch:
diff --git a/pkg/minikube/cruntime/cruntime_test.go b/pkg/minikube/cruntime/cruntime_test.go
index 80bf49cf0..91f28c20d 100644
--- a/pkg/minikube/cruntime/cruntime_test.go
+++ b/pkg/minikube/cruntime/cruntime_test.go
@@ -23,7 +23,6 @@ import (
 	"strings"
 	"testing"
 
-	"github.com/blang/semver/v4"
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 	"github.com/pkg/errors"
@@ -57,34 +56,6 @@ func TestName(t *testing.T) {
 	}
 }
 
-func TestDefaultDockerSocketPath(t *testing.T) {
-	var tests = []struct {
-		version string
-		want    string
-	}{
-		{"1.20.0", InternalDockerCRISocket},
-		{"1.21.3", InternalDockerCRISocket},
-		{"1.23.0", InternalDockerCRISocket},
-		{"1.24.0-alpha.0", ExternalDockerCRISocket},
-		{"1.24.0-beta.0", ExternalDockerCRISocket},
-		{"1.24.6", ExternalDockerCRISocket},
-	}
-	for _, tc := range tests {
-		runtime := "docker"
-		version := semver.MustParse(tc.version)
-		t.Run(runtime, func(t *testing.T) {
-			r, err := New(Config{Type: runtime, KubernetesVersion: version})
-			if err != nil {
-				t.Fatalf("New(%s): %v", tc.version, err)
-			}
-			got := r.SocketPath()
-			if got != tc.want {
-				t.Errorf("SocketPath(%s) = %q, want: %q", tc.version, got, tc.want)
-			}
-		})
-	}
-}
-
 func TestImageExists(t *testing.T) {
 	var tests = []struct {
 		runtime string
diff --git a/pkg/minikube/driver/driver_test.go b/pkg/minikube/driver/driver_test.go
index 67855fb50..4a04f4567 100644
--- a/pkg/minikube/driver/driver_test.go
+++ b/pkg/minikube/driver/driver_test.go
@@ -85,7 +85,7 @@ func TestMachineType(t *testing.T) {
 }
 
 func TestFlagDefaults(t *testing.T) {
-	expected := FlagHints{CacheImages: true, ExtraOptions: []string{"kubelet.global-housekeeping-interval=60m", "kubelet.housekeeping-interval=5m"}}
+	expected := FlagHints{CacheImages: true, ExtraOptions: []string{"kubelet.housekeeping-interval=5m"}}
 	if diff := cmp.Diff(FlagDefaults(VirtualBox), expected); diff != "" {
 		t.Errorf("defaults mismatch (-want +got):\n%s", diff)
 	}
@@ -98,7 +98,7 @@ func TestFlagDefaults(t *testing.T) {
 
 	expected = FlagHints{
 		CacheImages:  false,
-		ExtraOptions: []string{"kubelet.global-housekeeping-interval=60m", "kubelet.housekeeping-interval=5m", fmt.Sprintf("kubelet.resolv-conf=%s", tf.Name())},
+		ExtraOptions: []string{"kubelet.housekeeping-interval=5m", fmt.Sprintf("kubelet.resolv-conf=%s", tf.Name())},
 	}
 	systemdResolvConf = tf.Name()
 	if diff := cmp.Diff(FlagDefaults(None), expected); diff != "" {