From f5fc0960e5eddf64a7d8fbf8fbfd3652b4ee5db3 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 26 Sep 2022 14:48:37 -0400 Subject: 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 --- test/system/700-play.bats | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/system') diff --git a/test/system/700-play.bats b/test/system/700-play.bats index bad9544ff..578d28394 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -386,3 +386,27 @@ status: {} run_podman rm -a -f run_podman rm -f -t0 myyaml } + +@test "podman kube play - hostport" { + HOST_PORT=$(random_free_port) + echo " +apiVersion: v1 +kind: Pod +metadata: + labels: + app: test + name: test_pod +spec: + containers: + - name: server + image: $IMAGE + ports: + - name: hostp + containerPort: $HOST_PORT +" > $PODMAN_TMPDIR/testpod.yaml + + run_podman kube play $PODMAN_TMPDIR/testpod.yaml + run_podman pod inspect test_pod --format "{{.InfraConfig.PortBindings}}" + assert "$output" = "map[$HOST_PORT/tcp:[{ $HOST_PORT}]]" + run_podman kube down $PODMAN_TMPDIR/testpod.yaml +} -- cgit v1.2.3-54-g00ecf