@@ -30,7 +30,7 @@ import (
30
30
"testing"
31
31
"time"
32
32
33
- "k8s.io/api/certificates/v1alpha1 "
33
+ "k8s.io/api/certificates/v1beta1 "
34
34
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35
35
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructuredscheme"
36
36
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -47,9 +47,6 @@ import (
47
47
)
48
48
49
49
func TestClusterTrustBundlesPublisherController (t * testing.T ) {
50
- // KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE allows for APIs pending removal to not block tests
51
- // TODO: Remove this line once certificates v1alpha1 types to be removed in 1.32 are fully removed
52
- t .Setenv ("KUBE_APISERVER_SERVE_REMOVED_APIS_FOR_ONE_RELEASE" , "true" )
53
50
ctx := ktesting .Init (t )
54
51
55
52
certBytes := mustMakeCertificate (t , & x509.Certificate {
@@ -73,7 +70,7 @@ func TestClusterTrustBundlesPublisherController(t *testing.T) {
73
70
"--disable-admission-plugins" , "ServiceAccount" ,
74
71
"--authorization-mode=RBAC" ,
75
72
"--feature-gates" , "ClusterTrustBundle=true" ,
76
- fmt .Sprintf ("--runtime-config=%s=true" , v1alpha1 .SchemeGroupVersion ),
73
+ fmt .Sprintf ("--runtime-config=%s=true" , v1beta1 .SchemeGroupVersion ),
77
74
}
78
75
storageConfig := framework .SharedEtcd ()
79
76
server := kubeapiservertesting .StartTestServerOrDie (t , nil , apiServerFlags , storageConfig )
@@ -108,12 +105,12 @@ func TestClusterTrustBundlesPublisherController(t *testing.T) {
108
105
unrelatedPEM := pem .EncodeToMemory (& pem.Block {Type : "CERTIFICATE" , Bytes : unrelatedSigner })
109
106
// set up a signer that's completely unrelated to the controller to check
110
107
// it's not anyhow handled by it
111
- unrelatedCTB , err := clientSet .CertificatesV1alpha1 ().ClusterTrustBundles ().Create (ctx ,
112
- & v1alpha1 .ClusterTrustBundle {
108
+ unrelatedCTB , err := clientSet .CertificatesV1beta1 ().ClusterTrustBundles ().Create (ctx ,
109
+ & v1beta1 .ClusterTrustBundle {
113
110
ObjectMeta : metav1.ObjectMeta {
114
111
Name : "test.test:unrelated:0" ,
115
112
},
116
- Spec : v1alpha1 .ClusterTrustBundleSpec {
113
+ Spec : v1beta1 .ClusterTrustBundleSpec {
117
114
SignerName : "test.test/unrelated" ,
118
115
TrustBundle : string (unrelatedPEM ),
119
116
},
@@ -127,11 +124,11 @@ func TestClusterTrustBundlesPublisherController(t *testing.T) {
127
124
waitUntilSingleKASSignerCTB (ctx , t , clientSet , certPEM )
128
125
129
126
t .Log ("check that the controller deletes any additional bundles for the same signer" )
130
- if _ , err := clientSet .CertificatesV1alpha1 ().ClusterTrustBundles ().Create (ctx , & v1alpha1 .ClusterTrustBundle {
127
+ if _ , err := clientSet .CertificatesV1beta1 ().ClusterTrustBundles ().Create (ctx , & v1beta1 .ClusterTrustBundle {
131
128
ObjectMeta : metav1.ObjectMeta {
132
129
Name : "kubernetes.io:kube-apiserver-serving:testname" ,
133
130
},
134
- Spec : v1alpha1 .ClusterTrustBundleSpec {
131
+ Spec : v1beta1 .ClusterTrustBundleSpec {
135
132
SignerName : "kubernetes.io/kube-apiserver-serving" ,
136
133
TrustBundle : string (certPEM ),
137
134
},
@@ -152,7 +149,7 @@ func TestClusterTrustBundlesPublisherController(t *testing.T) {
152
149
})
153
150
differentSignerPEM := pem .EncodeToMemory (& pem.Block {Type : "CERTIFICATE" , Bytes : differentSigner })
154
151
155
- ctbList , err := clientSet .CertificatesV1alpha1 ().ClusterTrustBundles ().List (ctx , metav1.ListOptions {
152
+ ctbList , err := clientSet .CertificatesV1beta1 ().ClusterTrustBundles ().List (ctx , metav1.ListOptions {
156
153
FieldSelector : "spec.signerName=kubernetes.io/kube-apiserver-serving" ,
157
154
})
158
155
if err != nil || len (ctbList .Items ) != 1 {
@@ -162,13 +159,13 @@ func TestClusterTrustBundlesPublisherController(t *testing.T) {
162
159
ctbToUpdate := ctbList .Items [0 ].DeepCopy ()
163
160
ctbToUpdate .Spec .TrustBundle = string (differentSignerPEM )
164
161
165
- if _ , err = clientSet .CertificatesV1alpha1 ().ClusterTrustBundles ().Update (ctx , ctbToUpdate , metav1.UpdateOptions {}); err != nil {
162
+ if _ , err = clientSet .CertificatesV1beta1 ().ClusterTrustBundles ().Update (ctx , ctbToUpdate , metav1.UpdateOptions {}); err != nil {
166
163
t .Fatalf ("failed to update ctb with new PEM bundle: %v" , err )
167
164
}
168
165
169
166
waitUntilSingleKASSignerCTB (ctx , t , clientSet , certPEM )
170
167
171
- unrelatedCTB , err = clientSet .CertificatesV1alpha1 ().ClusterTrustBundles ().Get (ctx , unrelatedCTB .Name , metav1.GetOptions {})
168
+ unrelatedCTB , err = clientSet .CertificatesV1beta1 ().ClusterTrustBundles ().Get (ctx , unrelatedCTB .Name , metav1.GetOptions {})
172
169
if err != nil {
173
170
t .Fatalf ("failed to get the unrelated CTB back: %v" , err )
174
171
}
@@ -184,7 +181,7 @@ func TestClusterTrustBundlesPublisherController(t *testing.T) {
184
181
185
182
func waitUntilSingleKASSignerCTB (ctx context.Context , t * testing.T , clientSet * clientset.Clientset , caPEM []byte ) {
186
183
err := wait .PollUntilContextTimeout (ctx , 200 * time .Millisecond , 30 * time .Second , true , func (ctx context.Context ) (done bool , err error ) {
187
- ctbList , err := clientSet .CertificatesV1alpha1 ().ClusterTrustBundles ().List (ctx , metav1.ListOptions {
184
+ ctbList , err := clientSet .CertificatesV1beta1 ().ClusterTrustBundles ().List (ctx , metav1.ListOptions {
188
185
FieldSelector : "spec.signerName=kubernetes.io/kube-apiserver-serving" ,
189
186
})
190
187
0 commit comments