A Series of Unfortunate ACLs: How to Overcomplicate a Localhost with Tailscale


This is a journal, written for future me. It is deliberately chronological and includes the dead ends, because those are the parts I actually learned from. Nothing here is a tutorial; it is a record of what happened and what I would do differently.

Jump to a section:

Background

I have a single-node microk8s cluster on a small cloud VM, running a Tailscale operator with Tailscale client on the VM itself. On it lives Mage.ai, a data workflows workspace I poke at from my laptop and phone, alongside my Devtron dashboard and an n8n instance. I do not want to open Mage to the internet, and I do not want to remember a public IP or babysit a firewall. Tailscale’s Kubernetes operator looked like the clean answer. My devices join my tailnet, privately hosted Mage shows up. Everything else stays closed.

The plan was deceptively simple. In practice, I spent most of my time not on the “how” but on three layers of silent failure rabbit hole. One in the host, one in the tailnet, and one in Kubernetes. Each one deserves at least a slap on my own forehead.

Devtron dashboard
My Devtron dashboard

Blocker 1: CoreDNS down

Before I even got to Tailscale, the cluster was sick. CoreDNS would not come ready, and calico-kube-controllers was crash-looping. This cluster is ooold, like a-couple-of-years old, and had been upgraded in place a few times.

The root cause was an iptables mismatch. The node was configured to write rules to the legacy iptables backend, but the kernel was actually enforcing nftables. The Kubernetes service rules were going somewhere that the data plane never looked, so DNS (which relies on KUBE-SERVICES) broke.

The fix was to point the alternatives back at legacy and reboot (people might be side-eyeing me already for this):

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo update-alternatives --set arptables /usr/sbin/arptables-legacy
sudo update-alternatives --set ebtables /usr/sbin/ebtables-legacy
sudo reboot

I promise myself (not, maybe), I’ll update later instead of going back to legacy. After the reboot, CoreDNS went 1/1 and calico recovered. Pats myself on the shoulder.

Lesson #1: on a OLD long-lived node, check that iptables and nftables agree before blaming the application.

Installing the Tailscale operator

microk8s does not use ~/.kube/config the way a normal kubeadm cluster does. That meant my first attempt, running standalone helm, failed before doing anything useful. 1 The operator has to be installed with microk8s’s own Helm wrapper:

microk8s helm3 repo add tailscale https://pkgs.tailscale.com/helmcharts
microk8s helm3 repo update
microk8s helm3 upgrade --install tailscale-operator tailscale/tailscale-operator \
  -n tailscale --create-namespace \
  --set-string oauth.clientId="<idhihi>" \
  --set-string oauth.clientSecret="<secrethehe>" \
  --wait

Two pieces of setup mattered more than the chart itself. First, an OAuth client with write scopes for devices, auth keys, and services so the operator can spin up devices. Second, tagOwners in the ACL, because the operator tags every proxy it creates, and someone has to be allowed to own that tag:

{
  "tagOwners": {
    "tag:k8s-operator": [],
    "tag:k8s": ["tag:k8s-operator"]
  }
}

Exposing the service

The operator exposes a workload in two very different ways, and I did not appreciate the difference at first:2

  • A Service with tailscale.com/expose: "true" is a layer 3 proxy that forwards the Service’s own port, with TLS termination, at <namespace>-<service-name>.<tailnet>.ts.net.
  • An Ingress with ingressClassName: tailscale is a layer 7 proxy that serves HTTPS on 443 and routes by hostname, at the name in tls.hosts. (This is what I actually needed. Nobody wants to type :6789 into their browser address bar like an animal.)
# Service (L3): exposes port 6789
apiVersion: v1
kind: Service
metadata:
  name: mage-service
  annotations:
    tailscale.com/expose: "true"
spec:
  selector: { app: mage }
  ports:
    - port: 6789
      targetPort: 6789
# Ingress (L7): HTTPS on 443, hostname "mage"
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mage-service
spec:
  ingressClassName: tailscale
  rules:
    - http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: mage-service
                port:
                  number: 6789
  tls:
    - hosts:
        - mage

Because I created both, the operator made two proxy devices on my tailnet: mage.<tailnet>.ts.net and default-mage-service.<tailnet>.ts.net. That surprise came back to haunt me later, when I could reach one but not the other.

The NXDOMAIN mystery

With the proxies showing up in the Tailscale admin console, I expected the names to resolve. They did not. nslookup came back with NXDOMAIN, and tailscale status on the VM did not even list the k8s proxy devices.

The missing piece was the ACL (so silly, I thought this is somewhat title worthy). My policy had rules for my admin and VM tags, but nothing that mentioned tag:k8s. Tailscale only puts devices in your map if the ACL grants some relationship, and devices that are not in your map get no Tailscale’s ✨MagicDNS🧙🏻‍♀️ name. So the names did not resolve because the devices were effectively invisible to me.

