cmd/k8s-operator: add tailscale.com/service-name annotation for Ingress#10
Closed
cmd/k8s-operator: add tailscale.com/service-name annotation for Ingress#10
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 namesvc:zergfor 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-nameannotation 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.Priority for hostname derivation:
tailscale.com/service-nameannotation (new, explicit override)tls.hosts[0](existing behavior)<namespace>-<name>-ingressfallback (existing behavior)The annotation is optional — without it, existing behavior is unchanged.
Testing
hostnameForIngress()