...
1
16
17 package kubeadm
18
19 import (
20 "context"
21
22 rbacv1 "k8s.io/api/rbac/v1"
23 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24 "k8s.io/kubernetes/test/e2e/framework"
25 admissionapi "k8s.io/pod-security-admission/api"
26
27 "github.com/onsi/ginkgo/v2"
28 "github.com/onsi/gomega"
29 )
30
31 const (
32 nodesGroup = "system:nodes"
33 nodesCertificateRotationClusterRoleName = "system:certificates.k8s.io:certificatesigningrequests:selfnodeclient"
34 nodesCertificateRotationClusterRoleBinding = "kubeadm:node-autoapprove-certificate-rotation"
35 nodesCRISocketAnnotation = "kubeadm.alpha.kubernetes.io/cri-socket"
36 )
37
38
39
40 var _ = Describe("nodes", func() {
41
42
43 f := framework.NewDefaultFramework("nodes")
44 f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
45
46
47
48 f.SkipNamespaceCreation = true
49
50 ginkgo.It("should have CRI annotation", func(ctx context.Context) {
51 nodes, err := f.ClientSet.CoreV1().Nodes().
52 List(ctx, metav1.ListOptions{})
53 framework.ExpectNoError(err, "error reading nodes")
54
55
56
57 for _, node := range nodes.Items {
58 gomega.Expect(node.Annotations).To(gomega.HaveKey(nodesCRISocketAnnotation))
59 gomega.Expect(node.Annotations[nodesCRISocketAnnotation]).To(gomega.HavePrefix("unix://"))
60 }
61 })
62
63 ginkgo.It("should be allowed to rotate CSR", func(ctx context.Context) {
64
65 ExpectClusterRoleBindingWithSubjectAndRole(f.ClientSet,
66 nodesCertificateRotationClusterRoleBinding,
67 rbacv1.GroupKind, nodesGroup,
68 nodesCertificateRotationClusterRoleName,
69 )
70 })
71 })
72
View as plain text