diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-27 19:42:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 19:42:50 +0100 |
commit | 1fe2fbb42114b9072a1caf359beff63042df90fd (patch) | |
tree | cfe3c3736969d66c31b1c32438e302b9c940b16a /pkg/adapter/pods.go | |
parent | 2c5c1980200806d2a0dde375564b505b9150e645 (diff) | |
parent | d704144f530bd473556a018349e13d082bff4676 (diff) | |
download | podman-1fe2fbb42114b9072a1caf359beff63042df90fd.tar.gz podman-1fe2fbb42114b9072a1caf359beff63042df90fd.tar.bz2 podman-1fe2fbb42114b9072a1caf359beff63042df90fd.zip |
Merge pull request #5642 from tylarb/5610_play_kube_network
Sanitize port parsing for pods in play kube
Diffstat (limited to 'pkg/adapter/pods.go')
-rw-r--r-- | pkg/adapter/pods.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index 1417bd2b9..102eabd8b 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -768,6 +768,12 @@ func getPodPorts(containers []v1.Container) []ocicni.PortMapping { var infraPorts []ocicni.PortMapping for _, container := range containers { 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{ HostPort: p.HostPort, ContainerPort: p.ContainerPort, @@ -776,7 +782,12 @@ func getPodPorts(containers []v1.Container) []ocicni.PortMapping { if p.HostIP != "" { 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 |