remote: fix podman-remote kube play --publish-all

Fix `podman kube play --publish-all` to work in remote environment.

Signed-off-by: Tsubasa Watanabe <w.tsubasa@fujitsu.com>
This commit is contained in:
Tsubasa Watanabe 2023-12-29 12:41:54 +09:00
parent 7dc7cbfd9b
commit 4f94c96b9b
3 changed files with 18 additions and 0 deletions

View File

@ -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,

View File

@ -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

View File

@ -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())