docs: add decision record and runbook for the CI runner VM
This commit is contained in:
1 parent
7586d8af31
commit
6108d6dbf5
3 files changed
+56
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# 0002: CI runner on a dedicated VM with Docker job containers
|
||||
|
||||
Status: accepted (December 2026)
|
||||
|
||||
## Context
|
||||
|
||||
The Gitea runner ran as a container on the shared Docker host, next to Gitea and Postgres, with the Docker socket mounted. A job that reached the socket had root on that host. Jobs in this repo also hold the most powerful credentials in the homelab: the Proxmox API tokens, pfSense access and the Pulumi passphrase.
|
||||
|
||||
## Decision
|
||||
|
||||
The runner runs on its own VM (`runner`, defined in `01-proxmox-infra`), outside the k3s cluster:
|
||||
|
||||
- act_runner runs as a systemd service, installed and configured by Ansible.
|
||||
- Each job runs in a fresh Docker container that is removed afterwards. Job containers don't get the Docker socket (`container.docker_host: "-"`), and `capacity: 1`.
|
||||
- The registration token is entered by hand at registration time and isn't stored anywhere.
|
||||
- SSH is key-only. Ansible uses a key that exists only for this VM.
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
- **Unprivileged LXC with Docker:** Docker in an LXC needs `nesting` and `keyctl`, which widens the shared-kernel attack surface towards the Proxmox host. Proxmox itself recommends running Docker in a VM. For the host holding the strongest credentials, a separate kernel is worth the extra RAM.
|
||||
- **Host mode (no Docker):** jobs would leave files and tools behind for the next job and could read the runner's own credential (`.runner`). The security gain is small, because deploy secrets are in the job environment in either mode.
|
||||
- **Runner pods in k3s:** `01` and `02` create and repair the cluster, so the runner can't depend on it. Gitea also has no mature per-job pod autoscaler.
|
||||
|
||||
## Consequences
|
||||
|
||||
- When everything is down, recovery doesn't go through CI. You run `pulumi up` from the workstation instead.
|
||||
- Deploy secrets are still readable by any job. The real protection is scoping the credentials and filtering the runner's outbound traffic, both tracked separately.
|
||||
- Access to the runner VM is as sensitive as the CI credentials themselves. That includes the Ansible node, through its dedicated key.
|
||||
@@ -0,0 +1,27 @@
|
||||
# CI runner VM: first-time setup
|
||||
|
||||
The `runner` VM is defined in `01-proxmox-infra`. For the design, see [decision 0002](../decisions/0002-ci-runner-on-a-vm.md). Do this once, before the first deploy that creates the VM.
|
||||
|
||||
1. On the Ansible node, create a key that is used only for the runner VM:
|
||||
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -f ~/.ssh/runner_vm -C ansible-runner-vm
|
||||
```
|
||||
|
||||
2. Set the config from the repo root, then commit and push it in the private config repo:
|
||||
|
||||
```bash
|
||||
cd 01-proxmox-infra
|
||||
pulumi config set --secret runnerIp <free IP outside the DHCP pool>
|
||||
pulumi config set --secret runnerAnsibleSshPublicKey "$(cat runner_vm.pub)" # copy of ~/.ssh/runner_vm.pub from the Ansible node
|
||||
```
|
||||
|
||||
3. Deploy `01-proxmox-infra`. Pulumi creates the pfSense DHCP reservation and the VM.
|
||||
|
||||
4. Check that the Ansible node can log in: `ssh -i ~/.ssh/runner_vm ubuntu@<runnerIp>`.
|
||||
|
||||
5. Install and register act_runner with the runner playbook in the Ansible repo. The playbook asks for a registration token: create one in Gitea, then reset it right after registering.
|
||||
|
||||
## Revoke access
|
||||
|
||||
To lock the Ansible node out of the runner VM, remove its key from `~ubuntu/.ssh/authorized_keys` on the VM. Changing the config alone isn't enough, because cloud-init only applies keys on the first boot.
|
||||
Reference in new issue
Block a user