Add support for host:port:port

This adds support for supplying for example:
"127.0.0.1:80:80/tcp" to docker-compose.yaml and converting it to it's
corresponding Kubernetes / OpenShift hostIP.

This commit also refactors the loadPorts function of compose.go

Closes https://github.com/kubernetes-incubator/kompose/issues/335
This commit is contained in:
Charlie Drage
2017-02-09 12:21:17 -05:00
parent be042c7e1f
commit 438088f37d
7 changed files with 287 additions and 20 deletions
+4
View File
@@ -285,13 +285,16 @@ func (k *Kubernetes) ConfigPorts(name string, service kobject.ServiceConfig) []a
if port.Protocol == api.ProtocolTCP {
ports = append(ports, api.ContainerPort{
ContainerPort: port.ContainerPort,
HostIP: port.HostIP,
})
} else {
ports = append(ports, api.ContainerPort{
ContainerPort: port.ContainerPort,
Protocol: port.Protocol,
HostIP: port.HostIP,
})
}
}
return ports
@@ -304,6 +307,7 @@ func (k *Kubernetes) ConfigServicePorts(name string, service kobject.ServiceConf
if port.HostPort == 0 {
port.HostPort = port.ContainerPort
}
var targetPort intstr.IntOrString
targetPort.IntVal = port.ContainerPort
targetPort.StrVal = strconv.Itoa(int(port.ContainerPort))