@ -61,6 +61,11 @@
// and not `tailscale up` or `tailscale set`.
// and not `tailscale up` or `tailscale set`.
// The config file contents are currently read once on container start.
// The config file contents are currently read once on container start.
// NB: This env var is currently experimental and the logic will likely change!
// NB: This env var is currently experimental and the logic will likely change!
// TS_EXPERIMENTAL_ENABLE_FORWARDING_OPTIMIZATIONS: set to true to
// autoconfigure the default network interface for optimal performance for
// Tailscale subnet router/exit node.
// https://tailscale.com/kb/1320/performance-best-practices#linux-optimizations-for-subnet-routers-and-exit-nodes
// NB: This env var is currently experimental and the logic will likely change!
// - EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS: if set to true
// - EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS: if set to true
// and if this containerboot instance is an L7 ingress proxy (created by
// and if this containerboot instance is an L7 ingress proxy (created by
// the Kubernetes operator), set up rules to allow proxying cluster traffic,
// the Kubernetes operator), set up rules to allow proxying cluster traffic,
@ -152,6 +157,7 @@ func main() {
TailscaledConfigFilePath : tailscaledConfigFilePath ( ) ,
TailscaledConfigFilePath : tailscaledConfigFilePath ( ) ,
AllowProxyingClusterTrafficViaIngress : defaultBool ( "EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS" , false ) ,
AllowProxyingClusterTrafficViaIngress : defaultBool ( "EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS" , false ) ,
PodIP : defaultEnv ( "POD_IP" , "" ) ,
PodIP : defaultEnv ( "POD_IP" , "" ) ,
EnableForwardingOptimizations : defaultBool ( "TS_EXPERIMENTAL_ENABLE_FORWARDING_OPTIMIZATIONS" , false ) ,
}
}
if err := cfg . validate ( ) ; err != nil {
if err := cfg . validate ( ) ; err != nil {
@ -199,6 +205,12 @@ func main() {
}
}
defer killTailscaled ( )
defer killTailscaled ( )
if cfg . EnableForwardingOptimizations {
if err := client . SetUDPGROForwarding ( bootCtx ) ; err != nil {
log . Printf ( "[unexpected] error enabling UDP GRO forwarding: %v" , err )
}
}
w , err := client . WatchIPNBus ( bootCtx , ipn . NotifyInitialNetMap | ipn . NotifyInitialPrefs | ipn . NotifyInitialState )
w , err := client . WatchIPNBus ( bootCtx , ipn . NotifyInitialNetMap | ipn . NotifyInitialPrefs | ipn . NotifyInitialState )
if err != nil {
if err != nil {
log . Fatalf ( "failed to watch tailscaled for updates: %v" , err )
log . Fatalf ( "failed to watch tailscaled for updates: %v" , err )
@ -1080,22 +1092,23 @@ type settings struct {
// TailnetTargetFQDN is an MagicDNS name to which all incoming
// TailnetTargetFQDN is an MagicDNS name to which all incoming
// non-Tailscale traffic should be proxied. This must be a full Tailnet
// non-Tailscale traffic should be proxied. This must be a full Tailnet
// node FQDN.
// node FQDN.
TailnetTargetFQDN string
TailnetTargetFQDN string
ServeConfigPath string
ServeConfigPath string
DaemonExtraArgs string
DaemonExtraArgs string
ExtraArgs string
ExtraArgs string
InKubernetes bool
InKubernetes bool
UserspaceMode bool
UserspaceMode bool
StateDir string
StateDir string
AcceptDNS * bool
AcceptDNS * bool
KubeSecret string
KubeSecret string
SOCKSProxyAddr string
SOCKSProxyAddr string
HTTPProxyAddr string
HTTPProxyAddr string
Socket string
Socket string
AuthOnce bool
AuthOnce bool
Root string
Root string
KubernetesCanPatch bool
KubernetesCanPatch bool
TailscaledConfigFilePath string
TailscaledConfigFilePath string
EnableForwardingOptimizations bool
// If set to true and, if this containerboot instance is a Kubernetes
// If set to true and, if this containerboot instance is a Kubernetes
// ingress proxy, set up rules to forward incoming cluster traffic to be
// ingress proxy, set up rules to forward incoming cluster traffic to be
// forwarded to the ingress target in cluster.
// forwarded to the ingress target in cluster.
@ -1149,6 +1162,9 @@ func (s *settings) validate() error {
if s . AllowProxyingClusterTrafficViaIngress && s . PodIP == "" {
if s . AllowProxyingClusterTrafficViaIngress && s . PodIP == "" {
return errors . New ( "EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS is set but POD_IP is not set" )
return errors . New ( "EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS is set but POD_IP is not set" )
}
}
if s . EnableForwardingOptimizations && s . UserspaceMode {
return errors . New ( "TS_EXPERIMENTAL_ENABLE_FORWARDING_OPTIMIZATIONS is not supported in userspace mode" )
}
return nil
return nil
}
}