Add service.spec.AllocateLoadBalancerNodePorts

This commit is contained in:
Lars Ekman
2020-11-04 07:30:15 +01:00
parent 0e0cc1ead8
commit 1f4d852f2f
9 changed files with 240 additions and 2 deletions

View File

@@ -4357,6 +4357,16 @@ func ValidateService(service *core.Service) field.ErrorList {
}
}
if service.Spec.AllocateLoadBalancerNodePorts != nil && service.Spec.Type != core.ServiceTypeLoadBalancer {
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"), ""))
}
}
// external traffic fields
allErrs = append(allErrs, validateServiceExternalTrafficFieldsValue(service)...)
return allErrs