@ -8,6 +8,7 @@ package main
import (
import (
"context"
"context"
"fmt"
"fmt"
"net/netip"
"strings"
"strings"
"go.uber.org/zap"
"go.uber.org/zap"
@ -121,6 +122,11 @@ func (a *ServiceReconciler) maybeProvision(ctx context.Context, logger *zap.Suga
tags = strings . Split ( tstr , "," )
tags = strings . Split ( tstr , "," )
}
}
clusterIPAddr , err := netip . ParseAddr ( svc . Spec . ClusterIP )
if err != nil {
return fmt . Errorf ( "failed to parse cluster IP: %w" , err )
}
sts := & tailscaleSTSConfig {
sts := & tailscaleSTSConfig {
ParentResourceName : svc . Name ,
ParentResourceName : svc . Name ,
ParentResourceUID : string ( svc . UID ) ,
ParentResourceUID : string ( svc . UID ) ,
@ -158,8 +164,14 @@ func (a *ServiceReconciler) maybeProvision(ctx context.Context, logger *zap.Suga
{ Hostname : tsHost } ,
{ Hostname : tsHost } ,
}
}
for _ , ip := range tsIPs {
for _ , ip := range tsIPs {
addr , err := netip . ParseAddr ( ip )
if err != nil {
continue
}
if addr . Is4 ( ) == clusterIPAddr . Is4 ( ) { // only add addresses of the same family
ingress = append ( ingress , corev1 . LoadBalancerIngress { IP : ip } )
ingress = append ( ingress , corev1 . LoadBalancerIngress { IP : ip } )
}
}
}
svc . Status . LoadBalancer . Ingress = ingress
svc . Status . LoadBalancer . Ingress = ingress
if err := a . Status ( ) . Update ( ctx , svc ) ; err != nil {
if err := a . Status ( ) . Update ( ctx , svc ) ; err != nil {
return fmt . Errorf ( "failed to update service status: %w" , err )
return fmt . Errorf ( "failed to update service status: %w" , err )