summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2021-09-27 15:12:47 -0400
committerMatthew Heon <matthew.heon@pm.me>2021-09-29 16:39:29 -0400
commit7d72e83240890c338dc3d2b17295ba09f9878707 (patch)
tree03ff2bd15ac3a3ad5e143541cdc74756c0a6ad51 /libpod
parent4fc40c82f7e916a3d164a26f6f2ee51f1f323ab6 (diff)
downloadpodman-7d72e83240890c338dc3d2b17295ba09f9878707.tar.gz
podman-7d72e83240890c338dc3d2b17295ba09f9878707.tar.bz2
podman-7d72e83240890c338dc3d2b17295ba09f9878707.zip
[NO TESTS NEEDED] Add port configuration to first regular container
When generating a kube yaml and there is a port configuration add the configuration to the first regular container in the pod and not to the init container. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/kube.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/libpod/kube.go b/libpod/kube.go
index b92753f1b..25f672c28 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -253,7 +253,9 @@ func (p *Pod) podWithContainers(ctx context.Context, containers []*Container, po
// We add the original port declarations from the libpod infra container
// to the first kubernetes container description because otherwise we loose
// the original container/port bindings.
- if first && len(ports) > 0 {
+ // Add the port configuration to the first regular container or the first
+ // init container if only init containers have been created in the pod.
+ if first && len(ports) > 0 && (!isInit || len(containers) == 2) {
ctr.Ports = ports
first = false
}