@@ -31,6 +31,7 @@ import (
31
31
"github.com/blang/semver/v4"
32
32
"k8s.io/minikube/pkg/kapi"
33
33
"k8s.io/minikube/pkg/minikube/config"
34
+ "k8s.io/minikube/pkg/minikube/constants"
34
35
"k8s.io/minikube/pkg/minikube/reason"
35
36
"k8s.io/minikube/pkg/util"
36
37
"k8s.io/minikube/pkg/util/retry"
@@ -57,7 +58,8 @@ func TestNetworkPlugins(t *testing.T) {
57
58
namespace string
58
59
hairpin bool
59
60
}{
60
- {"auto" , []string {}, "" , "" , "" , true },
61
+ // kindnet CNI is used by default and hairpin is enabled
62
+ {"auto" , []string {}, "" , "" , "" , usingCNI ()},
61
63
{"kubenet" , []string {"--network-plugin=kubenet" }, "kubenet" , "" , "" , true },
62
64
{"bridge" , []string {"--cni=bridge" }, "cni" , "" , "" , true },
63
65
{"enable-default-cni" , []string {"--enable-default-cni=true" }, "cni" , "" , "" , true },
@@ -80,15 +82,14 @@ func TestNetworkPlugins(t *testing.T) {
80
82
// collect debug logs
81
83
defer debugLogs (t , profile )
82
84
83
- if ContainerRuntime () != "docker" && tc .name == "false" {
85
+ if usingCNI () && tc .name == "false" {
84
86
// CNI is required for current container runtime
85
87
validateFalseCNI (ctx , t , profile )
86
88
return
87
89
}
88
90
89
- if ContainerRuntime () != "docker" && tc .name == "kubenet" {
91
+ if usingCNI () && tc .name == "kubenet" {
90
92
// CNI is disabled when --network-plugin=kubenet option is passed. See cni.New(..) function
91
- // But for containerd/crio CNI has to be configured
92
93
t .Skipf ("Skipping the test as %s container runtimes requires CNI" , ContainerRuntime ())
93
94
}
94
95
@@ -212,6 +213,21 @@ func TestNetworkPlugins(t *testing.T) {
212
213
})
213
214
}
214
215
216
+ // usingCNI checks if not using dockershim
217
+ func usingCNI () bool {
218
+ if ContainerRuntime () != "docker" {
219
+ return true
220
+ }
221
+ version , err := util .ParseKubernetesVersion (constants .DefaultKubernetesVersion )
222
+ if err != nil {
223
+ return false
224
+ }
225
+ if version .GTE (semver .MustParse ("1.24.0-alpha.2" )) {
226
+ return true
227
+ }
228
+ return false
229
+ }
230
+
215
231
// validateFalseCNI checks that minikube returns and error
216
232
// if container runtime is "containerd" or "crio"
217
233
// and --cni=false
0 commit comments