diff --git a/pkg/api/handlers/libpod/kube.go b/pkg/api/handlers/libpod/kube.go index 1559bfbbcb..e78157c5b5 100644 --- a/pkg/api/handlers/libpod/kube.go +++ b/pkg/api/handlers/libpod/kube.go @@ -27,6 +27,7 @@ func KubePlay(w http.ResponseWriter, r *http.Request) { NoTrunc bool `schema:"noTrunc"` Replace bool `schema:"replace"` PublishPorts []string `schema:"publishPorts"` + PublishAllPorts bool `schema:"publishAllPorts"` ServiceContainer bool `schema:"serviceContainer"` Start bool `schema:"start"` StaticIPs []string `schema:"staticIPs"` @@ -97,6 +98,7 @@ func KubePlay(w http.ResponseWriter, r *http.Request) { NoHosts: query.NoHosts, Password: password, PublishPorts: query.PublishPorts, + PublishAllPorts: query.PublishAllPorts, Quiet: true, Replace: query.Replace, ServiceContainer: query.ServiceContainer, diff --git a/pkg/api/server/register_kube.go b/pkg/api/server/register_kube.go index a944c52a3b..188c9fe441 100644 --- a/pkg/api/server/register_kube.go +++ b/pkg/api/server/register_kube.go @@ -53,6 +53,10 @@ func (s *APIServer) registerKubeHandlers(r *mux.Router) error { // items: // type: string // - in: query + // name: publishAllPorts + // type: boolean + // description: Whether to publish all ports defined in the K8S YAML file (containerPort, hostPort), if false only hostPort will be published + // - in: query // name: replace // type: boolean // default: false diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 8581af4384..f4c1a739bd 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -5644,6 +5644,18 @@ spec: testHTTPServer("19003", false, "podman rulez") }) + It("podman play kube should publish containerPort with --publish-all", func() { + SkipIfRootless("rootlessport can't expose privileged port 80") + err := writeYaml(publishPortsPodWithContainerPort, kubeYaml) + Expect(err).ToNot(HaveOccurred()) + + kube := podmanTest.Podman([]string{"kube", "play", "--publish-all=true", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube).Should(Exit(0)) + + testHTTPServer("80", false, "podman rulez") + }) + It("with Host Ports - curl should succeed", func() { err := writeYaml(publishPortsPodWithContainerHostPort, kubeYaml) Expect(err).ToNot(HaveOccurred())