mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Merge pull request #5642 from tylarb/5610_play_kube_network
Sanitize port parsing for pods in play kube
This commit is contained in:
@ -768,6 +768,12 @@ func getPodPorts(containers []v1.Container) []ocicni.PortMapping {
|
|||||||
var infraPorts []ocicni.PortMapping
|
var infraPorts []ocicni.PortMapping
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
for _, p := range container.Ports {
|
for _, p := range container.Ports {
|
||||||
|
if p.HostPort != 0 && p.ContainerPort == 0 {
|
||||||
|
p.ContainerPort = p.HostPort
|
||||||
|
}
|
||||||
|
if p.Protocol == "" {
|
||||||
|
p.Protocol = "tcp"
|
||||||
|
}
|
||||||
portBinding := ocicni.PortMapping{
|
portBinding := ocicni.PortMapping{
|
||||||
HostPort: p.HostPort,
|
HostPort: p.HostPort,
|
||||||
ContainerPort: p.ContainerPort,
|
ContainerPort: p.ContainerPort,
|
||||||
@ -776,7 +782,12 @@ func getPodPorts(containers []v1.Container) []ocicni.PortMapping {
|
|||||||
if p.HostIP != "" {
|
if p.HostIP != "" {
|
||||||
logrus.Debug("HostIP on port bindings is not supported")
|
logrus.Debug("HostIP on port bindings is not supported")
|
||||||
}
|
}
|
||||||
infraPorts = append(infraPorts, portBinding)
|
// only hostPort is utilized in podman context, all container ports
|
||||||
|
// are accessible inside the shared network namespace
|
||||||
|
if p.HostPort != 0 {
|
||||||
|
infraPorts = append(infraPorts, portBinding)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return infraPorts
|
return infraPorts
|
||||||
|
Reference in New Issue
Block a user