@@ -40,6 +40,7 @@ import (
40
40
"k8s.io/kubernetes/test/e2e/framework"
41
41
"k8s.io/kubernetes/test/utils/crd"
42
42
imageutils "k8s.io/kubernetes/test/utils/image"
43
+ "k8s.io/utils/pointer"
43
44
44
45
. "github.com/onsi/ginkgo"
45
46
. "github.com/onsi/gomega"
@@ -50,6 +51,7 @@ const (
50
51
secretName = "sample-webhook-secret"
51
52
deploymentName = "sample-webhook-deployment"
52
53
serviceName = "e2e-test-webhook"
54
+ servicePort = 8443
53
55
roleBindingName = "webhook-auth-reader"
54
56
55
57
// The webhook configuration names should not be reused between test instances.
@@ -208,17 +210,17 @@ var _ = SIGDescribe("AdmissionWebhook", func() {
208
210
policyIgnore := v1beta1 .Ignore
209
211
210
212
By ("Setting timeout (1s) shorter than webhook latency (5s)" )
211
- slowWebhookCleanup := registerSlowWebhook (f , context , & policyFail , int32Ptr (1 ))
213
+ slowWebhookCleanup := registerSlowWebhook (f , context , & policyFail , pointer . Int32Ptr (1 ))
212
214
testSlowWebhookTimeoutFailEarly (f )
213
215
slowWebhookCleanup ()
214
216
215
217
By ("Having no error when timeout is shorter than webhook latency and failure policy is ignore" )
216
- slowWebhookCleanup = registerSlowWebhook (f , context , & policyIgnore , int32Ptr (1 ))
218
+ slowWebhookCleanup = registerSlowWebhook (f , context , & policyIgnore , pointer . Int32Ptr (1 ))
217
219
testSlowWebhookTimeoutNoError (f )
218
220
slowWebhookCleanup ()
219
221
220
222
By ("Having no error when timeout is longer than webhook latency" )
221
- slowWebhookCleanup = registerSlowWebhook (f , context , & policyFail , int32Ptr (10 ))
223
+ slowWebhookCleanup = registerSlowWebhook (f , context , & policyFail , pointer . Int32Ptr (10 ))
222
224
testSlowWebhookTimeoutNoError (f )
223
225
slowWebhookCleanup ()
224
226
@@ -368,7 +370,7 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
368
370
Ports : []v1.ServicePort {
369
371
{
370
372
Protocol : "TCP" ,
371
- Port : 443 ,
373
+ Port : servicePort ,
372
374
TargetPort : intstr .FromInt (443 ),
373
375
},
374
376
},
@@ -384,8 +386,6 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
384
386
385
387
func strPtr (s string ) * string { return & s }
386
388
387
- func int32Ptr (i int32 ) * int32 { return & i }
388
-
389
389
func registerWebhook (f * framework.Framework , context * certContext ) func () {
390
390
client := f .ClientSet
391
391
By ("Registering the webhook via the AdmissionRegistration API" )
@@ -417,6 +417,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() {
417
417
Namespace : namespace ,
418
418
Name : serviceName ,
419
419
Path : strPtr ("/pods" ),
420
+ Port : pointer .Int32Ptr (servicePort ),
420
421
},
421
422
CABundle : context .signingCert ,
422
423
},
@@ -446,6 +447,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() {
446
447
Namespace : namespace ,
447
448
Name : serviceName ,
448
449
Path : strPtr ("/configmaps" ),
450
+ Port : pointer .Int32Ptr (servicePort ),
449
451
},
450
452
CABundle : context .signingCert ,
451
453
},
@@ -496,6 +498,7 @@ func registerWebhookForAttachingPod(f *framework.Framework, context *certContext
496
498
Namespace : namespace ,
497
499
Name : serviceName ,
498
500
Path : strPtr ("/pods/attach" ),
501
+ Port : pointer .Int32Ptr (servicePort ),
499
502
},
500
503
CABundle : context .signingCert ,
501
504
},
@@ -539,6 +542,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo
539
542
Namespace : namespace ,
540
543
Name : serviceName ,
541
544
Path : strPtr ("/mutating-configmaps" ),
545
+ Port : pointer .Int32Ptr (servicePort ),
542
546
},
543
547
CABundle : context .signingCert ,
544
548
},
@@ -558,6 +562,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo
558
562
Namespace : namespace ,
559
563
Name : serviceName ,
560
564
Path : strPtr ("/mutating-configmaps" ),
565
+ Port : pointer .Int32Ptr (servicePort ),
561
566
},
562
567
CABundle : context .signingCert ,
563
568
},
@@ -614,6 +619,7 @@ func registerMutatingWebhookForPod(f *framework.Framework, context *certContext)
614
619
Namespace : namespace ,
615
620
Name : serviceName ,
616
621
Path : strPtr ("/mutating-pods" ),
622
+ Port : pointer .Int32Ptr (servicePort ),
617
623
},
618
624
CABundle : context .signingCert ,
619
625
},
@@ -786,6 +792,7 @@ func failingWebhook(namespace, name string) v1beta1.Webhook {
786
792
Namespace : namespace ,
787
793
Name : serviceName ,
788
794
Path : strPtr ("/configmaps" ),
795
+ Port : pointer .Int32Ptr (servicePort ),
789
796
},
790
797
// Without CA bundle, the call to webhook always fails
791
798
CABundle : nil ,
@@ -892,6 +899,7 @@ func registerValidatingWebhookForWebhookConfigurations(f *framework.Framework, c
892
899
Namespace : namespace ,
893
900
Name : serviceName ,
894
901
Path : strPtr ("/always-deny" ),
902
+ Port : pointer .Int32Ptr (servicePort ),
895
903
},
896
904
CABundle : context .signingCert ,
897
905
},
@@ -944,6 +952,7 @@ func registerMutatingWebhookForWebhookConfigurations(f *framework.Framework, con
944
952
Namespace : namespace ,
945
953
Name : serviceName ,
946
954
Path : strPtr ("/add-label" ),
955
+ Port : pointer .Int32Ptr (servicePort ),
947
956
},
948
957
CABundle : context .signingCert ,
949
958
},
@@ -997,6 +1006,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) {
997
1006
// but because the failure policy is ignore, it will
998
1007
// have no effect on admission requests.
999
1008
Path : strPtr ("" ),
1009
+ Port : pointer .Int32Ptr (servicePort ),
1000
1010
},
1001
1011
CABundle : nil ,
1002
1012
},
@@ -1044,6 +1054,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) {
1044
1054
// but because the failure policy is ignore, it will
1045
1055
// have no effect on admission requests.
1046
1056
Path : strPtr ("" ),
1057
+ Port : pointer .Int32Ptr (servicePort ),
1047
1058
},
1048
1059
CABundle : nil ,
1049
1060
},
@@ -1213,6 +1224,7 @@ func registerWebhookForCustomResource(f *framework.Framework, context *certConte
1213
1224
Namespace : namespace ,
1214
1225
Name : serviceName ,
1215
1226
Path : strPtr ("/custom-resource" ),
1227
+ Port : pointer .Int32Ptr (servicePort ),
1216
1228
},
1217
1229
CABundle : context .signingCert ,
1218
1230
},
@@ -1254,6 +1266,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
1254
1266
Namespace : namespace ,
1255
1267
Name : serviceName ,
1256
1268
Path : strPtr ("/mutating-custom-resource" ),
1269
+ Port : pointer .Int32Ptr (servicePort ),
1257
1270
},
1258
1271
CABundle : context .signingCert ,
1259
1272
},
@@ -1273,6 +1286,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c
1273
1286
Namespace : namespace ,
1274
1287
Name : serviceName ,
1275
1288
Path : strPtr ("/mutating-custom-resource" ),
1289
+ Port : pointer .Int32Ptr (servicePort ),
1276
1290
},
1277
1291
CABundle : context .signingCert ,
1278
1292
},
@@ -1401,6 +1415,7 @@ func registerValidatingWebhookForCRD(f *framework.Framework, context *certContex
1401
1415
Namespace : namespace ,
1402
1416
Name : serviceName ,
1403
1417
Path : strPtr ("/crd" ),
1418
+ Port : pointer .Int32Ptr (servicePort ),
1404
1419
},
1405
1420
CABundle : context .signingCert ,
1406
1421
},
@@ -1512,6 +1527,7 @@ func registerSlowWebhook(f *framework.Framework, context *certContext, policy *v
1512
1527
Namespace : namespace ,
1513
1528
Name : serviceName ,
1514
1529
Path : strPtr ("/always-allow-delay-5s" ),
1530
+ Port : pointer .Int32Ptr (servicePort ),
1515
1531
},
1516
1532
CABundle : context .signingCert ,
1517
1533
},
0 commit comments