Skip to content

Commit c966f6f

Browse files
committed
allow to customize domain validation
This allows to customize the FQDN validation of tailscale services.
1 parent 9bb7166 commit c966f6f

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

cmd/k8s-operator/egress-services.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,6 @@ func (esr *egressSvcsReconciler) validateClusterResources(ctx context.Context, s
524524
tsoperator.RemoveServiceCondition(svc, tsapi.EgressSvcConfigured)
525525
return false, err
526526
}
527-
if !tsoperator.ProxyGroupIsReady(pg) {
528-
l.Infof("ProxyGroup %s is not ready, waiting...", proxyGroupName)
529-
tsoperator.SetServiceCondition(svc, tsapi.EgressSvcValid, metav1.ConditionUnknown, reasonProxyGroupNotReady, reasonProxyGroupNotReady, esr.clock, l)
530-
tsoperator.RemoveServiceCondition(svc, tsapi.EgressSvcConfigured)
531-
return false, nil
532-
}
533-
534527
if violations := validateEgressService(svc, pg, esr.validationOpts); len(violations) > 0 {
535528
msg := fmt.Sprintf("invalid egress Service: %s", strings.Join(violations, ", "))
536529
esr.recorder.Event(svc, corev1.EventTypeWarning, "INVALIDSERVICE", msg)
@@ -539,6 +532,11 @@ func (esr *egressSvcsReconciler) validateClusterResources(ctx context.Context, s
539532
tsoperator.RemoveServiceCondition(svc, tsapi.EgressSvcConfigured)
540533
return false, nil
541534
}
535+
if !tsoperator.ProxyGroupIsReady(pg) {
536+
tsoperator.SetServiceCondition(svc, tsapi.EgressSvcValid, metav1.ConditionUnknown, reasonProxyGroupNotReady, reasonProxyGroupNotReady, esr.clock, l)
537+
tsoperator.RemoveServiceCondition(svc, tsapi.EgressSvcConfigured)
538+
}
539+
542540
l.Debugf("egress service is valid")
543541
tsoperator.SetServiceCondition(svc, tsapi.EgressSvcValid, metav1.ConditionTrue, reasonEgressSvcValid, reasonEgressSvcValid, esr.clock, l)
544542
return true, nil

cmd/k8s-operator/operator.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,17 @@ func runReconcilers(opts reconcilerOpts) {
404404
Watches(&tsapi.ProxyGroup{}, ingressProxyGroupFilter).
405405
Watches(&discoveryv1.EndpointSlice{}, ingressSvcFromEpsFilter).
406406
Complete(&HAServiceReconciler{
407-
recorder: eventRecorder,
408-
tsClient: opts.tsClient,
409-
tsnetServer: opts.tsServer,
410-
defaultTags: strings.Split(opts.proxyTags, ","),
411-
Client: mgr.GetClient(),
412-
logger: opts.log.Named("service-pg-reconciler"),
413-
lc: lc,
414-
clock: tstime.DefaultClock{},
415-
operatorID: id,
416-
tsNamespace: opts.tailscaleNamespace,
407+
recorder: eventRecorder,
408+
tsClient: opts.tsClient,
409+
tsnetServer: opts.tsServer,
410+
defaultTags: strings.Split(opts.proxyTags, ","),
411+
Client: mgr.GetClient(),
412+
logger: opts.log.Named("service-pg-reconciler"),
413+
lc: lc,
414+
clock: tstime.DefaultClock{},
415+
operatorID: id,
416+
tsNamespace: opts.tailscaleNamespace,
417+
validationOpts: opts.validationOpts,
417418
})
418419
if err != nil {
419420
startlog.Fatalf("could not create service-pg-reconciler: %v", err)

cmd/k8s-operator/operator_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,6 @@ func TestTailscaledConfigfileHash(t *testing.T) {
13781378
},
13791379
})
13801380

1381-
expectReconciled(t, sr, "default", "test")
13821381
expectReconciled(t, sr, "default", "test")
13831382

13841383
fullName, shortName := findGenName(t, fc, "default", "test", "svc")

cmd/k8s-operator/sts.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ type tailscaleSTSConfig struct {
136136

137137
proxyType string
138138

139-
ControlURL string
140-
141139
// Connector specifies a configuration of a Connector instance if that's
142140
// what this StatefulSet should be created for.
143141
Connector *connector

cmd/k8s-operator/svc-for-pg.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ type HAServiceReconciler struct {
6666
defaultTags []string
6767
operatorID string // stableID of the operator's Tailscale device
6868

69+
validationOpts validationOpts
70+
6971
clock tstime.Clock
7072

7173
mu sync.Mutex // protects following
@@ -170,7 +172,7 @@ func (r *HAServiceReconciler) maybeProvision(ctx context.Context, hostname strin
170172
}
171173

172174
// Validate Service configuration
173-
if violations := validateService(svc); len(violations) > 0 {
175+
if violations := validateService(svc, r.validationOpts); len(violations) > 0 {
174176
msg := fmt.Sprintf("unable to provision proxy resources: invalid Service: %s", strings.Join(violations, ", "))
175177
r.recorder.Event(svc, corev1.EventTypeWarning, "INVALIDSERVICE", msg)
176178
r.logger.Error(msg)

0 commit comments

Comments
 (0)