From 1ef96752daff9e0e58b2643b46b29e718c229d2b Mon Sep 17 00:00:00 2001 From: Lars Ekman Date: Thu, 16 Dec 2021 16:48:58 +0100 Subject: [PATCH 1/2] Mark ServiceLBNodePortControl as GA --- pkg/apis/core/types.go | 1 - pkg/apis/core/v1/defaults.go | 8 +- pkg/apis/core/validation/validation.go | 6 +- pkg/features/kube_features.go | 2 +- pkg/quota/v1/evaluator/core/services.go | 5 +- pkg/quota/v1/evaluator/core/services_test.go | 12 +- pkg/registry/core/service/storage/alloc.go | 7 +- .../core/service/storage/storage_test.go | 103 ++++-------------- pkg/registry/core/service/strategy.go | 14 --- staging/src/k8s.io/api/core/v1/types.go | 2 - test/integration/quota/quota_test.go | 4 - test/integration/service/loadbalancer_test.go | 4 - 12 files changed, 31 insertions(+), 137 deletions(-) diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index fc46e23eb1a..4477dcdf815 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -3892,7 +3892,6 @@ type ServiceSpec struct { // value), those requests will be respected, regardless of this field. // This field may only be set for services with type LoadBalancer and will // be cleared if the type is changed to any other type. - // This field is beta-level and is only honored by servers that enable the ServiceLBNodePortControl feature. // +optional AllocateLoadBalancerNodePorts *bool diff --git a/pkg/apis/core/v1/defaults.go b/pkg/apis/core/v1/defaults.go index 466ab441bb3..3328790fd65 100644 --- a/pkg/apis/core/v1/defaults.go +++ b/pkg/apis/core/v1/defaults.go @@ -136,11 +136,9 @@ func SetDefaults_Service(obj *v1.Service) { obj.Spec.InternalTrafficPolicy = &serviceInternalTrafficPolicyCluster } - if utilfeature.DefaultFeatureGate.Enabled(features.ServiceLBNodePortControl) { - if obj.Spec.Type == v1.ServiceTypeLoadBalancer { - if obj.Spec.AllocateLoadBalancerNodePorts == nil { - obj.Spec.AllocateLoadBalancerNodePorts = utilpointer.BoolPtr(true) - } + if obj.Spec.Type == v1.ServiceTypeLoadBalancer { + if obj.Spec.AllocateLoadBalancerNodePorts == nil { + obj.Spec.AllocateLoadBalancerNodePorts = utilpointer.BoolPtr(true) } } } diff --git a/pkg/apis/core/validation/validation.go b/pkg/apis/core/validation/validation.go index e4a5b5af7e6..45e5e3af0fc 100644 --- a/pkg/apis/core/validation/validation.go +++ b/pkg/apis/core/validation/validation.go @@ -4685,10 +4685,8 @@ func ValidateService(service *core.Service) field.ErrorList { allErrs = append(allErrs, field.Forbidden(specPath.Child("allocateLoadBalancerNodePorts"), "may only be used when `type` is 'LoadBalancer'")) } - if utilfeature.DefaultFeatureGate.Enabled(features.ServiceLBNodePortControl) { - if service.Spec.Type == core.ServiceTypeLoadBalancer && service.Spec.AllocateLoadBalancerNodePorts == nil { - allErrs = append(allErrs, field.Required(field.NewPath("allocateLoadBalancerNodePorts"), "")) - } + if service.Spec.Type == core.ServiceTypeLoadBalancer && service.Spec.AllocateLoadBalancerNodePorts == nil { + allErrs = append(allErrs, field.Required(field.NewPath("allocateLoadBalancerNodePorts"), "")) } // validate LoadBalancerClass field diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index a9622284e9b..c7dd7621c9a 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -932,7 +932,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS KubeletCredentialProviders: {Default: false, PreRelease: featuregate.Alpha}, GracefulNodeShutdown: {Default: true, PreRelease: featuregate.Beta}, GracefulNodeShutdownBasedOnPodPriority: {Default: false, PreRelease: featuregate.Alpha}, - ServiceLBNodePortControl: {Default: true, PreRelease: featuregate.Beta}, + ServiceLBNodePortControl: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26 MixedProtocolLBService: {Default: false, PreRelease: featuregate.Alpha}, VolumeCapacityPriority: {Default: false, PreRelease: featuregate.Alpha}, PreferNominatedNode: {Default: true, PreRelease: featuregate.Beta}, diff --git a/pkg/quota/v1/evaluator/core/services.go b/pkg/quota/v1/evaluator/core/services.go index 5d5115a1401..dc061337327 100644 --- a/pkg/quota/v1/evaluator/core/services.go +++ b/pkg/quota/v1/evaluator/core/services.go @@ -26,10 +26,8 @@ import ( "k8s.io/apiserver/pkg/admission" quota "k8s.io/apiserver/pkg/quota/v1" "k8s.io/apiserver/pkg/quota/v1/generic" - "k8s.io/apiserver/pkg/util/feature" api "k8s.io/kubernetes/pkg/apis/core" k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1" - "k8s.io/kubernetes/pkg/features" ) // the name used for object count quota @@ -134,8 +132,7 @@ func (p *serviceEvaluator) Usage(item runtime.Object) (corev1.ResourceList, erro // is suppressed only ports with explicit NodePort values are counted. // nodeports won't be allocated yet, so we can't simply count the actual values. // We need to look at the intent. - if feature.DefaultFeatureGate.Enabled(features.ServiceLBNodePortControl) && - svc.Spec.AllocateLoadBalancerNodePorts != nil && + if svc.Spec.AllocateLoadBalancerNodePorts != nil && *svc.Spec.AllocateLoadBalancerNodePorts == false { result[corev1.ResourceServicesNodePorts] = *portsWithNodePorts(svc) } else { diff --git a/pkg/quota/v1/evaluator/core/services_test.go b/pkg/quota/v1/evaluator/core/services_test.go index fa8f6246411..ddc9997ffd3 100644 --- a/pkg/quota/v1/evaluator/core/services_test.go +++ b/pkg/quota/v1/evaluator/core/services_test.go @@ -24,10 +24,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" quota "k8s.io/apiserver/pkg/quota/v1" "k8s.io/apiserver/pkg/quota/v1/generic" - "k8s.io/apiserver/pkg/util/feature" - featuregatetesting "k8s.io/component-base/featuregate/testing" api "k8s.io/kubernetes/pkg/apis/core" - "k8s.io/kubernetes/pkg/features" utilpointer "k8s.io/utils/pointer" ) @@ -56,9 +53,8 @@ func TestServiceEvaluatorMatchesResources(t *testing.T) { func TestServiceEvaluatorUsage(t *testing.T) { evaluator := NewServiceEvaluator(nil) testCases := map[string]struct { - service *api.Service - usage corev1.ResourceList - serviceLBNodePortControlEnabled bool + service *api.Service + usage corev1.ResourceList }{ "loadbalancer": { service: &api.Service{ @@ -185,7 +181,6 @@ func TestServiceEvaluatorUsage(t *testing.T) { corev1.ResourceServicesLoadBalancers: resource.MustParse("1"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "services"}): resource.MustParse("1"), }, - serviceLBNodePortControlEnabled: true, }, "nodeports-default-enabled": { service: &api.Service{ @@ -232,7 +227,6 @@ func TestServiceEvaluatorUsage(t *testing.T) { corev1.ResourceServicesLoadBalancers: resource.MustParse("1"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "services"}): resource.MustParse("1"), }, - serviceLBNodePortControlEnabled: true, }, "nodeports-disabled-but-specified": { service: &api.Service{ @@ -257,12 +251,10 @@ func TestServiceEvaluatorUsage(t *testing.T) { corev1.ResourceServicesLoadBalancers: resource.MustParse("1"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "services"}): resource.MustParse("1"), }, - serviceLBNodePortControlEnabled: true, }, } for testName, testCase := range testCases { t.Run(testName, func(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.ServiceLBNodePortControl, testCase.serviceLBNodePortControlEnabled)() actual, err := evaluator.Usage(testCase.service) if err != nil { t.Errorf("%s unexpected error: %v", testName, err) diff --git a/pkg/registry/core/service/storage/alloc.go b/pkg/registry/core/service/storage/alloc.go index 383c595ab3c..77f91ebed61 100644 --- a/pkg/registry/core/service/storage/alloc.go +++ b/pkg/registry/core/service/storage/alloc.go @@ -22,12 +22,10 @@ import ( "k8s.io/apimachinery/pkg/api/errors" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/klog/v2" apiservice "k8s.io/kubernetes/pkg/api/service" api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/apis/core/validation" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/registry/core/service/ipallocator" "k8s.io/kubernetes/pkg/registry/core/service/portallocator" netutils "k8s.io/utils/net" @@ -940,10 +938,7 @@ func shouldAllocateNodePorts(service *api.Service) bool { return true } if service.Spec.Type == api.ServiceTypeLoadBalancer { - if utilfeature.DefaultFeatureGate.Enabled(features.ServiceLBNodePortControl) { - return *service.Spec.AllocateLoadBalancerNodePorts - } - return true + return *service.Spec.AllocateLoadBalancerNodePorts } return false } diff --git a/pkg/registry/core/service/storage/storage_test.go b/pkg/registry/core/service/storage/storage_test.go index 217aa4ed561..444b5be00d2 100644 --- a/pkg/registry/core/service/storage/storage_test.go +++ b/pkg/registry/core/service/storage/storage_test.go @@ -6103,12 +6103,11 @@ func TestCreateDeleteReuse(t *testing.T) { func TestCreateInitNodePorts(t *testing.T) { testCases := []struct { - name string - svc *api.Service - expectError bool - expectNodePorts bool - gateMixedProtocolLBService bool - gateServiceLBNodePortControl bool + name string + svc *api.Service + expectError bool + expectNodePorts bool + gateMixedProtocolLBService bool }{{ name: "type:ExternalName", svc: svctest.MakeService("foo"), @@ -6199,108 +6198,51 @@ func TestCreateInitNodePorts(t *testing.T) { svctest.SetNodePorts(30093, 30093)), expectError: true, }, { - // When the ServiceLBNodePortControl gate is locked, this can be removed. - name: "type:LoadBalancer_single_port_unspecified_gateServiceLBNodePortControl:off_alloc:nil", - svc: svctest.MakeService("foo", - svctest.SetTypeLoadBalancer), - gateServiceLBNodePortControl: false, - expectNodePorts: true, - }, { - // When the ServiceLBNodePortControl gate is locked, this can be removed. - name: "type:LoadBalancer_single_port_unspecified_gateServiceLBNodePortControl:off_alloc:false", + name: "type:LoadBalancer_single_port_unspecified:on_alloc:false", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetAllocateLoadBalancerNodePorts(false)), - gateServiceLBNodePortControl: false, - expectNodePorts: true, + expectNodePorts: false, }, { - // When the ServiceLBNodePortControl gate is locked, this can be removed. - name: "type:LoadBalancer_single_port_unspecified_gateServiceLBNodePortControl:off_alloc:true", + name: "type:LoadBalancer_single_port_unspecified:on_alloc:true", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetAllocateLoadBalancerNodePorts(true)), - gateServiceLBNodePortControl: false, - expectNodePorts: true, + expectNodePorts: true, }, { - // When the ServiceLBNodePortControl gate is locked, this can be removed. - name: "type:LoadBalancer_single_port_specified_gateServiceLBNodePortControl:off", - svc: svctest.MakeService("foo", - svctest.SetTypeLoadBalancer, svctest.SetUniqueNodePorts), - gateServiceLBNodePortControl: false, - expectNodePorts: true, - }, { - // When the ServiceLBNodePortControl gate is locked, this can be removed. - name: "type:LoadBalancer_multiport_unspecified_gateServiceLBNodePortControl:off", - svc: svctest.MakeService("foo", - svctest.SetTypeLoadBalancer, - svctest.SetPorts( - svctest.MakeServicePort("p", 80, intstr.FromInt(80), api.ProtocolTCP), - svctest.MakeServicePort("q", 443, intstr.FromInt(443), api.ProtocolTCP))), - gateServiceLBNodePortControl: false, - expectNodePorts: true, - }, { - // When the ServiceLBNodePortControl gate is locked, this can be removed. - name: "type:LoadBalancer_multiport_specified_gateServiceLBNodePortControl:off", - svc: svctest.MakeService("foo", - svctest.SetTypeLoadBalancer, - svctest.SetPorts( - svctest.MakeServicePort("p", 80, intstr.FromInt(80), api.ProtocolTCP), - svctest.MakeServicePort("q", 443, intstr.FromInt(443), api.ProtocolTCP)), - svctest.SetUniqueNodePorts), - gateServiceLBNodePortControl: false, - expectNodePorts: true, - }, { - name: "type:LoadBalancer_single_port_unspecified_gateServiceLBNodePortControl:on_alloc:false", - svc: svctest.MakeService("foo", - svctest.SetTypeLoadBalancer, - svctest.SetAllocateLoadBalancerNodePorts(false)), - gateServiceLBNodePortControl: true, - expectNodePorts: false, - }, { - name: "type:LoadBalancer_single_port_unspecified_gateServiceLBNodePortControl:on_alloc:true", - svc: svctest.MakeService("foo", - svctest.SetTypeLoadBalancer, - svctest.SetAllocateLoadBalancerNodePorts(true)), - gateServiceLBNodePortControl: true, - expectNodePorts: true, - }, { - name: "type:LoadBalancer_single_port_specified_gateServiceLBNodePortControl:on_alloc:false", + name: "type:LoadBalancer_single_port_specified:on_alloc:false", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetUniqueNodePorts, svctest.SetAllocateLoadBalancerNodePorts(false)), - gateServiceLBNodePortControl: true, - expectNodePorts: true, + expectNodePorts: true, }, { - name: "type:LoadBalancer_single_port_specified_gateServiceLBNodePortControl:on_alloc:true", + name: "type:LoadBalancer_single_port_specified:on_alloc:true", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetUniqueNodePorts, svctest.SetAllocateLoadBalancerNodePorts(true)), - gateServiceLBNodePortControl: true, - expectNodePorts: true, + expectNodePorts: true, }, { - name: "type:LoadBalancer_multiport_unspecified_gateServiceLBNodePortControl:on_alloc:false", + name: "type:LoadBalancer_multiport_unspecified:on_alloc:false", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetPorts( svctest.MakeServicePort("p", 80, intstr.FromInt(80), api.ProtocolTCP), svctest.MakeServicePort("q", 443, intstr.FromInt(443), api.ProtocolTCP)), svctest.SetAllocateLoadBalancerNodePorts(false)), - gateServiceLBNodePortControl: true, - expectNodePorts: false, + expectNodePorts: false, }, { - name: "type:LoadBalancer_multiport_unspecified_gateServiceLBNodePortControl:on_alloc:true", + name: "type:LoadBalancer_multiport_unspecified:on_alloc:true", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetPorts( svctest.MakeServicePort("p", 80, intstr.FromInt(80), api.ProtocolTCP), svctest.MakeServicePort("q", 443, intstr.FromInt(443), api.ProtocolTCP)), svctest.SetAllocateLoadBalancerNodePorts(true)), - gateServiceLBNodePortControl: true, - expectNodePorts: true, + expectNodePorts: true, }, { - name: "type:LoadBalancer_multiport_specified_gateServiceLBNodePortControl:on_alloc:false", + name: "type:LoadBalancer_multiport_specified:on_alloc:false", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetPorts( @@ -6308,10 +6250,9 @@ func TestCreateInitNodePorts(t *testing.T) { svctest.MakeServicePort("q", 443, intstr.FromInt(443), api.ProtocolTCP)), svctest.SetUniqueNodePorts, svctest.SetAllocateLoadBalancerNodePorts(false)), - gateServiceLBNodePortControl: true, - expectNodePorts: true, + expectNodePorts: true, }, { - name: "type:LoadBalancer_multiport_specified_gateServiceLBNodePortControl:on_alloc:true", + name: "type:LoadBalancer_multiport_specified:on_alloc:true", svc: svctest.MakeService("foo", svctest.SetTypeLoadBalancer, svctest.SetPorts( @@ -6319,8 +6260,7 @@ func TestCreateInitNodePorts(t *testing.T) { svctest.MakeServicePort("q", 443, intstr.FromInt(443), api.ProtocolTCP)), svctest.SetUniqueNodePorts, svctest.SetAllocateLoadBalancerNodePorts(true)), - gateServiceLBNodePortControl: true, - expectNodePorts: true, + expectNodePorts: true, }, { name: "type:LoadBalancer_multiport_same", svc: svctest.MakeService("foo", @@ -6408,7 +6348,6 @@ func TestCreateInitNodePorts(t *testing.T) { defer storage.Store.DestroyFunc() for _, tc := range testCases { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceLBNodePortControl, tc.gateServiceLBNodePortControl)() defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MixedProtocolLBService, tc.gateMixedProtocolLBService)() t.Run(tc.name, func(t *testing.T) { diff --git a/pkg/registry/core/service/strategy.go b/pkg/registry/core/service/strategy.go index 53ffe01f5d1..e714c1386dd 100644 --- a/pkg/registry/core/service/strategy.go +++ b/pkg/registry/core/service/strategy.go @@ -162,12 +162,6 @@ func (svcStrategy) AllowUnconditionalUpdate() bool { // newSvc.Spec.MyFeature = nil // } func dropServiceDisabledFields(newSvc *api.Service, oldSvc *api.Service) { - // Clear AllocateLoadBalancerNodePorts if ServiceLBNodePortControl is not enabled - if !utilfeature.DefaultFeatureGate.Enabled(features.ServiceLBNodePortControl) { - if !allocateLoadBalancerNodePortsInUse(oldSvc) { - newSvc.Spec.AllocateLoadBalancerNodePorts = nil - } - } if !utilfeature.DefaultFeatureGate.Enabled(features.MixedProtocolLBService) { if !serviceConditionsInUse(oldSvc) { @@ -195,14 +189,6 @@ func dropServiceDisabledFields(newSvc *api.Service, oldSvc *api.Service) { } } -// returns true if svc.Spec.AllocateLoadBalancerNodePorts field is in use -func allocateLoadBalancerNodePortsInUse(svc *api.Service) bool { - if svc == nil { - return false - } - return svc.Spec.AllocateLoadBalancerNodePorts != nil -} - // returns true when the svc.Status.Conditions field is in use. func serviceConditionsInUse(svc *api.Service) bool { if svc == nil { diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 80c5dd744c1..e75c89d00a6 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -4460,8 +4460,6 @@ type ServiceSpec struct { // value), those requests will be respected, regardless of this field. // This field may only be set for services with type LoadBalancer and will // be cleared if the type is changed to any other type. - // This field is beta-level and is only honored by servers that enable the ServiceLBNodePortControl feature. - // +featureGate=ServiceLBNodePortControl // +optional AllocateLoadBalancerNodePorts *bool `json:"allocateLoadBalancerNodePorts,omitempty" protobuf:"bytes,20,opt,name=allocateLoadBalancerNodePorts"` diff --git a/test/integration/quota/quota_test.go b/test/integration/quota/quota_test.go index 311f9f01e65..243d8013e6a 100644 --- a/test/integration/quota/quota_test.go +++ b/test/integration/quota/quota_test.go @@ -38,17 +38,14 @@ import ( "k8s.io/apiserver/pkg/admission/plugin/resourcequota" resourcequotaapi "k8s.io/apiserver/pkg/admission/plugin/resourcequota/apis/resourcequota" "k8s.io/apiserver/pkg/quota/v1/generic" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/informers" clientset "k8s.io/client-go/kubernetes" restclient "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" watchtools "k8s.io/client-go/tools/watch" - featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/pkg/controller" replicationcontroller "k8s.io/kubernetes/pkg/controller/replication" resourcequotacontroller "k8s.io/kubernetes/pkg/controller/resourcequota" - "k8s.io/kubernetes/pkg/features" quotainstall "k8s.io/kubernetes/pkg/quota/v1/install" "k8s.io/kubernetes/test/integration/framework" ) @@ -416,7 +413,6 @@ func TestQuotaLimitedResourceDenial(t *testing.T) { } func TestQuotaLimitService(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceLBNodePortControl, true)() // Set up an API server h := &framework.APIServerHolder{Initialized: make(chan struct{})} diff --git a/test/integration/service/loadbalancer_test.go b/test/integration/service/loadbalancer_test.go index 18ad2a16567..3baf89ac973 100644 --- a/test/integration/service/loadbalancer_test.go +++ b/test/integration/service/loadbalancer_test.go @@ -37,7 +37,6 @@ import ( // Test_ServiceLoadBalancerAllocateNodePorts tests that a Service with spec.allocateLoadBalancerNodePorts=false // does not allocate node ports for the Service. func Test_ServiceLoadBalancerDisableAllocateNodePorts(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceLBNodePortControl, true)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfig() _, server, closeFn := framework.RunAnAPIServer(controlPlaneConfig) @@ -81,7 +80,6 @@ func Test_ServiceLoadBalancerDisableAllocateNodePorts(t *testing.T) { // Test_ServiceUpdateLoadBalancerAllocateNodePorts tests that a Service that is updated from ClusterIP to LoadBalancer // with spec.allocateLoadBalancerNodePorts=false does not allocate node ports for the Service func Test_ServiceUpdateLoadBalancerDisableAllocateNodePorts(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceLBNodePortControl, true)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfig() _, server, closeFn := framework.RunAnAPIServer(controlPlaneConfig) @@ -135,7 +133,6 @@ func Test_ServiceUpdateLoadBalancerDisableAllocateNodePorts(t *testing.T) { // Test_ServiceLoadBalancerSwitchToDeallocatedNodePorts test that switching a Service // to spec.allocateLoadBalancerNodePorts=false, does not de-allocate existing node ports. func Test_ServiceLoadBalancerEnableThenDisableAllocatedNodePorts(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceLBNodePortControl, true)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfig() _, server, closeFn := framework.RunAnAPIServer(controlPlaneConfig) @@ -189,7 +186,6 @@ func Test_ServiceLoadBalancerEnableThenDisableAllocatedNodePorts(t *testing.T) { // Test_ServiceLoadBalancerDisableThenEnableAllocatedNodePorts test that switching a Service // to spec.allocateLoadBalancerNodePorts=true from false, allocate new node ports. func Test_ServiceLoadBalancerDisableThenEnableAllocatedNodePorts(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceLBNodePortControl, true)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfig() _, server, closeFn := framework.RunAnAPIServer(controlPlaneConfig) From 0ac38a74724ce4deb7334f354399543f352196e6 Mon Sep 17 00:00:00 2001 From: Lars Ekman Date: Thu, 16 Dec 2021 17:17:52 +0100 Subject: [PATCH 2/2] Update generated files after ServiceLBNodePortControl->GA --- api/openapi-spec/swagger.json | 2 +- api/openapi-spec/v3/api__v1_openapi.json | 2 +- staging/src/k8s.io/api/core/v1/generated.proto | 2 -- staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index d5441b6fded..c8469a1310d 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -10173,7 +10173,7 @@ "description": "ServiceSpec describes the attributes that a user creates on a service.", "properties": { "allocateLoadBalancerNodePorts": { - "description": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type. This field is beta-level and is only honored by servers that enable the ServiceLBNodePortControl feature.", + "description": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type.", "type": "boolean" }, "clusterIP": { diff --git a/api/openapi-spec/v3/api__v1_openapi.json b/api/openapi-spec/v3/api__v1_openapi.json index b5d657ac2eb..581247e49c6 100644 --- a/api/openapi-spec/v3/api__v1_openapi.json +++ b/api/openapi-spec/v3/api__v1_openapi.json @@ -5896,7 +5896,7 @@ "description": "ServiceSpec describes the attributes that a user creates on a service.", "properties": { "allocateLoadBalancerNodePorts": { - "description": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type. This field is beta-level and is only honored by servers that enable the ServiceLBNodePortControl feature.", + "description": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type.", "type": "boolean" }, "clusterIP": { diff --git a/staging/src/k8s.io/api/core/v1/generated.proto b/staging/src/k8s.io/api/core/v1/generated.proto index b5b44781f02..cf7583bf856 100644 --- a/staging/src/k8s.io/api/core/v1/generated.proto +++ b/staging/src/k8s.io/api/core/v1/generated.proto @@ -5162,8 +5162,6 @@ message ServiceSpec { // value), those requests will be respected, regardless of this field. // This field may only be set for services with type LoadBalancer and will // be cleared if the type is changed to any other type. - // This field is beta-level and is only honored by servers that enable the ServiceLBNodePortControl feature. - // +featureGate=ServiceLBNodePortControl // +optional optional bool allocateLoadBalancerNodePorts = 20; diff --git a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go index 0a60e7008ab..2c04105e3ce 100644 --- a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go @@ -2280,7 +2280,7 @@ var map_ServiceSpec = map[string]string{ "sessionAffinityConfig": "sessionAffinityConfig contains the configurations of session affinity.", "ipFamilies": "IPFamilies is a list of IP families (e.g. IPv4, IPv6) assigned to this service. This field is usually assigned automatically based on cluster configuration and the ipFamilyPolicy field. If this field is specified manually, the requested family is available in the cluster, and ipFamilyPolicy allows it, it will be used; otherwise creation of the service will fail. This field is conditionally mutable: it allows for adding or removing a secondary IP family, but it does not allow changing the primary IP family of the Service. Valid values are \"IPv4\" and \"IPv6\". This field only applies to Services of types ClusterIP, NodePort, and LoadBalancer, and does apply to \"headless\" services. This field will be wiped when updating a Service to type ExternalName.\n\nThis field may hold a maximum of two entries (dual-stack families, in either order). These families must correspond to the values of the clusterIPs field, if specified. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field.", "ipFamilyPolicy": "IPFamilyPolicy represents the dual-stack-ness requested or required by this Service. If there is no value provided, then this field will be set to SingleStack. Services can be \"SingleStack\" (a single IP family), \"PreferDualStack\" (two IP families on dual-stack configured clusters or a single IP family on single-stack clusters), or \"RequireDualStack\" (two IP families on dual-stack configured clusters, otherwise fail). The ipFamilies and clusterIPs fields depend on the value of this field. This field will be wiped when updating a service to type ExternalName.", - "allocateLoadBalancerNodePorts": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type. This field is beta-level and is only honored by servers that enable the ServiceLBNodePortControl feature.", + "allocateLoadBalancerNodePorts": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type.", "loadBalancerClass": "loadBalancerClass is the class of the load balancer implementation this Service belongs to. If specified, the value of this field must be a label-style identifier, with an optional prefix, e.g. \"internal-vip\" or \"example.com/internal-vip\". Unprefixed names are reserved for end-users. This field can only be set when the Service type is 'LoadBalancer'. If not set, the default load balancer implementation is used, today this is typically done through the cloud provider integration, but should apply for any default implementation. If set, it is assumed that a load balancer implementation is watching for Services with a matching class. Any default load balancer implementation (e.g. cloud providers) should ignore Services that set this field. This field can only be set when creating or updating a Service to type 'LoadBalancer'. Once set, it can not be changed. This field will be wiped when a service is updated to a non 'LoadBalancer' type.", "internalTrafficPolicy": "InternalTrafficPolicy specifies if the cluster internal traffic should be routed to all endpoints or node-local endpoints only. \"Cluster\" routes internal traffic to a Service to all endpoints. \"Local\" routes traffic to node-local endpoints only, traffic is dropped if no node-local endpoints are ready. The default value is \"Cluster\".", }