diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index a2fb8000cf19..a08e50631d22 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -209,7 +209,8 @@ func runStart(cmd *cobra.Command, args []string) { selectedEnableDefaultCNI := viper.GetBool(enableDefaultCNI) // default network plugin (cni) - if selectedContainerRuntime != "" { + r, err := cruntime.New(cruntime.Config{Type: selectedContainerRuntime}) + if err == nil && r.DefaultCNI() { if !cmd.Flags().Changed(networkPlugin) { selectedNetworkPlugin = "cni" if !cmd.Flags().Changed(enableDefaultCNI) { diff --git a/pkg/minikube/cruntime/containerd.go b/pkg/minikube/cruntime/containerd.go index 46c23060a307..8b4e5aadb730 100644 --- a/pkg/minikube/cruntime/containerd.go +++ b/pkg/minikube/cruntime/containerd.go @@ -41,6 +41,11 @@ func (r *Containerd) SocketPath() string { return "/run/containerd/containerd.sock" } +// DefaultCNI returns whether to use CNI networking by default +func (r *Containerd) DefaultCNI() bool { + return true +} + // Active returns if containerd is active on the host func (r *Containerd) Active() bool { err := r.Runner.Run("systemctl is-active --quiet service containerd") diff --git a/pkg/minikube/cruntime/crio.go b/pkg/minikube/cruntime/crio.go index 4d81d6068989..a7421e0f7d04 100644 --- a/pkg/minikube/cruntime/crio.go +++ b/pkg/minikube/cruntime/crio.go @@ -41,6 +41,11 @@ func (r *CRIO) SocketPath() string { return "/var/run/crio/crio.sock" } +// DefaultCNI returns whether to use CNI networking by default +func (r *CRIO) DefaultCNI() bool { + return true +} + // Available returns an error if it is not possible to use this runtime on a host func (r *CRIO) Available() error { return r.Runner.Run("command -v crio") diff --git a/pkg/minikube/cruntime/cruntime.go b/pkg/minikube/cruntime/cruntime.go index 6db7b7a504c6..9f478086164d 100644 --- a/pkg/minikube/cruntime/cruntime.go +++ b/pkg/minikube/cruntime/cruntime.go @@ -49,6 +49,8 @@ type Manager interface { KubeletOptions() map[string]string // SocketPath returns the path to the socket file for a given runtime SocketPath() string + // DefaultCNI returns whether to use CNI networking by default + DefaultCNI() bool // Load an image idempotently into the runtime on a host LoadImage(string) error diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index fb4f7bf6424a..92f4c0bb5485 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -40,6 +40,11 @@ func (r *Docker) SocketPath() string { return r.Socket } +// DefaultCNI returns whether to use CNI networking by default +func (r *Docker) DefaultCNI() bool { + return false +} + // Available returns an error if it is not possible to use this runtime on a host func (r *Docker) Available() error { _, err := exec.LookPath("docker")