Add static endpoints to a cluster

Last validated:

Static endpoints are available to proxies in ProxyGroups in the Tailscale Kubernetes Operator v1.86 or later, and to Connectors in the Tailscale Kubernetes Operator v1.106 or later.

Standalone ingress and egress proxies do not support static endpoints. A standalone proxy is the dedicated proxy that the operator creates for a single Kubernetes Ingress or Service that does not use a ProxyGroup. The operator ignores spec.staticEndpoints in the ProxyClass of a standalone proxy and does not report an error. To use static endpoints with an Ingress or Service, use high availability ingress or high availability egress, which run on a ProxyGroup.

Tailscale uses various NAT traversal techniques to securely connect to other Tailscale nodes without manual intervention. Most of the time, you do not need to open any firewall ports for Tailscale. However, in some scenarios where NAT traversal is unsuccessful, Tailscale proxies deployed by the operator rely on a relayed connection, resulting in lower throughput and performance compared to direct connections. For example, NAT traversal can fail behind AWS NAT gateways, which are hard NATs.

In these scenarios, ProxyClass provides configuration to use Kubernetes NodePort services as additional endpoints for direct connections to ProxyGroups and Connectors. A tailnet device can use a static endpoint only if it can route traffic to the ExternalIP address of the Node, and firewalls permit inbound UDP traffic to the node port. If the ExternalIP address is a public IP address, tailnet devices on the internet can reach the endpoint. If it is a private IP address, only tailnet devices on networks that can route to it can reach the endpoint.

For each replica of a ProxyGroup or Connector that uses the ProxyClass, the operator does the following:

  • Creates a NodePort Service named <resource-name>-<replica-index>-nodeport in the operator's namespace, which is tailscale by default. The <resource-name> value is the name of the ProxyGroup or Connector, and <replica-index> is the zero-based replica number.
  • Allocates the node port of the Service from the port ranges in the ProxyClass.
  • Configures the replica to advertise up to two static endpoints. Each endpoint is the ExternalIP address of a selected Kubernetes Node and the node port of the replica.

The operator deletes the NodePort Service of a replica when you reduce the number of replicas, delete the ProxyGroup or Connector, or remove spec.staticEndpoints from the ProxyClass.

A ProxyGroup and a Connector with the same name use the same NodePort Service names. If both use static endpoints, give the ProxyGroup and the Connector different names.

Prerequisites

Before you configure static endpoints, make sure that the following conditions are true:

  • At least one Kubernetes Node that matches the ProxyClass selector has an ExternalIP address in status.addresses. The operator advertises only ExternalIP addresses. If no matching Node has one, the ProxyGroup or Connector does not become ready. Clusters without a cloud provider integration, such as many bare-metal clusters, often have no ExternalIP addresses.
  • Tailnet devices can route traffic to those ExternalIP addresses.
  • Firewalls permit inbound UDP traffic to those addresses on the ports in the ProxyClass port ranges. For details, refer to configure firewall rules.

Configure firewall rules

The operator advertises a maximum of two static endpoints for each replica. To choose which Node addresses the operator advertises, configure the spec.staticEndpoints.nodePort.selector field in the ProxyClass resource. The selector only filters the advertised addresses. It does not restrict the NodePort Service to those nodes. If you do not set a selector, the operator can advertise the ExternalIP address of any Node.

To use static endpoints, configure inbound firewall rules that permit UDP traffic to the ExternalIP address of each selected Node on the ports in the port ranges of the ProxyClass. Each replica of every ProxyGroup and Connector that uses the ProxyClass requires one port. If no free port is left, the ProxyGroup or Connector does not become ready. Tailscale recommends configuring enough ports in the ProxyClass and on the firewall to avoid running out of ports as you add replicas.

Configure static endpoints

