Skip to content

Commit 7a504aa

Browse files
authored
Merge pull request kubernetes#129174 from RyanAoh/fix-115896
Remove the limitation on exposing port 10250 externally
2 parents efea0a0 + e8087b3 commit 7a504aa

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

pkg/apis/core/validation/validation.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import (
5858
podshelper "k8s.io/kubernetes/pkg/apis/core/pods"
5959
corev1 "k8s.io/kubernetes/pkg/apis/core/v1"
6060
"k8s.io/kubernetes/pkg/capabilities"
61-
"k8s.io/kubernetes/pkg/cluster/ports"
6261
"k8s.io/kubernetes/pkg/features"
6362
"k8s.io/kubernetes/pkg/fieldpath"
6463
)
@@ -5772,16 +5771,6 @@ func ValidateService(service *core.Service) field.ErrorList {
57725771
}
57735772
switch service.Spec.Type {
57745773
case core.ServiceTypeLoadBalancer:
5775-
for ix := range service.Spec.Ports {
5776-
port := &service.Spec.Ports[ix]
5777-
// This is a workaround for broken cloud environments that
5778-
// over-open firewalls. Hopefully it can go away when more clouds
5779-
// understand containers better.
5780-
if port.Port == ports.KubeletPort {
5781-
portPath := specPath.Child("ports").Index(ix)
5782-
allErrs = append(allErrs, field.Invalid(portPath, port.Port, fmt.Sprintf("may not expose port %v externally since it is used by kubelet", ports.KubeletPort)))
5783-
}
5784-
}
57855774
if isHeadlessService(service) {
57865775
allErrs = append(allErrs, field.Invalid(specPath.Child("clusterIPs").Index(0), service.Spec.ClusterIPs[0], "may not be set to 'None' for LoadBalancer services"))
57875776
}

pkg/apis/core/validation/validation_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15512,16 +15512,15 @@ func TestValidateServiceCreate(t *testing.T) {
1551215512
},
1551315513
numErrs: 0,
1551415514
}, {
15515-
// For now we open firewalls, and its insecure if we open 10250, remove this
15516-
// when we have better protections in place.
15517-
name: "invalid port type=LoadBalancer",
15515+
// Remove the limitation on exposing port 10250 externally
15516+
name: "valid port type=LoadBalancer",
1551815517
tweakSvc: func(s *core.Service) {
1551915518
s.Spec.Type = core.ServiceTypeLoadBalancer
1552015519
s.Spec.ExternalTrafficPolicy = core.ServiceExternalTrafficPolicyCluster
1552115520
s.Spec.AllocateLoadBalancerNodePorts = utilpointer.Bool(true)
1552215521
s.Spec.Ports = append(s.Spec.Ports, core.ServicePort{Name: "kubelet", Port: 10250, Protocol: "TCP", TargetPort: intstr.FromInt32(12345)})
1552315522
},
15524-
numErrs: 1,
15523+
numErrs: 0,
1552515524
}, {
1552615525
name: "valid LoadBalancer source range annotation",
1552715526
tweakSvc: func(s *core.Service) {

0 commit comments

Comments
 (0)