@@ -20,6 +20,7 @@ import (
2020 "context"
2121 "fmt"
2222 "net"
23+ "net/url"
2324 "os"
2425 "reflect"
2526 "strconv"
@@ -79,7 +80,7 @@ const (
7980 serviceAnnotationLoadBalancerHealthCheckMaxRetries = "service.beta.kubernetes.io/scw-loadbalancer-health-check-max-retries"
8081
8182 // 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"
8384 // NB: Required when setting service.beta.kubernetes.io/scw-loadbalancer-health-check-type to "http" or "https"
8485 serviceAnnotationLoadBalancerHealthCheckHTTPURI = "service.beta.kubernetes.io/scw-loadbalancer-health-check-http-uri"
8586
@@ -1510,19 +1511,29 @@ func getHTTPHealthCheck(service *v1.Service, nodePort int32) (*scwlb.HealthCheck
15101511 if err != nil {
15111512 return nil , err
15121513 }
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 ))
15141520 if err != nil {
15151521 return nil , err
15161522 }
1523+ if uri .Path == "" {
1524+ uri .Path = "/"
1525+ }
1526+
15171527 method , err := getHTTPHealthCheckMethod (service , nodePort )
15181528 if err != nil {
15191529 return nil , err
15201530 }
15211531
15221532 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 ,
15261537 }, nil
15271538}
15281539
@@ -1531,19 +1542,30 @@ func getHTTPSHealthCheck(service *v1.Service, nodePort int32) (*scwlb.HealthChec
15311542 if err != nil {
15321543 return nil , err
15331544 }
1534- uri , err := getHTTPHealthCheckURI (service , nodePort )
1545+
1546+ uriStr , err := getHTTPHealthCheckURI (service , nodePort )
15351547 if err != nil {
15361548 return nil , err
15371549 }
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+
15381558 method , err := getHTTPHealthCheckMethod (service , nodePort )
15391559 if err != nil {
15401560 return nil , err
15411561 }
15421562
15431563 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 ,
15471569 }, nil
15481570}
15491571
@@ -1905,65 +1927,9 @@ func backendEquals(got, want *scwlb.Backend) bool {
19051927 return false
19061928 }
19071929
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
19671933 }
19681934
19691935 return true
@@ -2074,7 +2040,7 @@ func aclsEquals(got []*scwlb.ACL, want []*scwlb.ACLSpec) bool {
20742040
20752041 slices .SortStableFunc (got , func (a , b * scwlb.ACL ) bool { return a .Index < b .Index })
20762042 slices .SortStableFunc (want , func (a , b * scwlb.ACLSpec ) bool { return a .Index < b .Index })
2077- for idx , _ := range want {
2043+ for idx := range want {
20782044 if want [idx ].Name != got [idx ].Name {
20792045 return false
20802046 }
@@ -2102,7 +2068,6 @@ func aclsEquals(got []*scwlb.ACL, want []*scwlb.ACLSpec) bool {
21022068}
21032069
21042070func (l * loadbalancers ) createBackend (service * v1.Service , loadbalancer * scwlb.LB , backend * scwlb.Backend ) (* scwlb.Backend , error ) {
2105- // TODO: implement createBackend
21062071 b , err := l .api .CreateBackend (& scwlb.ZonedAPICreateBackendRequest {
21072072 Zone : getLoadBalancerZone (service ),
21082073 LBID : loadbalancer .ID ,
@@ -2130,7 +2095,6 @@ func (l *loadbalancers) createBackend(service *v1.Service, loadbalancer *scwlb.L
21302095}
21312096
21322097func (l * loadbalancers ) updateBackend (service * v1.Service , loadbalancer * scwlb.LB , backend * scwlb.Backend ) (* scwlb.Backend , error ) {
2133- // TODO: implement updateBackend
21342098 b , err := l .api .UpdateBackend (& scwlb.ZonedAPIUpdateBackendRequest {
21352099 Zone : getLoadBalancerZone (service ),
21362100 BackendID : backend .ID ,
0 commit comments