...
1
16
17 package kubeadm
18
19 import (
20 "context"
21
22 "k8s.io/kubernetes/test/e2e/framework"
23 admissionapi "k8s.io/pod-security-admission/api"
24
25 "github.com/onsi/ginkgo/v2"
26 "github.com/onsi/gomega"
27 )
28
29 const (
30 dnsService = "kube-dns"
31
32 coreDNSServiceAccountName = "coredns"
33 coreDNSConfigMap = "coredns"
34 coreDNSConfigMapKey = "Corefile"
35 coreDNSRoleName = "system:coredns"
36 coreDNSRoleBindingName = coreDNSRoleName
37 coreDNSDeploymentName = "coredns"
38 )
39
40
41
42 var _ = Describe("DNS addon", func() {
43
44
45 f := framework.NewDefaultFramework("DNS")
46 f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
47
48
49
50 f.SkipNamespaceCreation = true
51
52 ginkgo.Context("CoreDNS", func() {
53 ginkgo.Context("CoreDNS ServiceAccount", func() {
54 ginkgo.It("should exist", func(ctx context.Context) {
55 ExpectServiceAccount(f.ClientSet, kubeSystemNamespace, coreDNSServiceAccountName)
56 })
57
58 ginkgo.It("should have related ClusterRole and ClusterRoleBinding", func(ctx context.Context) {
59 ExpectClusterRole(f.ClientSet, coreDNSRoleName)
60 ExpectClusterRoleBinding(f.ClientSet, coreDNSRoleBindingName)
61 })
62 })
63
64 ginkgo.Context("CoreDNS ConfigMap", func() {
65 ginkgo.It("should exist and be properly configured", func(ctx context.Context) {
66 cm := GetConfigMap(f.ClientSet, kubeSystemNamespace, coreDNSConfigMap)
67 gomega.Expect(cm.Data).To(gomega.HaveKey(coreDNSConfigMapKey))
68 })
69 })
70
71 ginkgo.Context("CoreDNS Deployment", func() {
72 ginkgo.It("should exist and be properly configured", func(ctx context.Context) {
73 d := GetDeployment(f.ClientSet, kubeSystemNamespace, coreDNSDeploymentName)
74 gomega.Expect(d.Spec.Template.Spec.ServiceAccountName).To(gomega.Equal(coreDNSServiceAccountName))
75 })
76 })
77 })
78
79 ginkgo.Context("DNS Service", func() {
80 ginkgo.It("should exist", func(ctx context.Context) {
81 ExpectService(f.ClientSet, kubeSystemNamespace, dnsService)
82 })
83 })
84 })
85
View as plain text