This was the first of several reminders that in Tailscale, DNS resolution is a side effect of the ACL, not a separate DNS service. In a traditional network, a firewall blocks your packets but DNS still happily hands out the IP. In Tailscale, if you aren’t allowed to talk to a machine, you aren’t even allowed to know its name (Never heard of it. NXDOMAINed). If a name does not resolve, the answer might be in the policy, not in the resolver.

Writing ACL tests

The Tailscale policy file has a tests section, which is easy to overlook. It lets you assert that a given source can or cannot reach a given tag:port, and it runs every time you save the policy. The relevant part is a small assertion like:

{ "src": "me@github", "deny": ["tag:k8s:443"] }

The tests immediately paid for themselves. While iterating I had introduced a grants block alongside acls with a bare destination:

{
  "grants": [
    { "src": ["group:me"], "dst": ["tag:k8s"], "ip": ["*"] }
  ]
}

A destination without a port means every port. And acls and grants are additive, a connection passes if either allows it. So my carefully port-limited acls rule was being overridden by the broad grant, and the tests caught it with want: Drop, got: Accept. I removed the grant and kept the explicit ports.

Resolves but times out

Once the ACL was right, the names resolved. Whew Progress! But the connection still failed. This is where the error got interesting (not):

  • curl ...:6789 returned “Connection refused”.
  • curl ...:443 returned “Connection timed out”.

Those are very different signals. Refused means my packet reached the node and it actively sent a reset, so the ACL was fine. The problem was that nothing was listening on that port. Timed out means my packets were being silently dropped, which is what a Tailscale ACL deny looks like.

Learning to read “refused vs timeout” told me exactly which layer to look at, and it is the single most useful diagnostic instinct I picked up in this whole exercise.

Empty endpoints

The “refused” pointed me into the cluster. The proxy was reachable, but there was nothing behind it. The culprit (or as I say it, /chŭl′prĭt/):

microk8s kubectl get endpoints -n default mage-service
# NAME           ENDPOINTS
# mage-service   <none>

really?

An empty endpoint set means the Service’s selector matches no pods. It turned out the Mage pod was a bare pod I had created through Devtron, and it had no labels at all. So selector: app: mage matched nothing.

The immediate fix was a one-liner:

microk8s kubectl label pod -n default my-mage-server-pod app=mage

And there they go, the endpoints populated and the proxy had somewhere to forward to. Two lessons here: empty endpoints is always a selector/label story (or a not-running pod), and a label slapped on a bare pod is fragile. It disappears if the pod is recreated. The durable fix is to put the label where Devtron actually owns it (my bad).

The custom-domain detour

At some point I decided I wanted mage.some-domain.some-other-tld instead of the .ts.net name, and waded ankle-deep into a Cloudflare puddle, a cul-de-sac.

Some takeaways:

  • Tailscale’s 100.x.y.z addresses are private (which I conveniently forgot), only routable on the tailnet. Cloudflare cannot proxy them, so any DNS record has to be DNS-only (grey cloud), and even then it only works for devices on the tailnet.
  • A CNAME to the .ts.net name does not fix TLS. The operator’s proxy serves a certificate for the .ts.net name, so a browser hitting my custom domain sees a name mismatch.
  • Tailscale’s built-in HTTPS only issues certificates for *.ts.net. A valid cert for my own domain would require terminating TLS myself. Tailscale already gives me a free VIP pass to my app, so using my own domain means I’d have to hire a notary, a bouncer, and a background-check agency to verify my own identity before walking into my own room.

I dropped the custom domain and kept the .ts.net name. For a service that is never public anyway, the name was not worth the infrastructure. I’ll save it for another usecase.

Lessons learned

  • DNS resolution is an ACL side effect. NXDOMAIN in this case means “device not in my netmap”, not a resolver problem.
  • acls and grants are additive. A broad destination without a port silently opens everything; write tests so you catch it.
  • Refused vs timeout is the fastest way to spot a Tailscale failure to the app layer versus the ACL.
  • Empty endpoints is a selector/label mismatch until proven otherwise.
  • microk8s needs microk8s helm3 and microk8s kubectl; the standalone tools will mislead you me.
  • Two proxies are normal if you create both a Service-expose and an Ingress; they serve different ports.

Next: Cloudflare Tunnel

The private stuff is done. The next experiment is the opposite direction, expose a public REST API without giving the VM a public IP, via Cloudflare Tunnel with an ingress controller that routes per-services. That is a whole other set of dead ends to document, so it gets its own post. I’m going to have a rest. The continuation might arrive on a random Tuesday, maybe.

Footnotes

Footnotes

  1. #TODO: me. Since I’ve actually set alias to microk8s kubectl and helm but still got this quirk, I’ll get back to this later, I’m no DevOps adult. Might have something to do with scripts run, environment variables, or clashing aliases. ↩

  2. OSI Layer refresher. ↩