@@ -20,6 +20,7 @@ import (
20
20
"context"
21
21
"fmt"
22
22
"net"
23
+ "net/url"
23
24
"os"
24
25
"reflect"
25
26
"strconv"
@@ -79,7 +80,7 @@ const (
79
80
serviceAnnotationLoadBalancerHealthCheckMaxRetries = "service.beta.kubernetes.io/scw-loadbalancer-health-check-max-retries"
80
81
81
82
// serviceAnnotationLoadBalancerHealthCheckHTTPURI is the URI that is used by the "http" health check
82
- // It is possible to set the uri per port, like "80:/;443,8443:/healthz"
83
+ // It is possible to set the uri per port, like "80:/;443,8443:mydomain.tld /healthz"
83
84
// NB: Required when setting service.beta.kubernetes.io/scw-loadbalancer-health-check-type to "http" or "https"
84
85
serviceAnnotationLoadBalancerHealthCheckHTTPURI = "service.beta.kubernetes.io/scw-loadbalancer-health-check-http-uri"
85
86
@@ -1510,19 +1511,29 @@ func getHTTPHealthCheck(service *v1.Service, nodePort int32) (*scwlb.HealthCheck
1510
1511
if err != nil {
1511
1512
return nil , err
1512
1513
}
1513
- uri , err := getHTTPHealthCheckURI (service , nodePort )
1514
+
1515
+ uriStr , err := getHTTPHealthCheckURI (service , nodePort )
1516
+ if err != nil {
1517
+ return nil , err
1518
+ }
1519
+ uri , err := url .Parse (fmt .Sprintf ("http://%s" , uriStr ))
1514
1520
if err != nil {
1515
1521
return nil , err
1516
1522
}
1523
+ if uri .Path == "" {
1524
+ uri .Path = "/"
1525
+ }
1526
+
1517
1527
method , err := getHTTPHealthCheckMethod (service , nodePort )
1518
1528
if err != nil {
1519
1529
return nil , err
1520
1530
}
1521
1531
1522
1532
return & scwlb.HealthCheckHTTPConfig {
1523
- Method : method ,
1524
- Code : & code ,
1525
- URI : uri ,
1533
+ Method : method ,
1534
+ Code : & code ,
1535
+ URI : uri .Path ,
1536
+ HostHeader : uri .Host ,
1526
1537
}, nil
1527
1538
}
1528
1539
@@ -1531,19 +1542,30 @@ func getHTTPSHealthCheck(service *v1.Service, nodePort int32) (*scwlb.HealthChec
1531
1542
if err != nil {
1532
1543
return nil , err
1533
1544
}
1534
- uri , err := getHTTPHealthCheckURI (service , nodePort )
1545
+
1546
+ uriStr , err := getHTTPHealthCheckURI (service , nodePort )
1535
1547
if err != nil {
1536
1548
return nil , err
1537
1549
}
1550
+ uri , err := url .Parse (fmt .Sprintf ("https://%s" , uriStr ))
1551
+ if err != nil {
1552
+ return nil , err
1553
+ }
1554
+ if uri .Path == "" {
1555
+ uri .Path = "/"
1556
+ }
1557
+
1538
1558
method , err := getHTTPHealthCheckMethod (service , nodePort )
1539
1559
if err != nil {
1540
1560
return nil , err
1541
1561
}
1542
1562
1543
1563
return & scwlb.HealthCheckHTTPSConfig {
1544
- Method : method ,
1545
- Code : & code ,
1546
- URI : uri ,
1564
+ Method : method ,
1565
+ Code : & code ,
1566
+ URI : uri .Path ,
1567
+ HostHeader : uri .Host ,
1568
+ Sni : uri .Host ,
1547
1569
}, nil
1548
1570
}
1549
1571
@@ -1905,65 +1927,9 @@ func backendEquals(got, want *scwlb.Backend) bool {
1905
1927
return false
1906
1928
}
1907
1929
1908
- // TODO
1909
- if got .HealthCheck != want .HealthCheck {
1910
- if got .HealthCheck == nil || want .HealthCheck == nil {
1911
- klog .V (3 ).Infof ("backend.HealthCheck: %s - %s" , got .HealthCheck , want .HealthCheck )
1912
- return false
1913
- }
1914
-
1915
- if got .HealthCheck .Port != want .HealthCheck .Port {
1916
- klog .V (3 ).Infof ("backend.HealthCheck.Port: %s - %s" , got .HealthCheck .Port , want .HealthCheck .Port )
1917
- return false
1918
- }
1919
- if ! durationPtrEqual (got .HealthCheck .CheckDelay , want .HealthCheck .CheckDelay ) {
1920
- klog .V (3 ).Infof ("backend.HealthCheck.CheckDelay: %s - %s" , got .HealthCheck .CheckDelay , want .HealthCheck .CheckDelay )
1921
- return false
1922
- }
1923
- if ! durationPtrEqual (got .HealthCheck .CheckTimeout , want .HealthCheck .CheckTimeout ) {
1924
- klog .V (3 ).Infof ("backend.HealthCheck.CheckTimeout: %s - %s" , got .HealthCheck .CheckTimeout , want .HealthCheck .CheckTimeout )
1925
- return false
1926
- }
1927
- if got .HealthCheck .CheckMaxRetries != want .HealthCheck .CheckMaxRetries {
1928
- klog .V (3 ).Infof ("backend.HealthCheck.CheckMaxRetries: %s - %s" , got .HealthCheck .CheckMaxRetries , want .HealthCheck .CheckMaxRetries )
1929
- return false
1930
- }
1931
- if got .HealthCheck .CheckSendProxy != want .HealthCheck .CheckSendProxy {
1932
- klog .V (3 ).Infof ("backend.HealthCheck.CheckSendProxy: %s - %s" , got .HealthCheck .CheckSendProxy , want .HealthCheck .CheckSendProxy )
1933
- return false
1934
- }
1935
- if (got .HealthCheck .TCPConfig == nil ) != (want .HealthCheck .TCPConfig == nil ) {
1936
- klog .V (3 ).Infof ("backend.HealthCheck.TCPConfig: %s - %s" , got .HealthCheck .TCPConfig , want .HealthCheck .TCPConfig )
1937
- return false
1938
- }
1939
- if (got .HealthCheck .MysqlConfig == nil ) != (want .HealthCheck .MysqlConfig == nil ) {
1940
- klog .V (3 ).Infof ("backend.HealthCheck.MysqlConfig: %s - %s" , got .HealthCheck .MysqlConfig , want .HealthCheck .MysqlConfig )
1941
- return false
1942
- }
1943
- if (got .HealthCheck .PgsqlConfig == nil ) != (want .HealthCheck .PgsqlConfig == nil ) {
1944
- klog .V (3 ).Infof ("backend.HealthCheck.PgsqlConfig: %s - %s" , got .HealthCheck .PgsqlConfig , want .HealthCheck .PgsqlConfig )
1945
- return false
1946
- }
1947
- if (got .HealthCheck .LdapConfig == nil ) != (want .HealthCheck .LdapConfig == nil ) {
1948
- klog .V (3 ).Infof ("backend.HealthCheck.LdapConfig: %s - %s" , got .HealthCheck .LdapConfig , want .HealthCheck .LdapConfig )
1949
- return false
1950
- }
1951
- if (got .HealthCheck .RedisConfig == nil ) != (want .HealthCheck .RedisConfig == nil ) {
1952
- klog .V (3 ).Infof ("backend.HealthCheck.RedisConfig: %s - %s" , got .HealthCheck .RedisConfig , want .HealthCheck .RedisConfig )
1953
- return false
1954
- }
1955
- if (got .HealthCheck .HTTPConfig == nil ) != (want .HealthCheck .HTTPConfig == nil ) {
1956
- klog .V (3 ).Infof ("backend.HealthCheck.HTTPConfig: %s - %s" , got .HealthCheck .HTTPConfig , want .HealthCheck .HTTPConfig )
1957
- return false
1958
- }
1959
- if (got .HealthCheck .HTTPSConfig == nil ) != (want .HealthCheck .HTTPSConfig == nil ) {
1960
- klog .V (3 ).Infof ("backend.HealthCheck.HTTPSConfig: %s - %s" , got .HealthCheck .HTTPSConfig , want .HealthCheck .HTTPSConfig )
1961
- return false
1962
- }
1963
- if ! scwDurationPtrEqual (got .HealthCheck .TransientCheckDelay , want .HealthCheck .TransientCheckDelay ) {
1964
- klog .V (3 ).Infof ("backend.HealthCheck.TransientCheckDelay: %s - %s" , got .HealthCheck .TransientCheckDelay , want .HealthCheck .TransientCheckDelay )
1965
- return false
1966
- }
1930
+ if ! reflect .DeepEqual (got .HealthCheck , want .HealthCheck ) {
1931
+ klog .V (3 ).Infof ("backend.HealthCheck: %s - %s" , got .HealthCheck , want .HealthCheck )
1932
+ return false
1967
1933
}
1968
1934
1969
1935
return true
@@ -2074,7 +2040,7 @@ func aclsEquals(got []*scwlb.ACL, want []*scwlb.ACLSpec) bool {
2074
2040
2075
2041
slices .SortStableFunc (got , func (a , b * scwlb.ACL ) bool { return a .Index < b .Index })
2076
2042
slices .SortStableFunc (want , func (a , b * scwlb.ACLSpec ) bool { return a .Index < b .Index })
2077
- for idx , _ := range want {
2043
+ for idx := range want {
2078
2044
if want [idx ].Name != got [idx ].Name {
2079
2045
return false
2080
2046
}
@@ -2102,7 +2068,6 @@ func aclsEquals(got []*scwlb.ACL, want []*scwlb.ACLSpec) bool {
2102
2068
}
2103
2069
2104
2070
func (l * loadbalancers ) createBackend (service * v1.Service , loadbalancer * scwlb.LB , backend * scwlb.Backend ) (* scwlb.Backend , error ) {
2105
- // TODO: implement createBackend
2106
2071
b , err := l .api .CreateBackend (& scwlb.ZonedAPICreateBackendRequest {
2107
2072
Zone : getLoadBalancerZone (service ),
2108
2073
LBID : loadbalancer .ID ,
@@ -2130,7 +2095,6 @@ func (l *loadbalancers) createBackend(service *v1.Service, loadbalancer *scwlb.L
2130
2095
}
2131
2096
2132
2097
func (l * loadbalancers ) updateBackend (service * v1.Service , loadbalancer * scwlb.LB , backend * scwlb.Backend ) (* scwlb.Backend , error ) {
2133
- // TODO: implement updateBackend
2134
2098
b , err := l .api .UpdateBackend (& scwlb.ZonedAPIUpdateBackendRequest {
2135
2099
Zone : getLoadBalancerZone (service ),
2136
2100
BackendID : backend .ID ,
0 commit comments