added cluster-name
This commit is contained in:
parent
9e85a199a7
commit
393904c21c
3 changed files with 15 additions and 8 deletions
|
|
@ -60,6 +60,14 @@ func (lb *loadbalancer) GetLoadBalancerName(ctx context.Context, clusterName str
|
|||
return fullname(clusterName, service)
|
||||
}
|
||||
|
||||
const (
|
||||
FrontendHAProxyLBOptions = "frontend.haproxy-lb/options"
|
||||
BackendHAProxyLBOptions = "backend.haproxy-lb/options"
|
||||
BackendHAProxyLBProxyProtocol = "backend.haproxy-lb/proxy-protocol"
|
||||
BackendHAProxyLBCheckProxyProtocol = "backend.haproxy-lb/check-proxy-protocol"
|
||||
BackendHAProxyLBDefaultServer = "backend.haproxy-lb/default-server"
|
||||
)
|
||||
|
||||
func (lb *loadbalancer) EnsureLoadBalancer(ctx context.Context, clusterName string, service *v1.Service, nodes []*v1.Node) (status *v1.LoadBalancerStatus, err error) {
|
||||
/*TODO service annotations
|
||||
port <node.Status.HealthCheckNodePort (int32)>
|
||||
|
|
@ -69,30 +77,27 @@ func (lb *loadbalancer) EnsureLoadBalancer(ctx context.Context, clusterName stri
|
|||
v1.ServiceExternalTrafficPolicyTypeCluster
|
||||
*/
|
||||
var slb schema.LoadBalancer
|
||||
if fo, ok := service.Annotations["frontend.haproxy-lb/options"]; ok {
|
||||
if fo, ok := service.Annotations[FrontendHAProxyLBOptions]; ok {
|
||||
slb.Options.Frontend = strings.Split(fo, ",")
|
||||
}
|
||||
if bo, ok := service.Annotations["backend.haproxy-lb/options"]; ok {
|
||||
if bo, ok := service.Annotations[BackendHAProxyLBOptions]; ok {
|
||||
slb.Options.Backend = strings.Split(bo, ",")
|
||||
}
|
||||
if cp, ok := service.Annotations["backend.haproxy-lb/proxy-protocol"]; ok {
|
||||
if cp, ok := service.Annotations[BackendHAProxyLBProxyProtocol]; ok {
|
||||
if cp == "v1" || cp == "v2" {
|
||||
slb.Options.ProxyProtocol = cp
|
||||
}
|
||||
}
|
||||
if cpp, ok := service.Annotations["backend.haproxy-lb/check-proxy-protocol"]; ok {
|
||||
if cpp, ok := service.Annotations[BackendHAProxyLBCheckProxyProtocol]; ok {
|
||||
slb.Options.CheckProxyProtocol = cpp == "true"
|
||||
}
|
||||
if df, ok := service.Annotations["backend.haproxy-lb/default-server"]; ok {
|
||||
if df, ok := service.Annotations[BackendHAProxyLBDefaultServer]; ok {
|
||||
slb.Options.DefaultServer = df
|
||||
}
|
||||
|
||||
for _, port := range service.Spec.Ports {
|
||||
sp := schema.Port{Port: int(port.Port)}
|
||||
for _, node := range nodes {
|
||||
if len(node.Status.Addresses) == 0 {
|
||||
continue
|
||||
}
|
||||
ip := ""
|
||||
for _, a := range node.Status.Addresses {
|
||||
if a.Type == v1.NodeInternalIP {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue