LB Source Ranges: Move validation into API layer
Had to move other things around too to avoid a weird api -> cloudprovider dependency. Also adding fixes per code reviews. (This is a squash of the previously approved commits)
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
apiservice "k8s.io/kubernetes/pkg/api/service"
|
||||
"k8s.io/kubernetes/pkg/capabilities"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
@@ -1736,6 +1737,12 @@ func ValidateService(service *api.Service) field.ErrorList {
|
||||
nodePorts[key] = true
|
||||
}
|
||||
|
||||
_, err := apiservice.GetLoadBalancerSourceRanges(service.Annotations)
|
||||
if err != nil {
|
||||
v := service.Annotations[apiservice.AnnotationLoadBalancerSourceRangesKey]
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata", "annotations").Key(apiservice.AnnotationLoadBalancerSourceRangesKey), v, "must be a comma separated list of CIDRs e.g. 192.168.0.0/16,10.0.0.0/8"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user