Use service UID as the ELB name

This commit is contained in:
caesarxuchao
2015-04-21 12:20:42 -07:00
parent 2a3e0796f8
commit e9c5e44767
4 changed files with 20 additions and 11 deletions

View File

@@ -18,6 +18,7 @@ package cloudprovider
import (
"net"
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
)
@@ -44,8 +45,15 @@ type Clusters interface {
// TODO(#6812): Use a shorter name that's less likely to be longer than cloud
// providers' name length limits.
func GetLoadBalancerName(clusterName, serviceNamespace, serviceName string) string {
return clusterName + "-" + serviceNamespace + "-" + serviceName
func GetLoadBalancerName(service *api.Service) string {
//GCE requires that the name of a load balancer starts with a lower case letter.
ret := "a" + string(service.UID)
ret = strings.Replace(ret, "-", "", -1)
//AWS requires that the name of a load balancer is shorter than 32 bytes.
if len(ret) > 32 {
ret = ret[:32]
}
return ret
}
// TCPLoadBalancer is an abstract, pluggable interface for TCP load balancers.