Pass ports as []*api.ServicePort into LoadBalancer provider

Because AWS needs the NodePort; this also paves the way for e.g. UDP balancing
This commit is contained in:
Justin Santa Barbara
2015-05-22 19:42:04 -04:00
parent 12901d0ada
commit c741b8f3ae
6 changed files with 58 additions and 21 deletions

View File

@@ -326,7 +326,7 @@ func translateAffinityType(affinityType api.ServiceAffinity) GCEAffinityType {
// CreateTCPLoadBalancer is an implementation of TCPLoadBalancer.CreateTCPLoadBalancer.
// TODO(a-robinson): Don't just ignore specified IP addresses. Check if they're
// owned by the project and available to be used, and use them if they are.
func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.IP, ports []int, hosts []string, affinityType api.ServiceAffinity) (*api.LoadBalancerStatus, error) {
func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.IP, ports []*api.ServicePort, hosts []string, affinityType api.ServiceAffinity) (*api.LoadBalancerStatus, error) {
err := gce.makeTargetPool(name, region, hosts, translateAffinityType(affinityType))
if err != nil {
if !isHTTPErrorCode(err, http.StatusConflict) {
@@ -341,11 +341,11 @@ func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.I
minPort := 65536
maxPort := 0
for i := range ports {
if ports[i] < minPort {
minPort = ports[i]
if ports[i].Port < minPort {
minPort = ports[i].Port
}
if ports[i] > maxPort {
maxPort = ports[i]
if ports[i].Port > maxPort {
maxPort = ports[i].Port
}
}
req := &compute.ForwardingRule{