diff --git a/test/e2e/apimachinery/aggregator.go b/test/e2e/apimachinery/aggregator.go index af15b813099..6dc150ddf9c 100644 --- a/test/e2e/apimachinery/aggregator.go +++ b/test/e2e/apimachinery/aggregator.go @@ -42,12 +42,17 @@ import ( "k8s.io/kubernetes/test/e2e/framework" imageutils "k8s.io/kubernetes/test/utils/image" samplev1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" + "k8s.io/utils/pointer" . "github.com/onsi/ginkgo" ) var serverAggregatorVersion = utilversion.MustParseSemantic("v1.10.0") +const ( + aggregatorServicePort = 7443 +) + var _ = SIGDescribe("Aggregator", func() { var ns string var c clientset.Interface @@ -266,7 +271,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) { Ports: []v1.ServicePort{ { Protocol: "TCP", - Port: 443, + Port: aggregatorServicePort, TargetPort: intstr.FromInt(443), }, }, @@ -317,6 +322,7 @@ func TestSampleAPIServer(f *framework.Framework, image string) { Service: &apiregistrationv1beta1.ServiceReference{ Namespace: namespace, Name: "sample-api", + Port: pointer.Int32Ptr(aggregatorServicePort), }, Group: "wardle.k8s.io", Version: "v1alpha1", diff --git a/test/e2e/apimachinery/crd_conversion_webhook.go b/test/e2e/apimachinery/crd_conversion_webhook.go index 71ad6e68512..a74464c9fee 100644 --- a/test/e2e/apimachinery/crd_conversion_webhook.go +++ b/test/e2e/apimachinery/crd_conversion_webhook.go @@ -34,6 +34,7 @@ import ( "k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/utils/crd" imageutils "k8s.io/kubernetes/test/utils/image" + "k8s.io/utils/pointer" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -44,6 +45,7 @@ const ( secretCRDName = "sample-custom-resource-conversion-webhook-secret" deploymentCRDName = "sample-crd-conversion-webhook-deployment" serviceCRDName = "e2e-test-crd-conversion-webhook" + serviceCRDPort = 9443 roleBindingCRDName = "crd-conversion-webhook-auth-reader" ) @@ -107,7 +109,8 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh Service: &v1beta1.ServiceReference{ Namespace: f.Namespace.Name, Name: serviceCRDName, - Path: strPtr("/crdconvert"), + Path: pointer.StringPtr("/crdconvert"), + Port: pointer.Int32Ptr(serviceCRDPort), }}) if err != nil { return @@ -123,7 +126,8 @@ var _ = SIGDescribe("CustomResourceConversionWebhook [Feature:CustomResourceWebh Service: &v1beta1.ServiceReference{ Namespace: f.Namespace.Name, Name: serviceCRDName, - Path: strPtr("/crdconvert"), + Path: pointer.StringPtr("/crdconvert"), + Port: pointer.Int32Ptr(serviceCRDPort), }}) if err != nil { return @@ -268,7 +272,7 @@ func deployCustomResourceWebhookAndService(f *framework.Framework, image string, Ports: []v1.ServicePort{ { Protocol: "TCP", - Port: 443, + Port: serviceCRDPort, TargetPort: intstr.FromInt(443), }, }, diff --git a/test/e2e/apimachinery/webhook.go b/test/e2e/apimachinery/webhook.go index 24e1d051122..9144c4a122c 100644 --- a/test/e2e/apimachinery/webhook.go +++ b/test/e2e/apimachinery/webhook.go @@ -40,6 +40,7 @@ import ( "k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/utils/crd" imageutils "k8s.io/kubernetes/test/utils/image" + "k8s.io/utils/pointer" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -50,6 +51,7 @@ const ( secretName = "sample-webhook-secret" deploymentName = "sample-webhook-deployment" serviceName = "e2e-test-webhook" + servicePort = 8443 roleBindingName = "webhook-auth-reader" // The webhook configuration names should not be reused between test instances. @@ -208,17 +210,17 @@ var _ = SIGDescribe("AdmissionWebhook", func() { policyIgnore := v1beta1.Ignore By("Setting timeout (1s) shorter than webhook latency (5s)") - slowWebhookCleanup := registerSlowWebhook(f, context, &policyFail, int32Ptr(1)) + slowWebhookCleanup := registerSlowWebhook(f, context, &policyFail, pointer.Int32Ptr(1)) testSlowWebhookTimeoutFailEarly(f) slowWebhookCleanup() By("Having no error when timeout is shorter than webhook latency and failure policy is ignore") - slowWebhookCleanup = registerSlowWebhook(f, context, &policyIgnore, int32Ptr(1)) + slowWebhookCleanup = registerSlowWebhook(f, context, &policyIgnore, pointer.Int32Ptr(1)) testSlowWebhookTimeoutNoError(f) slowWebhookCleanup() By("Having no error when timeout is longer than webhook latency") - slowWebhookCleanup = registerSlowWebhook(f, context, &policyFail, int32Ptr(10)) + slowWebhookCleanup = registerSlowWebhook(f, context, &policyFail, pointer.Int32Ptr(10)) testSlowWebhookTimeoutNoError(f) slowWebhookCleanup() @@ -368,7 +370,7 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert Ports: []v1.ServicePort{ { Protocol: "TCP", - Port: 443, + Port: servicePort, TargetPort: intstr.FromInt(443), }, }, @@ -384,8 +386,6 @@ func deployWebhookAndService(f *framework.Framework, image string, context *cert func strPtr(s string) *string { return &s } -func int32Ptr(i int32) *int32 { return &i } - func registerWebhook(f *framework.Framework, context *certContext) func() { client := f.ClientSet By("Registering the webhook via the AdmissionRegistration API") @@ -417,6 +417,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() { Namespace: namespace, Name: serviceName, Path: strPtr("/pods"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -446,6 +447,7 @@ func registerWebhook(f *framework.Framework, context *certContext) func() { Namespace: namespace, Name: serviceName, Path: strPtr("/configmaps"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -496,6 +498,7 @@ func registerWebhookForAttachingPod(f *framework.Framework, context *certContext Namespace: namespace, Name: serviceName, Path: strPtr("/pods/attach"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -539,6 +542,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo Namespace: namespace, Name: serviceName, Path: strPtr("/mutating-configmaps"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -558,6 +562,7 @@ func registerMutatingWebhookForConfigMap(f *framework.Framework, context *certCo Namespace: namespace, Name: serviceName, Path: strPtr("/mutating-configmaps"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -614,6 +619,7 @@ func registerMutatingWebhookForPod(f *framework.Framework, context *certContext) Namespace: namespace, Name: serviceName, Path: strPtr("/mutating-pods"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -786,6 +792,7 @@ func failingWebhook(namespace, name string) v1beta1.Webhook { Namespace: namespace, Name: serviceName, Path: strPtr("/configmaps"), + Port: pointer.Int32Ptr(servicePort), }, // Without CA bundle, the call to webhook always fails CABundle: nil, @@ -892,6 +899,7 @@ func registerValidatingWebhookForWebhookConfigurations(f *framework.Framework, c Namespace: namespace, Name: serviceName, Path: strPtr("/always-deny"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -944,6 +952,7 @@ func registerMutatingWebhookForWebhookConfigurations(f *framework.Framework, con Namespace: namespace, Name: serviceName, Path: strPtr("/add-label"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -997,6 +1006,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) { // but because the failure policy is ignore, it will // have no effect on admission requests. Path: strPtr(""), + Port: pointer.Int32Ptr(servicePort), }, CABundle: nil, }, @@ -1044,6 +1054,7 @@ func testWebhooksForWebhookConfigurations(f *framework.Framework) { // but because the failure policy is ignore, it will // have no effect on admission requests. Path: strPtr(""), + Port: pointer.Int32Ptr(servicePort), }, CABundle: nil, }, @@ -1213,6 +1224,7 @@ func registerWebhookForCustomResource(f *framework.Framework, context *certConte Namespace: namespace, Name: serviceName, Path: strPtr("/custom-resource"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -1254,6 +1266,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c Namespace: namespace, Name: serviceName, Path: strPtr("/mutating-custom-resource"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -1273,6 +1286,7 @@ func registerMutatingWebhookForCustomResource(f *framework.Framework, context *c Namespace: namespace, Name: serviceName, Path: strPtr("/mutating-custom-resource"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -1401,6 +1415,7 @@ func registerValidatingWebhookForCRD(f *framework.Framework, context *certContex Namespace: namespace, Name: serviceName, Path: strPtr("/crd"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, }, @@ -1512,6 +1527,7 @@ func registerSlowWebhook(f *framework.Framework, context *certContext, policy *v Namespace: namespace, Name: serviceName, Path: strPtr("/always-allow-delay-5s"), + Port: pointer.Int32Ptr(servicePort), }, CABundle: context.signingCert, },