Skip to content
Mementropy
RecipesHomelab recipesReference

Running an isolated Gitea Actions runner on K3s

A CI runner pod with no API token, no privileges, and tight egress.

By Ryan Hammang

CI that can reach Git and the internet but nothing else on the network.

  1. Get a registration token with the CLI (the admin API returned 404 on Gitea 1.27.0):
Terminal window
kubectl exec -n gitea deploy/gitea -- gitea actions generate-runner-token

Store it in your secrets manager. Never put it on a command line.

  1. Runner pod settings:
serviceAccountName: gitea-runner-sa
automountServiceAccountToken: false
securityContext:
privileged: false
allowPrivilegeEscalation: false

Use the runner’s host mode, with no Docker-in-Docker.

  1. NetworkPolicy: deny all ingress. Allow egress to:

    • kube-dns on 53
    • Gitea’s address on 80 and 2222 only
    • 0.0.0.0/0 on 80 and 443, with except for 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and 100.64.0.0/10
  2. Put workflows in .gitea/workflows/.

From inside the runner pod:

  • /var/run/secrets/kubernetes.io/serviceaccount doesn’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.

  • Gitea ignores .forgejo/workflows/.
  • If another service shares Gitea’s address, allow Gitea’s ports only.
  • Gitea’s run API returns head_sha and started_at. Forgejo returns commit_sha and created.