diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-09-26 14:48:37 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2022-09-27 14:04:24 -0400 |
commit | f5fc0960e5eddf64a7d8fbf8fbfd3652b4ee5db3 (patch) | |
tree | b72484a5ace3b59ff23c67a659700bc160f42288 /pkg | |
parent | cbc7185d1fc30fdb24466ccaaa5680aa10f67dd1 (diff) | |
download | podman-f5fc0960e5eddf64a7d8fbf8fbfd3652b4ee5db3.tar.gz podman-f5fc0960e5eddf64a7d8fbf8fbfd3652b4ee5db3.tar.bz2 podman-f5fc0960e5eddf64a7d8fbf8fbfd3652b4ee5db3.zip |
Default missing hostPort to containerPort is defined in kube.yaml
If user does not specify hostPort in a kube.yml file but does specify
a containerPort, then the hostPort should default to the containerPort.
Fixes: https://github.com/containers/podman/issues/15942
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 7d85fd2f3..bc9013afc 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -908,6 +908,9 @@ func getPodPorts(containers []v1.Container) []types.PortMapping { if p.HostPort != 0 && p.ContainerPort == 0 { p.ContainerPort = p.HostPort } + if p.HostPort == 0 && p.ContainerPort != 0 { + p.HostPort = p.ContainerPort + } if p.Protocol == "" { p.Protocol = "tcp" } |