@@ -419,13 +419,16 @@ var _ = SIGDescribe("AdmissionWebhook [Privileged:ClusterAdmin]", func() {
419
419
},
420
420
Webhooks : []admissionregistrationv1.ValidatingWebhook {
421
421
newDenyConfigMapWebhookFixture (f , context , servicePort ),
422
+ newValidatingIsReadyWebhookFixture (f , context , servicePort ),
422
423
},
423
424
})
424
425
framework .ExpectNoError (err , "Creating validating webhook configuration" )
425
426
defer func () {
426
427
err := client .AdmissionregistrationV1 ().ValidatingWebhookConfigurations ().Delete (hook .Name , nil )
427
428
framework .ExpectNoError (err , "Deleting validating webhook configuration" )
428
429
}()
430
+ // ensure backend is ready before proceeding
431
+ waitWebhookConfigurationReady (f )
429
432
ginkgo .By ("Creating a configMap that does not comply to the validation webhook rules" )
430
433
err = wait .PollImmediate (100 * time .Millisecond , 30 * time .Second , func () (bool , error ) {
431
434
cm := namedNonCompliantConfigMap (string (uuid .NewUUID ()), f )
@@ -509,14 +512,16 @@ var _ = SIGDescribe("AdmissionWebhook [Privileged:ClusterAdmin]", func() {
509
512
},
510
513
Webhooks : []admissionregistrationv1.MutatingWebhook {
511
514
newMutateConfigMapWebhookFixture (f , context , 1 , servicePort ),
515
+ newMutatingIsReadyWebhookFixture (f , context , servicePort ),
512
516
},
513
517
})
514
518
framework .ExpectNoError (err , "Creating mutating webhook configuration" )
515
519
defer func () {
516
520
err := client .AdmissionregistrationV1 ().MutatingWebhookConfigurations ().Delete (hook .Name , nil )
517
521
framework .ExpectNoError (err , "Deleting mutating webhook configuration" )
518
522
}()
519
-
523
+ // ensure backend is ready before proceeding
524
+ waitWebhookConfigurationReady (f )
520
525
hook , err = admissionClient .MutatingWebhookConfigurations ().Get (f .UniqueName , metav1.GetOptions {})
521
526
framework .ExpectNoError (err , "Getting mutating webhook configuration" )
522
527
ginkgo .By ("Updating a mutating webhook configuration's rules to not include the create operation" )
@@ -778,6 +783,18 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert
778
783
// Use a non-default port for containers.
779
784
fmt .Sprintf ("--port=%d" , containerPort ),
780
785
},
786
+ ReadinessProbe : & v1.Probe {
787
+ Handler : v1.Handler {
788
+ HTTPGet : & v1.HTTPGetAction {
789
+ Scheme : v1 .URISchemeHTTPS ,
790
+ Port : intstr .FromInt (int (containerPort )),
791
+ Path : "/readyz" ,
792
+ },
793
+ },
794
+ PeriodSeconds : 1 ,
795
+ SuccessThreshold : 1 ,
796
+ FailureThreshold : 30 ,
797
+ },
781
798
Image : image ,
782
799
Ports : []v1.ContainerPort {{ContainerPort : containerPort }},
783
800
},
@@ -2049,8 +2066,8 @@ func registerValidatingWebhookForCRD(f *framework.Framework, configName string,
2049
2066
},
2050
2067
SideEffects : & sideEffectsNone ,
2051
2068
AdmissionReviewVersions : []string {"v1" , "v1beta1" },
2052
- // Scope the webhook to just this namespace
2053
- NamespaceSelector : & metav1.LabelSelector {
2069
+ // Scope the webhook to just this test
2070
+ ObjectSelector : & metav1.LabelSelector {
2054
2071
MatchLabels : map [string ]string {f .UniqueName : "true" },
2055
2072
},
2056
2073
},
@@ -2101,6 +2118,9 @@ func testCRDDenyWebhook(f *framework.Framework) {
2101
2118
ObjectMeta : metav1.ObjectMeta {
2102
2119
Name : name + "s." + group ,
2103
2120
Labels : map [string ]string {
2121
+ // this label ensures our object is routed to this test's webhook
2122
+ f .UniqueName : "true" ,
2123
+ // this is the label the webhook disallows
2104
2124
"webhook-e2e-test" : "webhook-disallow" ,
2105
2125
},
2106
2126
},
@@ -2434,6 +2454,7 @@ func waitWebhookConfigurationReady(f *framework.Framework) error {
2434
2454
// with "marker" requests via waitWebhookConfigurationReady to wait for a webhook configuration to be ready.
2435
2455
func newValidatingIsReadyWebhookFixture (f * framework.Framework , context * certContext , servicePort int32 ) admissionregistrationv1.ValidatingWebhook {
2436
2456
sideEffectsNone := admissionregistrationv1 .SideEffectClassNone
2457
+ failOpen := admissionregistrationv1 .Ignore
2437
2458
return admissionregistrationv1.ValidatingWebhook {
2438
2459
Name : "validating-is-webhook-configuration-ready.k8s.io" ,
2439
2460
Rules : []admissionregistrationv1.RuleWithOperations {{
@@ -2453,6 +2474,8 @@ func newValidatingIsReadyWebhookFixture(f *framework.Framework, context *certCon
2453
2474
},
2454
2475
CABundle : context .signingCert ,
2455
2476
},
2477
+ // network failures while the service network routing is being set up should be ignored by the marker
2478
+ FailurePolicy : & failOpen ,
2456
2479
SideEffects : & sideEffectsNone ,
2457
2480
AdmissionReviewVersions : []string {"v1" , "v1beta1" },
2458
2481
// Scope the webhook to just the markers namespace
@@ -2470,6 +2493,7 @@ func newValidatingIsReadyWebhookFixture(f *framework.Framework, context *certCon
2470
2493
// with "marker" requests via waitWebhookConfigurationReady to wait for a webhook configuration to be ready.
2471
2494
func newMutatingIsReadyWebhookFixture (f * framework.Framework , context * certContext , servicePort int32 ) admissionregistrationv1.MutatingWebhook {
2472
2495
sideEffectsNone := admissionregistrationv1 .SideEffectClassNone
2496
+ failOpen := admissionregistrationv1 .Ignore
2473
2497
return admissionregistrationv1.MutatingWebhook {
2474
2498
Name : "mutating-is-webhook-configuration-ready.k8s.io" ,
2475
2499
Rules : []admissionregistrationv1.RuleWithOperations {{
@@ -2489,6 +2513,8 @@ func newMutatingIsReadyWebhookFixture(f *framework.Framework, context *certConte
2489
2513
},
2490
2514
CABundle : context .signingCert ,
2491
2515
},
2516
+ // network failures while the service network routing is being set up should be ignored by the marker
2517
+ FailurePolicy : & failOpen ,
2492
2518
SideEffects : & sideEffectsNone ,
2493
2519
AdmissionReviewVersions : []string {"v1" , "v1beta1" },
2494
2520
// Scope the webhook to just the markers namespace
0 commit comments