Change:
What happened: I tried to create a deployment with duplicate containerPorts with hostIPs of two different address families. Only the first mapping was provided as input into my CNI plugin chain. Also, a log message from kubelet warning about a duplicate containerPort was created. What you expected to happen: Both mappings to be provided as input into my CNI plugins. No log messages should be created. How to reproduce it (as minimally and precisely as possible): Create this deployment: Then grab kubelet logs on the host e.g: Anything else we need to know?: This issue here provides some context as to how I ran into this issue: Environment: Kubernetes version (use ): v1.15.1 Cloud provider or hardware configuration: DigitalOcean, custom setup OS (e.g: ):Kernel (e.g. ):Install tools: None Network plugin and version (if this is a network-related bug): Cilium v1.6.0 and Portmap v0.8.2 Others: N/A I've already identified the problem and will submit a PR which fixes this shortly. /sig network
is this dual-stack only? if so, does the fix for this need to target 1.16?
/triage unresolved Comment when the issue is assessed and confirmed. I am a bot run by vllry. ‍
This applies to dual-stack only yes. I don't know if it should target 1.16, personally I'd like to get this out so I don't have to run a forked version of kubelet.
/assign
I would agree that this should hit v1.16 if possible.
If this issue has been triaged, please comment . If you aren't able to handle this issue, consider unassigning yourself and/or adding the label. I am a bot run by vllry. ‍

Discussion:
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library", "//third_party/forked/golang/expansion:go_default_library", "//vendor/k8s.io/klog:go_default_library", <ins> "//vendor/k8s.io/utils/net:go_default_library", </ins> ], )

"k8s.io/kubernetes/pkg/kubelet/util/format" hashutil "k8s.io/kubernetes/pkg/util/hash" "k8s.io/kubernetes/third_party/forked/golang/expansion" <ins> utilsnet "k8s.io/utils/net" </ins> ) // HandlerRunner runs a lifecycle handler for a container.

HostIP:        p.HostIP, } <ins> // We need to determine the address family this entry applies to. We do this to ensure // duplicate containerPort / protocol rules work across different address families. // https://github.com/kubernetes/kubernetes/issues/82373 family := "any" if p.HostIP != "" { if utilsnet.IsIPv6String(p.HostIP) { family = "v6" } else { family = "v4" } } </ins> // We need to create some default port name if it's not specified, since <del> // this is necessary for rkt. // http://issue.k8s.io/7710 </del> <ins> // this is necessary for the dockershim CNI driver. // https://github.com/kubernetes/kubernetes/pull/82374#issuecomment-529496888 </ins> if p.Name == "" { <del> pm.Name = fmt.Sprintf("%s-%s:%d", container.Name, p.Protocol, p.ContainerPort) </del> <ins> pm.Name = fmt.Sprintf("%s-%s-%s:%d", container.Name, family, p.Protocol, p.ContainerPort) </ins> } else { pm.Name = fmt.Sprintf("%s-%s", container.Name, p.Name) } <del> // Protect against exposing the same protocol-port more than once in a container. </del> <ins> // Protect against a port name being used more than once in a container. </ins> if _, ok := names[pm.Name]; ok { klog.Warningf("Port name conflicted, %q is defined more than once", pm.Name) continue

// Duplicated, should be ignored. port("foo", v1.ProtocolUDP, 888, 8888, ""), // Duplicated, should be ignored. <del> port("", v1.ProtocolTCP, 80, 8888, ""), </del> <ins> port("", v1.ProtocolTCP, 80, 8888, "127.0.0.1"), // Duplicated with different address family, shouldn't be ignored port("", v1.ProtocolTCP, 80, 8080, "::"), // No address family specified port("", v1.ProtocolTCP, 1234, 5678, ""), </ins> }, }, []PortMapping{ <del> portMapping("fooContainer-TCP:80", v1.ProtocolTCP, 80, 8080, "127.0.0.1"), portMapping("fooContainer-TCP:443", v1.ProtocolTCP, 443, 4343, "192.168.0.1"), </del> <ins> portMapping("fooContainer-v4-TCP:80", v1.ProtocolTCP, 80, 8080, "127.0.0.1"), portMapping("fooContainer-v4-TCP:443", v1.ProtocolTCP, 443, 4343, "192.168.0.1"), </ins> portMapping("fooContainer-foo", v1.ProtocolUDP, 555, 5555, ""), <ins> portMapping("fooContainer-v6-TCP:80", v1.ProtocolTCP, 80, 8080, "::"), portMapping("fooContainer-any-TCP:1234", v1.ProtocolTCP, 1234, 5678, ""), </ins> }, }, }