diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-07-22 22:45:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-22 22:45:05 +0200 |
commit | 9223b721b38c2605320be540e9abd501a351ed72 (patch) | |
tree | 4386ac6736b2321fb9128f4d2752887dc5e61e75 /test/e2e | |
parent | d493374eb4b0e9f5f58548d445f02c0a8cf00298 (diff) | |
parent | 80f57acc036542cfd19bf19ca596b739be71fd75 (diff) | |
download | podman-9223b721b38c2605320be540e9abd501a351ed72.tar.gz podman-9223b721b38c2605320be540e9abd501a351ed72.tar.bz2 podman-9223b721b38c2605320be540e9abd501a351ed72.zip |
Merge pull request #7053 from ashley-cui/kubeip
Publish IP from YAML (podman play kube)
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/play_kube_test.go | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 652e290b5..052db3842 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -85,6 +85,11 @@ spec: {{ end }} privileged: false readOnlyRootFilesystem: false + ports: + - containerPort: {{ .Port }} + hostIP: {{ .HostIP }} + hostPort: {{ .Port }} + protocol: TCP workingDir: / {{ end }} {{ end }} @@ -336,12 +341,14 @@ type Ctr struct { CapAdd []string CapDrop []string PullPolicy string + HostIP string + Port string } // getCtr takes a list of ctrOptions and returns a Ctr with sane defaults // and the configured options func getCtr(options ...ctrOption) *Ctr { - c := Ctr{defaultCtrName, defaultCtrImage, defaultCtrCmd, defaultCtrArg, true, false, nil, nil, ""} + c := Ctr{defaultCtrName, defaultCtrImage, defaultCtrCmd, defaultCtrArg, true, false, nil, nil, "", "", ""} for _, option := range options { option(&c) } @@ -394,6 +401,13 @@ func withPullPolicy(policy string) ctrOption { } } +func withHostIP(ip string, port string) ctrOption { + return func(c *Ctr) { + c.HostIP = ip + c.Port = port + } +} + func getCtrNameInPod(pod *Pod) string { return fmt.Sprintf("%s-%s", pod.Name, defaultCtrName) } @@ -820,4 +834,23 @@ spec: Expect(inspect.OutputToString()).To(ContainSubstring(correctCmd)) } }) + + It("podman play kube test with network portbindings", func() { + ip := "127.0.0.100" + port := "5000" + ctr := getCtr(withHostIP(ip, port), withImage(BB)) + + pod := getPod(withCtr(ctr)) + err := generatePodKubeYaml(pod, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"port", getCtrNameInPod(pod)}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.OutputToString()).To(Equal("5000/tcp -> 127.0.0.100:5000")) + }) }) |