From a3cdee9796497e46531549f906e6695021e48305 Mon Sep 17 00:00:00 2001 From: Urvashi Mohnani Date: Mon, 27 Sep 2021 15:12:47 -0400 Subject: [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 --- libpod/kube.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/kube.go b/libpod/kube.go index d94108cf2..f6224f07e 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 } -- cgit v1.2.3-54-g00ecf