Skip to content

Commit

Permalink
[NO TESTS NEEDED] Add port configuration to first regular container
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
umohnani8 committed Sep 28, 2021
1 parent b60cff8 commit a3cdee9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libpod/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit a3cdee9

Please sign in to comment.