mirror of
https://github.com/containers/podman.git
synced 2025-12-01 18:49:18 +08:00
kube-play: add support for HostIPC in pod.Spec
* play_kube_test: add tests Signed-off-by: danishprakash <danish.prakash@suse.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -953,6 +954,19 @@ spec:
|
||||
command: ['sh', '-c', 'echo $$']
|
||||
`
|
||||
|
||||
var podWithHostIPCDefined = `
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: test-hostipc
|
||||
spec:
|
||||
hostIPC: true
|
||||
containers:
|
||||
- name: alpine
|
||||
image: quay.io/libpod/alpine:latest
|
||||
command: ['sh', '-c', 'ls -l /proc/self/ns/ipc']
|
||||
`
|
||||
|
||||
var (
|
||||
defaultCtrName = "testCtr"
|
||||
defaultCtrCmd = []string{"top"}
|
||||
@@ -4964,4 +4978,32 @@ spec:
|
||||
Expect(inspect.OutputToString()).To(Equal("host"))
|
||||
})
|
||||
|
||||
It("podman play kube test with hostIPC", func() {
|
||||
err := writeYaml(podWithHostIPCDefined, kubeYaml)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
|
||||
kube.WaitWithDefaultTimeout()
|
||||
Expect(kube).Should(Exit(0))
|
||||
|
||||
inspect := podmanTest.Podman([]string{"inspect", "test-hostipc-alpine", "--format", "{{ .HostConfig.IpcMode }}"})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(Exit(0))
|
||||
Expect(inspect.OutputToString()).To(Equal("shareable"))
|
||||
|
||||
cmd := exec.Command("ls", "-l", "/proc/self/ns/ipc")
|
||||
res, err := cmd.Output()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
fields := strings.Split(string(res), " ")
|
||||
hostIpcNS := strings.TrimSuffix(fields[len(fields)-1], "\n")
|
||||
|
||||
logs := podmanTest.Podman([]string{"pod", "logs", "-c", "test-hostipc-alpine", "test-hostipc"})
|
||||
logs.WaitWithDefaultTimeout()
|
||||
Expect(logs).Should(Exit(0))
|
||||
fields = strings.Split(logs.OutputToString(), " ")
|
||||
ctrIpcNS := strings.TrimSuffix(fields[len(fields)-1], "\n")
|
||||
|
||||
Expect(hostIpcNS).To(Equal(ctrIpcNS))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user