diff --git a/docs/loadbalancer-annotations.md b/docs/loadbalancer-annotations.md index 40d3b37..378e048 100644 --- a/docs/loadbalancer-annotations.md +++ b/docs/loadbalancer-annotations.md @@ -53,6 +53,10 @@ The default is the first zone of the cluster's region. This is the annotation to set the time between two consecutive health checks. The default value is `5s`. The duration are go's time.Duration (ex: `1s`, `2m`, `4h`, ...). +### `service.beta.kubernetes.io/scw-loadbalancer-health-check-send-proxy` +This is the annotation to control if proxy protocol should be activated for the health check. +The default value is `false`. + ### `service.beta.kubernetes.io/scw-loadbalancer-health-transient-check-delay` This is the annotation to set the time between two consecutive health checks in a transient state (going UP or DOWN). The default value is `0.5s`. The duration are go's time.Duration (ex: `1s`, `2m`, `4h`, ...). diff --git a/scaleway/loadbalancers.go b/scaleway/loadbalancers.go index 5339dc1..417bf3b 100644 --- a/scaleway/loadbalancers.go +++ b/scaleway/loadbalancers.go @@ -1061,6 +1061,12 @@ func servicePortToBackend(service *v1.Service, loadbalancer *scwlb.LB, port v1.S } healthCheck.TransientCheckDelay = healthCheckTransientCheckDelay + healthCheckSendProxy, err := getHealthCheckSendProxy(service) + if err != nil { + return nil, err + } + healthCheck.CheckSendProxy = healthCheckSendProxy + healthCheckType, err := getHealthCheckType(service, port.NodePort) if err != nil { return nil, err diff --git a/scaleway/loadbalancers_annotations.go b/scaleway/loadbalancers_annotations.go index 7ed43c9..8a1c55f 100644 --- a/scaleway/loadbalancers_annotations.go +++ b/scaleway/loadbalancers_annotations.go @@ -44,6 +44,10 @@ const ( // The default value is "5s". The duration are go's time.Duration (ex: "1s", "2m", "4h", ...) serviceAnnotationLoadBalancerHealthCheckDelay = "service.beta.kubernetes.io/scw-loadbalancer-health-check-delay" + // serviceAnnotationLoadBalancerHealthCheckSendProxy is the annotation to control if proxy protocol should be activated for the health check. + // The default value is "false" + serviceAnnotationLoadBalancerHealthCheckSendProxy = "service.beta.kubernetes.io/scw-loadbalancer-health-check-send-proxy" + // serviceAnnotationLoadBalancerHealthTransientCheckDelay is the time between two consecutive health checks on transient state (going UP or DOWN) // The default value is "0.5s". The duration are go's time.Duration (ex: "1s", "2m", "4h", ...) serviceAnnotationLoadBalancerHealthTransientCheckDelay = "service.beta.kubernetes.io/scw-loadbalancer-health-transient-check-delay" @@ -483,6 +487,20 @@ func getHealthCheckMaxRetries(service *v1.Service) (int32, error) { return int32(healthCheckMaxRetriesInt), nil } +func getHealthCheckSendProxy(service *v1.Service) (bool, error) { + sendProxy, ok := service.Annotations[serviceAnnotationLoadBalancerHealthCheckSendProxy] + if !ok { + return false, nil + } + sendProxyBool, err := strconv.ParseBool(sendProxy) + if err != nil { + klog.Errorf("invalid value for annotation %s", serviceAnnotationLoadBalancerHealthCheckSendProxy) + return false, errLoadBalancerInvalidAnnotation + } + + return sendProxyBool, nil +} + func getHealthCheckTransientCheckDelay(service *v1.Service) (*scw.Duration, error) { transientCheckDelay, ok := service.Annotations[serviceAnnotationLoadBalancerHealthTransientCheckDelay] if !ok {