Skip to content

cmd/k8s-operator: add tailscale.com/service-name annotation for Ingress#10

Closed
vlinkz wants to merge 10 commits intomainfrom
vlinkz/service-name-annotation
Closed

cmd/k8s-operator: add tailscale.com/service-name annotation for Ingress#10
vlinkz wants to merge 10 commits intomainfrom
vlinkz/service-name-annotation

Conversation

@vlinkz
Copy link
Copy Markdown
Member

@vlinkz vlinkz commented Apr 6, 2026

Why

When multiple environments use custom TLS domains with the same first DNS label (e.g., zerg.staging.zergrush.dev, zerg.testing.zergrush.dev), hostnameForIngress() derives the same service name svc:zerg for all of them. This causes proxy groups from different environments to advertise the same Tailscale Service, stealing traffic from each other.

What changed

Added support for a tailscale.com/service-name annotation on Ingress resources. When present, this annotation value is used as the Tailscale Service name instead of deriving it from the first DNS label of the TLS host.

annotations:
  tailscale.com/proxy-group: zerg-west1-staging-ingress
  tailscale.com/service-name: zerg-west1-staging
spec:
  tls:
    - hosts:
        - zerg.staging.zergrush.dev
      secretName: zergrush-dev-wildcard-tls

Priority for hostname derivation:

  1. tailscale.com/service-name annotation (new, explicit override)
  2. First DNS label of tls.hosts[0] (existing behavior)
  3. <namespace>-<name>-ingress fallback (existing behavior)

The annotation is optional — without it, existing behavior is unchanged.

Testing

  • Verify annotation is read by hostnameForIngress()
  • Verify service name is derived from annotation when set
  • Verify fallback to TLS host when annotation is not set

matthalp and others added 10 commits March 25, 2026 12:06
Add support for the tailscale.com/accept-app-caps annotation on Ingress
resources. This populates the AcceptAppCaps field on HTTPHandler entries
in the serve config, which causes the serve proxy to forward matching
peer capabilities in the Tailscale-App-Capabilities header to backends.

The annotation accepts a comma-separated list of capability names
(e.g. "example.com/cap/monitoring,example.com/cap/admin"). Each
capability is validated against the standard app capability regex.
Invalid capabilities are skipped with a warning event, consistent
with the operator's soft-validation pattern.

Both the standard Ingress reconciler and the HA (ProxyGroup) Ingress
reconciler benefit from this change since they share the same
handlersForIngress() function.

Updates #tailscale/corp#28049

Signed-off-by: matthalp <mhalpern@column.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When multiple environments share the same custom domain structure
(e.g., zerg.staging.zergrush.dev, zerg.testing.zergrush.dev), the
hostnameForIngress function derives the same service name (svc:zerg)
for all of them because it only reads the first DNS label of the TLS
host.

Add a tailscale.com/service-name annotation that takes precedence
over the TLS host for service name derivation. This lets operators
explicitly control the Tailscale Service name per Ingress:

  annotations:
    tailscale.com/proxy-group: zerg-west1-staging-ingress
    tailscale.com/service-name: zerg-west1-staging

The annotation is optional — without it, existing behavior is
unchanged (service name derived from first DNS label of TLS host).
@vlinkz vlinkz marked this pull request as ready for review April 6, 2026 23:14
@vlinkz vlinkz closed this Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants