cmd/k8s-operator: fix egress service name (#9494)

Updates https://github.com/tailscale/tailscale/issues/502

Signed-off-by: Irbe Krumina <irbe@tailscale.com>
This commit is contained in:
Irbe Krumina 2023-09-20 20:58:28 +01:00 committed by GitHub
parent 5f4d76c18c
commit c5b2a365de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -218,7 +218,7 @@ func TestTailnetTargetIPAnnotation(t *testing.T) {
}, },
}, },
Spec: corev1.ServiceSpec{ Spec: corev1.ServiceSpec{
ExternalName: fmt.Sprintf("%s.operator-ns.svc", shortName), ExternalName: fmt.Sprintf("%s.operator-ns.svc.cluster.local", shortName),
Type: corev1.ServiceTypeExternalName, Type: corev1.ServiceTypeExternalName,
Selector: nil, Selector: nil,
}, },

View File

@ -184,7 +184,10 @@ func (a *ServiceReconciler) maybeProvision(ctx context.Context, logger *zap.Suga
} }
if sts.TailnetTargetIP != "" { if sts.TailnetTargetIP != "" {
headlessSvcName := hsvc.Name + "." + hsvc.Namespace + ".svc" // TODO (irbekrm): cluster.local is the default DNS name, but
// can be changed by users. Make this configurable or figure out
// how to discover the DNS name from within operator
headlessSvcName := hsvc.Name + "." + hsvc.Namespace + ".svc.cluster.local"
if svc.Spec.ExternalName != headlessSvcName || svc.Spec.Type != corev1.ServiceTypeExternalName { if svc.Spec.ExternalName != headlessSvcName || svc.Spec.Type != corev1.ServiceTypeExternalName {
svc.Spec.ExternalName = headlessSvcName svc.Spec.ExternalName = headlessSvcName
svc.Spec.Selector = nil svc.Spec.Selector = nil