commit a33c855c970ced3b154ba9a068b1bc88aa406ba1 Author: SmokyZone Date: Tue Oct 6 18:49:53 2026 +0200 Add Tailscale subnet router chart Userspace-mode subnet router advertising only the node (192.168.2.218/32). Auth key comes from OpenBao via ESO; node state is kept in a Kubernetes Secret so the identity survives restarts. Co-Authored-By: Claude Opus 5.5 diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..052652d --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: tailscale +description: Tailscale subnet router that makes the cluster node reachable from the tailnet +type: application +version: 0.1.0 +appVersion: "1.102.5" +home: https://git.smokyzone.de/SmokyZone/tailscale-gitops +sources: + - https://git.smokyzone.de/SmokyZone/tailscale-gitops +keywords: + - tailscale + - vpn +maintainers: + - name: SmokyZone diff --git a/README.md b/README.md new file mode 100644 index 0000000..dedf2a7 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# tailscale-gitops + +Tailscale **subnet router** for the single-node cluster (`loki`). It joins your tailnet +as `loki-k8s` and advertises only `192.168.2.218/32`, so devices in the tailnet reach +the node - and with it all ingress hostnames (`https://.smokyzone.de:30444`) - from +anywhere, without exposing anything to the internet. + +Runs in userspace mode (no `privileged`, no `NET_ADMIN`, no `/dev/net/tun`). The node +identity is stored in the Kubernetes Secret `tailscale-state`, so it survives restarts. + +## Setup + +1. **Auth key**: Tailscale admin console -> *Settings -> Keys -> Generate auth key*. + Reusable: off, Ephemeral: off, Pre-approved: on (if offered). +2. **Store it in OpenBao** at `secret/tailscale`, key `authkey` (UI: *secret/ -> Create + secret*, path `tailscale`). ESO turns it into the Secret `tailscale-auth`. +3. Deploy via ArgoCD (`apps-in-apps` entry `tailscale`). +4. **Admin console -> Machines -> loki-k8s**: + - *Edit route settings* -> approve `192.168.2.218/32`. + - *Disable key expiry* (otherwise the node logs out after 180 days). +5. Install the Tailscale app on phone/laptop, sign in with the same account. Open + `https://jellyfin.smokyzone.de:30444` while on mobile data. + +The auth key is only used for the first login. Afterwards it can expire or be revoked. +To re-register from scratch: delete the Secret `tailscale-state` and provide a new key. + +## How it fits together + +- DNS: the `*.smokyzone.de` records are public and resolve to `192.168.2.218` everywhere + (when the client uses a resolver that doesn't filter private IPs, e.g. 1.1.1.1). +- Routing: the Tailscale client sends traffic for `192.168.2.218` through the tunnel to + this pod, which forwards it to the node's NodePorts. +- Android: Android allows only one VPN at a time. diff --git a/templates/deployment.yaml b/templates/deployment.yaml new file mode 100644 index 0000000..db3b1e1 --- /dev/null +++ b/templates/deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tailscale + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: tailscale +spec: + replicas: 1 + # One node identity: never run two pods with the same state at once. + strategy: + type: Recreate + selector: + matchLabels: + app.kubernetes.io/name: tailscale + template: + metadata: + labels: + app.kubernetes.io/name: tailscale + spec: + serviceAccountName: tailscale + securityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + seccompProfile: + type: RuntimeDefault + containers: + - name: tailscale + image: {{ .Values.image }} + imagePullPolicy: IfNotPresent + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: ["ALL"] + env: + # Userspace networking: no /dev/net/tun, no NET_ADMIN. Subnet routing still + # works - forwarded connections originate from the pod and reach the node IP. + - name: TS_USERSPACE + value: "true" + - name: TS_KUBE_SECRET + value: {{ .Values.stateSecret | quote }} + - name: TS_HOSTNAME + value: {{ .Values.hostname | quote }} + - name: TS_ROUTES + value: {{ join "," .Values.routes | quote }} + - name: TS_ACCEPT_DNS + value: "false" + {{- with .Values.extraArgs }} + - name: TS_EXTRA_ARGS + value: {{ . | quote }} + {{- end }} + - name: TS_AUTHKEY + valueFrom: + secretKeyRef: + name: tailscale-auth + key: TS_AUTHKEY + # containerboot writes its socket/state helpers here. + - name: TS_SOCKET + value: /tmp/tailscaled.sock + - name: HOME + value: /tmp + volumeMounts: + - name: tmp + mountPath: /tmp + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: tmp + emptyDir: {} diff --git a/templates/externalsecret.yaml b/templates/externalsecret.yaml new file mode 100644 index 0000000..7f85183 --- /dev/null +++ b/templates/externalsecret.yaml @@ -0,0 +1,20 @@ +apiVersion: external-secrets.io/v1 +kind: ExternalSecret +metadata: + name: tailscale-auth + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: tailscale +spec: + refreshInterval: {{ .Values.authKey.refreshInterval }} + secretStoreRef: + kind: {{ .Values.authKey.storeKind }} + name: {{ .Values.authKey.storeName }} + target: + name: tailscale-auth + creationPolicy: Owner + data: + - secretKey: TS_AUTHKEY + remoteRef: + key: {{ .Values.authKey.remoteKey }} + property: {{ .Values.authKey.property }} diff --git a/templates/rbac.yaml b/templates/rbac.yaml new file mode 100644 index 0000000..d738337 --- /dev/null +++ b/templates/rbac.yaml @@ -0,0 +1,43 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: tailscale + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: tailscale +--- +# tailscaled stores its state in a Secret (TS_KUBE_SECRET) instead of a volume. +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: tailscale + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: tailscale +rules: + - apiGroups: [""] + resources: ["secrets"] + verbs: ["create"] + - apiGroups: [""] + resources: ["secrets"] + resourceNames: [{{ .Values.stateSecret | quote }}] + verbs: ["get", "update", "patch"] + - apiGroups: [""] + resources: ["events"] + verbs: ["get", "create", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: tailscale + namespace: {{ .Values.namespace }} + labels: + app.kubernetes.io/name: tailscale +subjects: + - kind: ServiceAccount + name: tailscale + namespace: {{ .Values.namespace }} +roleRef: + kind: Role + name: tailscale + apiGroup: rbac.authorization.k8s.io diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..9d8802d --- /dev/null +++ b/values.yaml @@ -0,0 +1,37 @@ +## Values for the tailscale chart (subnet router). + +namespace: tailscale + +image: ghcr.io/tailscale/tailscale:v1.102.5 + +# Device name in the Tailscale admin console. +hostname: loki-k8s + +# Routes advertised to the tailnet. Only the node itself (ingress NodePorts such as +# :30444, Valheim NodePorts, ...) - not the whole home LAN. Must be approved once in +# the admin console (Machines -> loki-k8s -> Edit route settings). +routes: + - 192.168.2.218/32 + +# Extra `tailscale up` flags, e.g. "--advertise-tags=tag:k8s" (tag must exist in the ACL). +extraArgs: "" + +# Auth key from OpenBao (via the openbao ClusterSecretStore). Only needed for the very +# first login: afterwards the node identity lives in the Kubernetes Secret `stateSecret`. +authKey: + storeKind: ClusterSecretStore + storeName: openbao + remoteKey: tailscale + property: authkey + refreshInterval: 1h + +# Kubernetes Secret where tailscaled keeps its state (node key, login). Created by the pod. +stateSecret: tailscale-state + +resources: + requests: + cpu: 20m + memory: 64Mi + limits: + cpu: 500m + memory: 256Mi