Running an isolated Gitea Actions runner on K3s
A CI runner pod with no API token, no privileges, and tight egress.
What it’s for
Section titled “What it’s for”CI that can reach Git and the internet but nothing else on the network.
- Get a registration token with the CLI (the admin API returned 404 on Gitea 1.27.0):
kubectl exec -n gitea deploy/gitea -- gitea actions generate-runner-tokenStore it in your secrets manager. Never put it on a command line.
- Runner pod settings:
serviceAccountName: gitea-runner-saautomountServiceAccountToken: falsesecurityContext: privileged: false allowPrivilegeEscalation: falseUse the runner’s host mode, with no Docker-in-Docker.
-
NetworkPolicy: deny all ingress. Allow egress to:
- kube-dns on 53
- Gitea’s address on 80 and 2222 only
0.0.0.0/0on 80 and 443, withexceptfor 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and 100.64.0.0/10
-
Put workflows in
.gitea/workflows/.
Check it worked
Section titled “Check it worked”From inside the runner pod:
/var/run/secrets/kubernetes.io/serviceaccountdoesn’t exist.- Gitea and github.com answer.
- The cluster API, other hosts and the Tailscale range time out.
Then push a workflow and watch it run.
Traps seen
Section titled “Traps seen”- Gitea ignores
.forgejo/workflows/. - If another service shares Gitea’s address, allow Gitea’s ports only.
- Gitea’s run API returns
head_shaandstarted_at. Forgejo returnscommit_shaandcreated.
Where this came from
Section titled “Where this came from”- A runner token leaked through a command line (2026-10-19)
- Running CI in a runner pod that can’t reach the cluster API (2026-10-20)