Skip to content

Commit

Permalink
Merge pull request #5642 from tylarb/5610_play_kube_network
Browse files Browse the repository at this point in the history
Sanitize port parsing for pods in play kube
  • Loading branch information
openshift-merge-robot authored Mar 27, 2020
2 parents 2c5c198 + d704144 commit 1fe2fbb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/adapter/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 1fe2fbb

Please sign in to comment.