Skip to content

Commit 43e1f57

Browse files
authored
feat: add annotation to set health check send proxy protocol (#168)
1 parent a7a896a commit 43e1f57

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

docs/loadbalancer-annotations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ The default is the first zone of the cluster's region.
5353
This is the annotation to set the time between two consecutive health checks.
5454
The default value is `5s`. The duration are go's time.Duration (ex: `1s`, `2m`, `4h`, ...).
5555

56+
### `service.beta.kubernetes.io/scw-loadbalancer-health-check-send-proxy`
57+
This is the annotation to control if proxy protocol should be activated for the health check.
58+
The default value is `false`.
59+
5660
### `service.beta.kubernetes.io/scw-loadbalancer-health-transient-check-delay`
5761
This is the annotation to set the time between two consecutive health checks in a transient state (going UP or DOWN).
5862
The default value is `0.5s`. The duration are go's time.Duration (ex: `1s`, `2m`, `4h`, ...).

scaleway/loadbalancers.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,12 @@ func servicePortToBackend(service *v1.Service, loadbalancer *scwlb.LB, port v1.S
10611061
}
10621062
healthCheck.TransientCheckDelay = healthCheckTransientCheckDelay
10631063

1064+
healthCheckSendProxy, err := getHealthCheckSendProxy(service)
1065+
if err != nil {
1066+
return nil, err
1067+
}
1068+
healthCheck.CheckSendProxy = healthCheckSendProxy
1069+
10641070
healthCheckType, err := getHealthCheckType(service, port.NodePort)
10651071
if err != nil {
10661072
return nil, err

scaleway/loadbalancers_annotations.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ const (
4444
// The default value is "5s". The duration are go's time.Duration (ex: "1s", "2m", "4h", ...)
4545
serviceAnnotationLoadBalancerHealthCheckDelay = "service.beta.kubernetes.io/scw-loadbalancer-health-check-delay"
4646

47+
// serviceAnnotationLoadBalancerHealthCheckSendProxy is the annotation to control if proxy protocol should be activated for the health check.
48+
// The default value is "false"
49+
serviceAnnotationLoadBalancerHealthCheckSendProxy = "service.beta.kubernetes.io/scw-loadbalancer-health-check-send-proxy"
50+
4751
// serviceAnnotationLoadBalancerHealthTransientCheckDelay is the time between two consecutive health checks on transient state (going UP or DOWN)
4852
// The default value is "0.5s". The duration are go's time.Duration (ex: "1s", "2m", "4h", ...)
4953
serviceAnnotationLoadBalancerHealthTransientCheckDelay = "service.beta.kubernetes.io/scw-loadbalancer-health-transient-check-delay"
@@ -483,6 +487,20 @@ func getHealthCheckMaxRetries(service *v1.Service) (int32, error) {
483487
return int32(healthCheckMaxRetriesInt), nil
484488
}
485489

490+
func getHealthCheckSendProxy(service *v1.Service) (bool, error) {
491+
sendProxy, ok := service.Annotations[serviceAnnotationLoadBalancerHealthCheckSendProxy]
492+
if !ok {
493+
return false, nil
494+
}
495+
sendProxyBool, err := strconv.ParseBool(sendProxy)
496+
if err != nil {
497+
klog.Errorf("invalid value for annotation %s", serviceAnnotationLoadBalancerHealthCheckSendProxy)
498+
return false, errLoadBalancerInvalidAnnotation
499+
}
500+
501+
return sendProxyBool, nil
502+
}
503+
486504
func getHealthCheckTransientCheckDelay(service *v1.Service) (*scw.Duration, error) {
487505
transientCheckDelay, ok := service.Annotations[serviceAnnotationLoadBalancerHealthTransientCheckDelay]
488506
if !ok {

0 commit comments

Comments
 (0)