@@ -20,7 +20,6 @@ import (
20
20
"context"
21
21
22
22
"k8s.io/kubernetes/test/e2e/framework"
23
- e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
24
23
admissionapi "k8s.io/pod-security-admission/api"
25
24
26
25
"github.com/onsi/ginkgo/v2"
@@ -36,17 +35,10 @@ const (
36
35
coreDNSRoleName = "system:coredns"
37
36
coreDNSRoleBindingName = coreDNSRoleName
38
37
coreDNSDeploymentName = "coredns"
39
-
40
- kubeDNSServiceAccountName = "kube-dns"
41
- kubeDNSDeploymentName = "kube-dns"
42
- )
43
-
44
- var (
45
- dnsType = ""
46
38
)
47
39
48
40
// Define container for all the test specification aimed at verifying
49
- // that kubeadm configures the dns as expected
41
+ // that kubeadm configures the DNS addon as expected
50
42
var _ = Describe ("DNS addon" , func () {
51
43
52
44
// Get an instance of the k8s test framework
@@ -57,91 +49,28 @@ var _ = Describe("DNS addon", func() {
57
49
// so we are disabling the creation of a namespace in order to get a faster execution
58
50
f .SkipNamespaceCreation = true
59
51
60
- // kubeadm supports two type of DNS addon, and so
61
- // it is necessary to get it from the kubeadm-config ConfigMap before testing
62
- ginkgo .BeforeEach (func () {
63
- // if the dnsType name is already known exit
64
- if dnsType != "" {
65
- return
66
- }
67
-
68
- // gets the ClusterConfiguration from the kubeadm kubeadm-config ConfigMap as a untyped map
69
- m := getClusterConfiguration (f .ClientSet )
70
-
71
- // Extract the dnsType
72
- dnsType = "CoreDNS"
73
- if _ , ok := m ["dns" ]; ok {
74
- d := m ["dns" ].(map [interface {}]interface {})
75
- if t , ok := d ["type" ]; ok {
76
- dnsType = t .(string )
77
- }
78
- }
79
- })
80
-
81
- ginkgo .Context ("kube-dns" , func () {
82
- ginkgo .Context ("kube-dns ServiceAccount" , func () {
83
- ginkgo .It ("should exist" , func (ctx context.Context ) {
84
- if dnsType != "kube-dns" {
85
- e2eskipper .Skipf ("Skipping because DNS type is %s" , dnsType )
86
- }
87
-
88
- ExpectServiceAccount (f .ClientSet , kubeSystemNamespace , kubeDNSServiceAccountName )
89
- })
90
- })
91
-
92
- ginkgo .Context ("kube-dns Deployment" , func () {
93
- ginkgo .It ("should exist and be properly configured" , func (ctx context.Context ) {
94
- if dnsType != "kube-dns" {
95
- e2eskipper .Skipf ("Skipping because DNS type is %s" , dnsType )
96
- }
97
-
98
- d := GetDeployment (f .ClientSet , kubeSystemNamespace , kubeDNSDeploymentName )
99
-
100
- gomega .Expect (d .Spec .Template .Spec .ServiceAccountName ).To (gomega .Equal (kubeDNSServiceAccountName ))
101
- })
102
- })
103
- })
104
-
105
52
ginkgo .Context ("CoreDNS" , func () {
106
53
ginkgo .Context ("CoreDNS ServiceAccount" , func () {
107
54
ginkgo .It ("should exist" , func (ctx context.Context ) {
108
- if dnsType != "CoreDNS" {
109
- e2eskipper .Skipf ("Skipping because DNS type is %s" , dnsType )
110
- }
111
-
112
55
ExpectServiceAccount (f .ClientSet , kubeSystemNamespace , coreDNSServiceAccountName )
113
56
})
114
57
115
58
ginkgo .It ("should have related ClusterRole and ClusterRoleBinding" , func (ctx context.Context ) {
116
- if dnsType != "CoreDNS" {
117
- e2eskipper .Skipf ("Skipping because DNS type is %s" , dnsType )
118
- }
119
-
120
59
ExpectClusterRole (f .ClientSet , coreDNSRoleName )
121
60
ExpectClusterRoleBinding (f .ClientSet , coreDNSRoleBindingName )
122
61
})
123
62
})
124
63
125
64
ginkgo .Context ("CoreDNS ConfigMap" , func () {
126
65
ginkgo .It ("should exist and be properly configured" , func (ctx context.Context ) {
127
- if dnsType != "CoreDNS" {
128
- e2eskipper .Skipf ("Skipping because DNS type is %s" , dnsType )
129
- }
130
-
131
66
cm := GetConfigMap (f .ClientSet , kubeSystemNamespace , coreDNSConfigMap )
132
-
133
67
gomega .Expect (cm .Data ).To (gomega .HaveKey (coreDNSConfigMapKey ))
134
68
})
135
69
})
136
70
137
71
ginkgo .Context ("CoreDNS Deployment" , func () {
138
72
ginkgo .It ("should exist and be properly configured" , func (ctx context.Context ) {
139
- if dnsType != "CoreDNS" {
140
- e2eskipper .Skipf ("Skipping because DNS type is %s" , dnsType )
141
- }
142
-
143
73
d := GetDeployment (f .ClientSet , kubeSystemNamespace , coreDNSDeploymentName )
144
-
145
74
gomega .Expect (d .Spec .Template .Spec .ServiceAccountName ).To (gomega .Equal (coreDNSServiceAccountName ))
146
75
})
147
76
})
0 commit comments