Fix port duplicate in container spec (#1223)

This commit is contained in:
Hang Yan 2019-12-29 11:32:33 +08:00 committed by GitHub
parent 25337eb82c
commit 0a2fa1a978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 13 deletions

View File

@ -547,8 +547,12 @@ func (k *Kubernetes) CreatePVC(name string, mode string, size string, selectorVa
// ConfigPorts configures the container ports.
func (k *Kubernetes) ConfigPorts(name string, service kobject.ServiceConfig) []api.ContainerPort {
ports := []api.ContainerPort{}
exist := map[string]bool{}
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 port.Protocol == api.ProtocolTCP {
ports = append(ports, api.ContainerPort{
@ -562,6 +566,7 @@ func (k *Kubernetes) ConfigPorts(name string, service kobject.ServiceConfig) []a
HostIP: port.HostIP,
})
}
exist[string(port.ContainerPort)+string(port.Protocol)] = true
}

View File

@ -135,9 +135,6 @@
"imagePullPolicy": "",
"name": "etherpad",
"ports": [
{
"containerPort": 9001
},
{
"containerPort": 9001
}

View File

@ -127,9 +127,6 @@
"name": "etherpad",
"image": " ",
"ports": [
{
"containerPort": 9001
},
{
"containerPort": 9001
}

View File

@ -5,6 +5,7 @@ services:
image: tuna/docker-counter23
ports:
- "5000:5000/tcp"
- "5001:5000/tcp"
links:
- redis
networks:

View File

@ -59,6 +59,11 @@
"name": "5000",
"port": 5000,
"targetPort": 5000
},
{
"name": "5001",
"port": 5001,
"targetPort": 5000
}
],
"selector": {

View File

@ -59,6 +59,11 @@
"name": "5000",
"port": 5000,
"targetPort": 5000
},
{
"name": "5001",
"port": 5001,
"targetPort": 5000
}
],
"selector": {

View File

@ -229,9 +229,6 @@
],
"workingDir": "/code",
"ports": [
{
"containerPort": 3000
},
{
"containerPort": 3000
},

View File

@ -229,9 +229,6 @@
],
"workingDir": "/code",
"ports": [
{
"containerPort": 3000
},
{
"containerPort": 3000
},