mirror of https://github.com/k3s-io/k3s
Merge pull request #64349 from nicksardo/fix-nodeport-alloc
Automatic merge from submit-queue. 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>. Fix nodeport repair for ESIPP services **What this PR does / why we need it**: The nodeport allocation repair controller does not scrape the `Service.Spec.healthCheckNodePort` value and would remove the allocation from memory and etcd after 10 minutes. This opens the door for other services to use the same nodeport and cause collisions. **Which issue(s) this PR fixes**: Fixes #54885 **Release note**: ```release-note Fix issue of colliding nodePorts when the cluster has services with externalTrafficPolicy=Local ```pull/8/head
commit
d089901e46
|
@ -204,5 +204,10 @@ func collectServiceNodePorts(service *api.Service) []int {
|
|||
servicePorts = append(servicePorts, int(servicePort.NodePort))
|
||||
}
|
||||
}
|
||||
|
||||
if service.Spec.HealthCheckNodePort != 0 {
|
||||
servicePorts = append(servicePorts, int(service.Spec.HealthCheckNodePort))
|
||||
}
|
||||
|
||||
return servicePorts
|
||||
}
|
||||
|
|
|
@ -164,6 +164,12 @@ func TestRepairWithExisting(t *testing.T) {
|
|||
Ports: []api.ServicePort{{NodePort: 111}},
|
||||
},
|
||||
},
|
||||
&api.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "six", Name: "six"},
|
||||
Spec: api.ServiceSpec{
|
||||
HealthCheckNodePort: 144,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
registry := &mockRangeRegistry{
|
||||
|
@ -183,10 +189,10 @@ func TestRepairWithExisting(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !after.Has(111) || !after.Has(122) || !after.Has(133) {
|
||||
if !after.Has(111) || !after.Has(122) || !after.Has(133) || !after.Has(144) {
|
||||
t.Errorf("unexpected portallocator state: %#v", after)
|
||||
}
|
||||
if free := after.Free(); free != 98 {
|
||||
if free := after.Free(); free != 97 {
|
||||
t.Errorf("unexpected portallocator state: %d free", free)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue