mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-22 10:27:56 +00:00
remove legacy leftovers of portmapping functionality that was moved to CNI
This commit is contained in:
@@ -333,22 +333,18 @@ func MakePortMappings(container *v1.Container) (ports []PortMapping) {
|
||||
}
|
||||
}
|
||||
|
||||
// We need to create some default port name if it's not specified, since
|
||||
// this is necessary for the dockershim CNI driver.
|
||||
// https://github.com/kubernetes/kubernetes/pull/82374#issuecomment-529496888
|
||||
if p.Name == "" {
|
||||
pm.Name = fmt.Sprintf("%s-%s-%s:%d", container.Name, family, p.Protocol, p.ContainerPort)
|
||||
} else {
|
||||
pm.Name = fmt.Sprintf("%s-%s", container.Name, p.Name)
|
||||
var name string = p.Name
|
||||
if name == "" {
|
||||
name = fmt.Sprintf("%s-%s:%d", family, p.Protocol, p.ContainerPort)
|
||||
}
|
||||
|
||||
// Protect against a port name being used more than once in a container.
|
||||
if _, ok := names[pm.Name]; ok {
|
||||
klog.Warningf("Port name conflicted, %q is defined more than once", pm.Name)
|
||||
if _, ok := names[name]; ok {
|
||||
klog.Warningf("Port name conflicted, %q is defined more than once", name)
|
||||
continue
|
||||
}
|
||||
ports = append(ports, pm)
|
||||
names[pm.Name] = struct{}{}
|
||||
names[name] = struct{}{}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -558,9 +558,8 @@ func TestMakePortMappings(t *testing.T) {
|
||||
HostIP: ip,
|
||||
}
|
||||
}
|
||||
portMapping := func(name string, protocol v1.Protocol, containerPort, hostPort int, ip string) PortMapping {
|
||||
portMapping := func(protocol v1.Protocol, containerPort, hostPort int, ip string) PortMapping {
|
||||
return PortMapping{
|
||||
Name: name,
|
||||
Protocol: protocol,
|
||||
ContainerPort: containerPort,
|
||||
HostPort: hostPort,
|
||||
@@ -590,11 +589,11 @@ func TestMakePortMappings(t *testing.T) {
|
||||
},
|
||||
},
|
||||
[]PortMapping{
|
||||
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"),
|
||||
portMapping("fooContainer-foo", v1.ProtocolUDP, 555, 5555, ""),
|
||||
portMapping("fooContainer-v6-TCP:80", v1.ProtocolTCP, 80, 8080, "::"),
|
||||
portMapping("fooContainer-any-TCP:1234", v1.ProtocolTCP, 1234, 5678, ""),
|
||||
portMapping(v1.ProtocolTCP, 80, 8080, "127.0.0.1"),
|
||||
portMapping(v1.ProtocolTCP, 443, 4343, "192.168.0.1"),
|
||||
portMapping(v1.ProtocolUDP, 555, 5555, ""),
|
||||
portMapping(v1.ProtocolTCP, 80, 8080, "::"),
|
||||
portMapping(v1.ProtocolTCP, 1234, 5678, ""),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -403,8 +403,6 @@ type Mount struct {
|
||||
|
||||
// PortMapping contains information about the port mapping.
|
||||
type PortMapping struct {
|
||||
// Name of the port mapping
|
||||
Name string
|
||||
// Protocol of the port mapping.
|
||||
Protocol v1.Protocol
|
||||
// The port number within the container.
|
||||
@@ -433,8 +431,6 @@ type RunContainerOptions struct {
|
||||
Mounts []Mount
|
||||
// The host devices mapped into the containers.
|
||||
Devices []DeviceInfo
|
||||
// The port mappings for the containers.
|
||||
PortMappings []PortMapping
|
||||
// The annotations for the container
|
||||
// These annotations are generated by other components (i.e.,
|
||||
// not users). Currently, only device plugins populate the annotations.
|
||||
|
Reference in New Issue
Block a user