@@ -110,9 +110,7 @@ func (l *loadBalancers) GetLoadBalancer(ctx context.Context, _ string, service *
110110 logger .WithValues ("ip_address" , xlb .virtualIPAddress ).Info ("Load balancer virtual IP address" )
111111
112112 return & v1.LoadBalancerStatus {
113- Ingress : []v1.LoadBalancerIngress {{
114- IP : xlb .virtualIPAddress ,
115- }},
113+ Ingress : l .buildLoadBalancerStatusIngress (xlb , service ),
116114 }, true , nil
117115}
118116
@@ -145,9 +143,7 @@ func (l *loadBalancers) EnsureLoadBalancer(ctx context.Context, clusterName stri
145143 }
146144
147145 return & v1.LoadBalancerStatus {
148- Ingress : []v1.LoadBalancerIngress {{
149- IP : xlb .virtualIPAddress ,
150- }},
146+ Ingress : l .buildLoadBalancerStatusIngress (xlb , service ),
151147 }, nil
152148}
153149
@@ -537,6 +533,33 @@ func (l *loadBalancers) updateLoadBalancer(ctx context.Context, xlb *xelonLoadBa
537533 return nil
538534}
539535
536+ func (l * loadBalancers ) buildLoadBalancerStatusIngress (ctx context.Context , xlb * xelonLoadBalancer , service * v1.Service ) []v1.LoadBalancerIngress {
537+ logger := configureLogger (ctx , "buildLoadBalancerStatusIngress" ).WithValues (
538+ "service" , getServiceNameWithNamespace (service ),
539+ )
540+
541+ ipMode := v1 .LoadBalancerIPModeVIP
542+
543+ protocolVersion := 0
544+ if protocolVersionAsString , ok := service .Annotations [serviceAnnotationLoadBalancerClusterProxyProtocolVersion ]; ok && protocolVersionAsString != "" {
545+ parsedProtocolVersion , err := strconv .Atoi (protocolVersionAsString )
546+ if err != nil {
547+ logger .Info ("Could not convert proxy protocol version, fallback to 0" )
548+ } else {
549+ protocolVersion = parsedProtocolVersion
550+ logger .Info ("Proxy protocol annotation is defined and will be used for load balancer ingress" , "proxy_protocol" , protocolVersion )
551+ }
552+ }
553+ if protocolVersion > 0 {
554+ ipMode = v1 .LoadBalancerIPModeProxy
555+ }
556+
557+ return []v1.LoadBalancerIngress {{
558+ IP : xlb .virtualIPAddress ,
559+ IPMode : & ipMode ,
560+ }}
561+ }
562+
540563func updateServiceAnnotation (service * v1.Service , annotationName , annotationValue string ) {
541564 if service .ObjectMeta .Annotations == nil {
542565 service .ObjectMeta .Annotations = map [string ]string {}
0 commit comments