mirror of https://github.com/containers/podman.git
Merge pull request #15946 from rhatdan/kube
Default missing hostPort to containerPort is defined in kube.yaml
This commit is contained in:
commit
dca5ead2d7
|
@ -914,6 +914,9 @@ func getPodPorts(containers []v1.Container) []types.PortMapping {
|
||||||
if p.HostPort != 0 && p.ContainerPort == 0 {
|
if p.HostPort != 0 && p.ContainerPort == 0 {
|
||||||
p.ContainerPort = p.HostPort
|
p.ContainerPort = p.HostPort
|
||||||
}
|
}
|
||||||
|
if p.HostPort == 0 && p.ContainerPort != 0 {
|
||||||
|
p.HostPort = p.ContainerPort
|
||||||
|
}
|
||||||
if p.Protocol == "" {
|
if p.Protocol == "" {
|
||||||
p.Protocol = "tcp"
|
p.Protocol = "tcp"
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,6 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: podnameEqualsContainerNameYaml
|
- name: podnameEqualsContainerNameYaml
|
||||||
image: quay.io/libpod/alpine:latest
|
image: quay.io/libpod/alpine:latest
|
||||||
ports:
|
|
||||||
- containerPort: 80
|
|
||||||
`
|
`
|
||||||
|
|
||||||
var podWithoutAName = `
|
var podWithoutAName = `
|
||||||
|
@ -239,8 +237,6 @@ spec:
|
||||||
- "1.5"
|
- "1.5"
|
||||||
name: alpine
|
name: alpine
|
||||||
image: quay.io/libpod/alpine:latest
|
image: quay.io/libpod/alpine:latest
|
||||||
ports:
|
|
||||||
- containerPort: 80
|
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
|
@ -274,8 +270,6 @@ spec:
|
||||||
- "1.5"
|
- "1.5"
|
||||||
name: alpine
|
name: alpine
|
||||||
image: quay.io/libpod/alpine:latest
|
image: quay.io/libpod/alpine:latest
|
||||||
ports:
|
|
||||||
- containerPort: 80
|
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
exec:
|
exec:
|
||||||
command:
|
command:
|
||||||
|
|
|
@ -386,3 +386,27 @@ status: {}
|
||||||
run_podman rm -a -f
|
run_podman rm -a -f
|
||||||
run_podman rm -f -t0 myyaml
|
run_podman rm -f -t0 myyaml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "podman kube play - hostport" {
|
||||||
|
HOST_PORT=$(random_free_port)
|
||||||
|
echo "
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: test
|
||||||
|
name: test_pod
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: server
|
||||||
|
image: $IMAGE
|
||||||
|
ports:
|
||||||
|
- name: hostp
|
||||||
|
containerPort: $HOST_PORT
|
||||||
|
" > $PODMAN_TMPDIR/testpod.yaml
|
||||||
|
|
||||||
|
run_podman kube play $PODMAN_TMPDIR/testpod.yaml
|
||||||
|
run_podman pod inspect test_pod --format "{{.InfraConfig.PortBindings}}"
|
||||||
|
assert "$output" = "map[$HOST_PORT/tcp:[{ $HOST_PORT}]]"
|
||||||
|
run_podman kube down $PODMAN_TMPDIR/testpod.yaml
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue