summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-27 09:32:49 -0400
committerGitHub <noreply@github.com>2022-04-27 09:32:49 -0400
commitc44efb011003942adedb6ac74457be0123d23a02 (patch)
treeadf0fa745aac5370ac8f55ff02100408a057d777
parent053b09660ffbe2df2104186c67e39be70764ff63 (diff)
parent70a2c000891ca45c53a39753ad7fb7fde8384812 (diff)
downloadpodman-c44efb011003942adedb6ac74457be0123d23a02.tar.gz
podman-c44efb011003942adedb6ac74457be0123d23a02.tar.bz2
podman-c44efb011003942adedb6ac74457be0123d23a02.zip
Merge pull request #14029 from Luap99/kube-hostnet
play kube respect hostNetwork
-rw-r--r--pkg/domain/infra/abi/play.go22
-rw-r--r--test/e2e/play_kube_test.go17
2 files changed, 24 insertions, 15 deletions
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 45500b23c..5de475480 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -199,18 +199,20 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
return nil, err
}
- ns, networks, netOpts, err := specgen.ParseNetworkFlag(options.Networks)
- if err != nil {
- return nil, err
- }
+ if len(options.Networks) > 0 {
+ ns, networks, netOpts, err := specgen.ParseNetworkFlag(options.Networks)
+ if err != nil {
+ return nil, err
+ }
- if (ns.IsBridge() && len(networks) == 0) || ns.IsHost() {
- return nil, errors.Errorf("invalid value passed to --network: bridge or host networking must be configured in YAML")
- }
+ if (ns.IsBridge() && len(networks) == 0) || ns.IsHost() {
+ return nil, errors.Errorf("invalid value passed to --network: bridge or host networking must be configured in YAML")
+ }
- podOpt.Net.Network = ns
- podOpt.Net.Networks = networks
- podOpt.Net.NetworkOptions = netOpts
+ podOpt.Net.Network = ns
+ podOpt.Net.Networks = networks
+ podOpt.Net.NetworkOptions = netOpts
+ }
// FIXME This is very hard to support properly with a good ux
if len(options.StaticIPs) > *ipIndex {
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 6d89a844e..46a8e88bc 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -2779,11 +2779,7 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
})
It("podman play kube test with HostNetwork", func() {
- if !strings.Contains(podmanTest.OCIRuntime, "crun") {
- Skip("Test only works on crun")
- }
-
- pod := getPod(withHostNetwork())
+ pod := getPod(withHostNetwork(), withCtr(getCtr(withCmd([]string{"readlink", "/proc/self/ns/net"}), withArg(nil))))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -2795,6 +2791,17 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(Equal("true"))
+
+ ns := SystemExec("readlink", []string{"/proc/self/ns/net"})
+ ns.WaitWithDefaultTimeout()
+ Expect(ns).Should(Exit(0))
+ netns := ns.OutputToString()
+ Expect(netns).ToNot(BeEmpty())
+
+ logs := podmanTest.Podman([]string{"logs", getCtrNameInPod(pod)})
+ logs.WaitWithDefaultTimeout()
+ Expect(logs).Should(Exit(0))
+ Expect(logs.OutputToString()).To(Equal(netns))
})
It("podman play kube persistentVolumeClaim", func() {