forked from LaconicNetwork/kompose
Fix port duplicate in container spec (#1223)
This commit is contained in:
parent
25337eb82c
commit
0a2fa1a978
@ -547,8 +547,12 @@ func (k *Kubernetes) CreatePVC(name string, mode string, size string, selectorVa
|
|||||||
// ConfigPorts configures the container ports.
|
// ConfigPorts configures the container ports.
|
||||||
func (k *Kubernetes) ConfigPorts(name string, service kobject.ServiceConfig) []api.ContainerPort {
|
func (k *Kubernetes) ConfigPorts(name string, service kobject.ServiceConfig) []api.ContainerPort {
|
||||||
ports := []api.ContainerPort{}
|
ports := []api.ContainerPort{}
|
||||||
|
exist := map[string]bool{}
|
||||||
for _, port := range service.Port {
|
for _, port := range service.Port {
|
||||||
|
// temp use as an id
|
||||||
|
if exist[string(port.ContainerPort)+string(port.Protocol)] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// If the default is already TCP, no need to include it.
|
// If the default is already TCP, no need to include it.
|
||||||
if port.Protocol == api.ProtocolTCP {
|
if port.Protocol == api.ProtocolTCP {
|
||||||
ports = append(ports, api.ContainerPort{
|
ports = append(ports, api.ContainerPort{
|
||||||
@ -562,6 +566,7 @@ func (k *Kubernetes) ConfigPorts(name string, service kobject.ServiceConfig) []a
|
|||||||
HostIP: port.HostIP,
|
HostIP: port.HostIP,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
exist[string(port.ContainerPort)+string(port.Protocol)] = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -135,9 +135,6 @@
|
|||||||
"imagePullPolicy": "",
|
"imagePullPolicy": "",
|
||||||
"name": "etherpad",
|
"name": "etherpad",
|
||||||
"ports": [
|
"ports": [
|
||||||
{
|
|
||||||
"containerPort": 9001
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"containerPort": 9001
|
"containerPort": 9001
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,9 +127,6 @@
|
|||||||
"name": "etherpad",
|
"name": "etherpad",
|
||||||
"image": " ",
|
"image": " ",
|
||||||
"ports": [
|
"ports": [
|
||||||
{
|
|
||||||
"containerPort": 9001
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"containerPort": 9001
|
"containerPort": 9001
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ services:
|
|||||||
image: tuna/docker-counter23
|
image: tuna/docker-counter23
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000/tcp"
|
- "5000:5000/tcp"
|
||||||
|
- "5001:5000/tcp"
|
||||||
links:
|
links:
|
||||||
- redis
|
- redis
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@ -59,6 +59,11 @@
|
|||||||
"name": "5000",
|
"name": "5000",
|
||||||
"port": 5000,
|
"port": 5000,
|
||||||
"targetPort": 5000
|
"targetPort": 5000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "5001",
|
||||||
|
"port": 5001,
|
||||||
|
"targetPort": 5000
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"selector": {
|
"selector": {
|
||||||
|
|||||||
@ -59,6 +59,11 @@
|
|||||||
"name": "5000",
|
"name": "5000",
|
||||||
"port": 5000,
|
"port": 5000,
|
||||||
"targetPort": 5000
|
"targetPort": 5000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "5001",
|
||||||
|
"port": 5001,
|
||||||
|
"targetPort": 5000
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"selector": {
|
"selector": {
|
||||||
|
|||||||
@ -229,9 +229,6 @@
|
|||||||
],
|
],
|
||||||
"workingDir": "/code",
|
"workingDir": "/code",
|
||||||
"ports": [
|
"ports": [
|
||||||
{
|
|
||||||
"containerPort": 3000
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"containerPort": 3000
|
"containerPort": 3000
|
||||||
},
|
},
|
||||||
|
|||||||
@ -229,9 +229,6 @@
|
|||||||
],
|
],
|
||||||
"workingDir": "/code",
|
"workingDir": "/code",
|
||||||
"ports": [
|
"ports": [
|
||||||
{
|
|
||||||
"containerPort": 3000
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"containerPort": 3000
|
"containerPort": 3000
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user