mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #39369 from CallMeFoxie/validation-hostip
Automatic merge from submit-queue (batch tested with PRs 40971, 41027, 40709, 40903, 39369) Validate unique against HostPort/Protocol/HostIP **What this PR does / why we need it**: We can bind to specific IPs however validation will fail for different HostIP:HostPort combination. This is a small fix to check combination of HostPort/Protocol/HostIP rather than just HostPort/Protocol. Sample configuration ... "ports": [ { "protocol": "TCP", "containerPort": 53, "hostPort": 55, "hostIP": "127.0.0.1", "name": "dns-local-tcp" }, { "protocol": "TCP", "containerPort": 53, "hostPort": 55, "hostIP": "127.0.0.2", "name": "dns-local-tcp2" } ] Before: * spec.template.spec.containers[1].ports[2].hostPort: Duplicate value: "55/TCP" * spec.template.spec.containers[1].ports[3].hostPort: Duplicate value: "55/TCP" After applying the patch: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:55 0.0.0.0:* LISTEN 3644/docker-proxy tcp 0 0 127.0.0.2:55 0.0.0.0:* LISTEN 3629/docker-proxy Thanks Ashley **Release note**: ```release-note ```
This commit is contained in:
commit
9dec47dc28
@ -1421,7 +1421,7 @@ func AccumulateUniqueHostPorts(containers []api.Container, accumulator *sets.Str
|
||||
if port == 0 {
|
||||
continue
|
||||
}
|
||||
str := fmt.Sprintf("%d/%s", port, ctr.Ports[pi].Protocol)
|
||||
str := fmt.Sprintf("%s/%s/%d", ctr.Ports[pi].Protocol, ctr.Ports[pi].HostIP, port)
|
||||
if accumulator.Has(str) {
|
||||
allErrs = append(allErrs, field.Duplicate(idxPath.Child("hostPort"), str))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user