@@ -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"
@@ -53,8 +54,8 @@ func TestNetworkPlugins(t *testing.T) {
53
54
podLabel string
54
55
hairpin bool
55
56
}{
56
- // for containerd and crio runtimes kindnet CNI is used by default and hairpin is enabled
57
- {"auto" , []string {}, "" , "" , ContainerRuntime () != "docker" },
57
+ // kindnet CNI is used by default and hairpin is enabled
58
+ {"auto" , []string {}, "" , "" , usingCNI () },
58
59
{"kubenet" , []string {"--network-plugin=kubenet" }, "kubenet" , "" , true },
59
60
{"bridge" , []string {"--cni=bridge" }, "cni" , "" , true },
60
61
{"enable-default-cni" , []string {"--enable-default-cni=true" }, "cni" , "" , true },
@@ -79,15 +80,14 @@ func TestNetworkPlugins(t *testing.T) {
79
80
t .Skipf ("flannel is not yet compatible with Docker driver: iptables v1.8.3 (legacy): Couldn't load target `CNI-x': No such file or directory" )
80
81
}
81
82
82
- if ContainerRuntime () != "docker" && tc .name == "false" {
83
+ if usingCNI () && tc .name == "false" {
83
84
// CNI is required for current container runtime
84
85
validateFalseCNI (ctx , t , profile )
85
86
return
86
87
}
87
88
88
- if ContainerRuntime () != "docker" && tc .name == "kubenet" {
89
+ if usingCNI () && tc .name == "kubenet" {
89
90
// CNI is disabled when --network-plugin=kubenet option is passed. See cni.New(..) function
90
- // But for containerd/crio CNI has to be configured
91
91
t .Skipf ("Skipping the test as %s container runtimes requires CNI" , ContainerRuntime ())
92
92
}
93
93
@@ -207,6 +207,21 @@ func TestNetworkPlugins(t *testing.T) {
207
207
})
208
208
}
209
209
210
+ // usingCNI checks if not using dockershim
211
+ func usingCNI () bool {
212
+ if ContainerRuntime () != "docker" {
213
+ return true
214
+ }
215
+ version , err := util .ParseKubernetesVersion (constants .DefaultKubernetesVersion )
216
+ if err != nil {
217
+ return false
218
+ }
219
+ if version .GTE (semver .MustParse ("1.24.0-alpha.2" )) {
220
+ return true
221
+ }
222
+ return false
223
+ }
224
+
210
225
// validateFalseCNI checks that minikube returns and error
211
226
// if container runtime is "containerd" or "crio"
212
227
// and --cni=false
0 commit comments