Merge pull request #53576 from xiangpengzhao/revert-47284
Automatic merge from submit-queue (batch tested with PRs 54826, 53576, 55591, 54946, 54825). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
Revert "Validate if service has duplicate targetPort"
**What this PR does / why we need it**:
Services allow duplicate targetPort. This reverts commit ce54d9072b
.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #53526
**Special notes for your reviewer**:
/cc @thockin @jhorwit2
**Release note**:
```release-note
NONE
```
This commit is contained in:
@@ -3188,22 +3188,6 @@ func ValidateService(service *core.Service) field.ErrorList {
|
||||
ports[key] = true
|
||||
}
|
||||
|
||||
// Check for duplicate TargetPort
|
||||
portsPath = specPath.Child("ports")
|
||||
targetPorts := make(map[core.ServicePort]bool)
|
||||
for i, port := range service.Spec.Ports {
|
||||
if (port.TargetPort.Type == intstr.Int && port.TargetPort.IntVal == 0) || (port.TargetPort.Type == intstr.String && port.TargetPort.StrVal == "") {
|
||||
continue
|
||||
}
|
||||
portPath := portsPath.Index(i)
|
||||
key := core.ServicePort{Protocol: port.Protocol, TargetPort: port.TargetPort}
|
||||
_, found := targetPorts[key]
|
||||
if found {
|
||||
allErrs = append(allErrs, field.Duplicate(portPath.Child("targetPort"), port.TargetPort))
|
||||
}
|
||||
targetPorts[key] = true
|
||||
}
|
||||
|
||||
// Validate SourceRange field and annotation
|
||||
_, ok := service.Annotations[core.AnnotationLoadBalancerSourceRangesKey]
|
||||
if len(service.Spec.LoadBalancerSourceRanges) > 0 || ok {
|
||||
|
Reference in New Issue
Block a user