mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
cmd/k8s-operator: add matching family addresses to status
This was added in 3451b89e5f
, but
resulted in the v6 Tailscale address being added to status when
when the forwarding only happened on the v4 address.
Updates #502
Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -108,9 +108,6 @@ func TestLoadBalancerClass(t *testing.T) {
|
|||||||
{
|
{
|
||||||
IP: "100.99.98.97",
|
IP: "100.99.98.97",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
IP: "2c0a:8083:94d4:2012:3165:34a5:3616:5fdf",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -375,9 +372,6 @@ func TestAnnotationIntoLB(t *testing.T) {
|
|||||||
{
|
{
|
||||||
IP: "100.99.98.97",
|
IP: "100.99.98.97",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
IP: "2c0a:8083:94d4:2012:3165:34a5:3616:5fdf",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -467,9 +461,6 @@ func TestLBIntoAnnotation(t *testing.T) {
|
|||||||
{
|
{
|
||||||
IP: "100.99.98.97",
|
IP: "100.99.98.97",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
IP: "2c0a:8083:94d4:2012:3165:34a5:3616:5fdf",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -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,7 +164,13 @@ func (a *ServiceReconciler) maybeProvision(ctx context.Context, logger *zap.Suga
|
|||||||
{Hostname: tsHost},
|
{Hostname: tsHost},
|
||||||
}
|
}
|
||||||
for _, ip := range tsIPs {
|
for _, ip := range tsIPs {
|
||||||
ingress = append(ingress, corev1.LoadBalancerIngress{IP: ip})
|
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})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
Reference in New Issue
Block a user