Integrating Tailscale Vpn with K3s: a Production-ready Workflow
Adding TailScale to an existing k3s cluster simplifies secure networking but requires careful node configuration and firewall.
Adding TailScale to an existing k3s cluster simplifies secure networking but requires careful node configuration and firewall adjustments.
Workflow: TailScale Integration with k3s
-
Install k3s
Use the official install script with any required flags (e.g.,--serverfor the master node):curl -sfL https://get.k3s.io | sh - -
Install TailScale Operator
Deploy via krew (Kubernetes CLI tool for plugins):krew install tailscaleOr manually apply the TailScale manifest:
kubectl apply -f https://raw.githubusercontent.com/tailscale/tailscale-k8s/main/deploy/tailscale.yaml -
Authenticate and Join Nodes
On each node (including the k3s server):sudo tailscale up --auth-key=<AUTH_KEY>Replace
<AUTH_KEY>with your TailScale authentication key from the web UI. -
Verify Cluster Connectivity
Check node IPs in the TailScale subnet:tailscale statusEnsure all nodes show as “ready” in
kubectl get nodes.
Policy Example: Restrict Access to Subnet
Use TailScale’s subnet routing to limit access to specific services:
# Allow only 10.0.0.0/24 subnet to access the cluster
tailscale set --subnet=10.0.0.0/24
For granular control, apply network policies in Kubernetes alongside TailScale’s ACLs.
Tooling
- k3s: Lightweight Kubernetes distribution (ideal for edge or small clusters).
- TailScale CLI: For node authentication and subnet configuration.
- krew: For installing TailScale operator and other Kubernetes tools.
- Monitoring: Use Prometheus/Grafana to track network latency and packet loss post-integration.
Tradeoffs
- Pros:
- Simplifies cross-cluster and hybrid-cloud connectivity.
- Automatic encryption and NAT traversal reduce firewall headaches.
- Cons:
- Adds dependency on TailScale’s DERP relays (potential latency).
- Not ideal for high-throughput workloads (e.g., video processing).
- Costs scale with node count for paid tiers.
Troubleshooting
Common Issues:
- Nodes Not Joining:
- Check firewall rules blocking UDP port 4160.
- Verify
tailscaleservice is running:systemctl status tailscale.
- DNS Resolution Failures:
- Ensure
coresdnsis configured to use TailScale’s DNS:tailscale set --dns=auto
- Ensure
- Intermittent Connectivity:
- Inspect logs for DERP relay timeouts:
journalctl -u tailscale -n 100 --since "5 minutes ago"
- Inspect logs for DERP relay timeouts:
Validation:
- Ping between nodes using their TailScale IPs:
ping <TAILSCALE_IP> - Test service reachability via Kubernetes services.
Prevention
- Firewall Rules: Allow UDP 4160 and ICMP for DERP relay reliability.
- Node Labels: Tag nodes with
tailscale.io/subnetfor policy enforcement. - Backup Auth Keys: Rotate keys periodically and avoid reusing them across environments.
TailScale streamlines secure networking for k3s but isn’t a silver bullet. Use it where simplicity and encryption outweigh strict performance or control requirements.
Source thread: Who has added TailScale (NetBird?) VPN to their setup? Is it easier to add it after, setting up k3s?

Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email