summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-03-27 19:42:50 +0100
committerGitHub <noreply@github.com>2020-03-27 19:42:50 +0100
commit1fe2fbb42114b9072a1caf359beff63042df90fd (patch)
treecfe3c3736969d66c31b1c32438e302b9c940b16a
parent2c5c1980200806d2a0dde375564b505b9150e645 (diff)
parentd704144f530bd473556a018349e13d082bff4676 (diff)
downloadpodman-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
-rw-r--r--pkg/adapter/pods.go13
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