To configure static endpoints, complete the following steps:

  1. Create a ProxyClass.

    The configuration for static endpoints is part of the ProxyClass custom resource, under spec.staticEndpoints:

    apiVersion: tailscale.com/v1alpha1
    kind: ProxyClass
    metadata:
      name: prod
    spec:
      staticEndpoints:
        nodePort:
          ports:
          - port: 31667
            endPort: 31680
          selector:
            kubernetes.io/os: linux
    

    The preceding example configures the ProxyClass to use Kubernetes NodePort services for the static endpoints. The nodePort configuration has the following fields:

    • ports (Required): A list of port ranges for the NodePort Services. Each range has a port and an optional endPort. The range contains every port from port through endPort, including both values. A range without endPort contains only port.
    • selector (Optional): The labels of the Kubernetes nodes whose ExternalIP addresses the operator advertises as static endpoints.

    Each port range must meet the following conditions:

    • When set, endPort is equal to or greater than port.
    • The range is within the node port range of the cluster, which is 30000-32767 by default.
    • The range does not overlap with the other ranges in the ProxyClass or with the port ranges of another ProxyClass.

    If the operator detects a port range that does not meet these conditions, the ProxyClass does not become ready.

    Make sure the firewall rules permit inbound UDP traffic to these ports so the endpoints are reachable from other tailnet devices.

  2. Reference the ProxyClass from a ProxyGroup or a Connector.

    To configure static endpoints for all replicas of a ProxyGroup, set the spec.proxyClass field of the ProxyGroup:

    apiVersion: tailscale.com/v1alpha1
    kind: ProxyGroup
    metadata:
      name: ingress
    spec:
      type: ingress
      proxyClass: prod
      replicas: 3
    

    To configure static endpoints for all replicas of a Connector, set the spec.proxyClass field of the Connector. The operator does not apply the default ProxyClass to a Connector, so you must set this field:

    apiVersion: tailscale.com/v1alpha1
    kind: Connector
    metadata:
      name: ts-pod-cidrs
    spec:
      proxyClass: prod
      replicas: 2
      hostnamePrefix: ts-pod-cidrs
      subnetRouter:
        advertiseRoutes:
          - "10.40.0.0/14"
    

    After you apply these examples, the operator creates one NodePort Service for each of the three ProxyGroup replicas and the two Connector replicas. To list them, run:

    kubectl get services -n tailscale
    

    The output includes lines similar to the following:

    NAME                      TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
    ingress-0-nodeport        NodePort   172.20.123.3     <none>        22918:31669/UDP   84m
    ingress-1-nodeport        NodePort   172.20.163.230   <none>        22918:31668/UDP   84m
    ingress-2-nodeport        NodePort   172.20.84.83     <none>        22918:31667/UDP   84m
    ts-pod-cidrs-0-nodeport   NodePort   172.20.97.12     <none>        40531:31670/UDP   2m
    ts-pod-cidrs-1-nodeport   NodePort   172.20.14.201    <none>        40531:31671/UDP   2m
    
  3. Check the static endpoints.

    The operator reports the static endpoints of each replica in the staticEndpoints field of its entry in status.devices. To list them for the Connector, run:

    kubectl get connector ts-pod-cidrs -o yaml
    

    The status section of the output is similar to the following:

    status:
      devices:
      - hostname: ts-pod-cidrs-0.tails-scales.ts.net
        staticEndpoints:
        - 203.0.113.1:31670
        - 203.0.113.2:31670
        . . .
      - hostname: ts-pod-cidrs-1.tails-scales.ts.net
        staticEndpoints:
        - 203.0.113.1:31671
        - 203.0.113.2:31671
        . . .
    

    For the ProxyGroup, run the following command. The status.devices field of the ProxyGroup has the same staticEndpoints field for each replica:

    kubectl get proxygroup ingress -o yaml
    
  4. Test the connection.

    From another tailnet device, use tailscale ping to test for a direct connection to a replica.

    For the Connector, ping a replica by its hostname:

    tailscale ping ts-pod-cidrs-0
    

    For the ProxyGroup, create a test Pod and a Service that exposes the Pod through a high-availability cluster ingress:

    apiVersion: v1
    kind: Pod
    metadata:
      name: test
      namespace: default
      labels:
        app: test
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: test
      namespace: default
      annotations:
        tailscale.com/proxy-group: ingress
    spec:
      type: LoadBalancer
      loadBalancerClass: tailscale
      selector:
        app: test
      ports:
        - port: 80
          targetPort: 80
          protocol: TCP
    

    To find the Tailscale Service IP address that exposes the Pod to the tailnet, run:

    kubectl get service -n default
    

    The output is similar to the following:

    NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
    test         LoadBalancer   172.20.50.164    100.64.1.2    80:31109/TCP      2m17s
    

    Test for a direct connection to the Pod in your tailnet by using the Tailscale Service IP address:

    tailscale ping <external-ip>
    

    The following examples show the output for a ProxyGroup replica. The output for a Connector replica has the same format. If a direct connection is successful, the output is similar to the following:

    pong from ingress-0 (100.64.1.1) via 203.0.113.1:31669 in 91ms
    

    If a direct connection is unsuccessful, the output is similar to the following:

    pong from ingress-0 (100.64.1.1) via DERP(nyc) in 90ms
    

    If you observe this output, make sure that the following conditions are true:

    • Inbound firewall rules are configured appropriately for traffic to flow to the correct Kubernetes nodes and port ranges, as configured in the ProxyClass.

    • Nodes that match spec.staticEndpoints.nodePort.selector have ExternalIP addresses in status.addresses.

    • For each replica, the staticEndpoints field in the status.devices of the ProxyGroup or Connector contains addresses that use a valid ExternalIP address and the node port of the NodePort Service of that replica.