feature(proxmox-infra): add a dedicated VM for the CI runner
A VM rather than an LXC: jobs run in Docker, and Docker in an LXC needs nesting + keyctl. The runner holds the Proxmox, pfSense and Pulumi credentials, so it gets its own kernel. The Ansible node gets a key used only for this VM, so its access can be revoked on its own.
This commit is contained in:
1 parent
063688746e
commit
7586d8af31
1 file changed
+104
-9
+104
-9
@@ -26,6 +26,12 @@ const worker2Ip = config.requireSecret("worker2Ip");
|
|||||||
const worker3Ip = config.requireSecret("worker3Ip");
|
const worker3Ip = config.requireSecret("worker3Ip");
|
||||||
|
|
||||||
const ansibleIp = config.requireSecret("ansibleIp");
|
const ansibleIp = config.requireSecret("ansibleIp");
|
||||||
|
const runnerIp = config.requireSecret("runnerIp");
|
||||||
|
// Generated on the Ansible node and used only for the runner VM, so access to
|
||||||
|
// the runner (and the CI credentials on it) can be revoked on its own.
|
||||||
|
const runnerAnsibleSshPublicKey = config.requireSecret(
|
||||||
|
"runnerAnsibleSshPublicKey",
|
||||||
|
);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// VM templates — one per node, cloned from the downloaded cloud image.
|
// VM templates — one per node, cloned from the downloaded cloud image.
|
||||||
@@ -332,21 +338,21 @@ k3sVms.forEach((vmResource, i) => {
|
|||||||
// boot; otherwise its first DHCP lease could come from the dynamic pool.
|
// boot; otherwise its first DHCP lease could come from the dynamic pool.
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
const ansibleHost = hostFor("pve-b550");
|
const proxmoHost = hostFor("pve-b550");
|
||||||
const ansibleMac = "02:A5:1B:00:01:54";
|
const ansibleMac = "02:A5:1B:00:01:54";
|
||||||
|
|
||||||
const ansibleTemplate = new proxmox.download.File(
|
const ubuntuTemplate = new proxmox.download.File(
|
||||||
"ubuntu-resolute-lxc-pve-b550",
|
"ubuntu-resolute-lxc-pve-b550",
|
||||||
{
|
{
|
||||||
nodeName: ansibleHost.nodeName,
|
nodeName: proxmoHost.nodeName,
|
||||||
datastoreId: ansibleHost.isoStore,
|
datastoreId: proxmoHost.isoStore,
|
||||||
contentType: "vztmpl",
|
contentType: "vztmpl",
|
||||||
fileName: "ubuntu-26.04-standard_26.04-1_amd64.tar.zst",
|
fileName: "ubuntu-26.04-standard_26.04-1_amd64.tar.zst",
|
||||||
url: "https://download.proxmox.com/images/system/ubuntu-26.04-standard_26.04-1_amd64.tar.zst",
|
url: "https://download.proxmox.com/images/system/ubuntu-26.04-standard_26.04-1_amd64.tar.zst",
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
overwriteUnmanaged: true,
|
overwriteUnmanaged: true,
|
||||||
},
|
},
|
||||||
{ provider: ansibleHost.provider },
|
{ provider: proxmoHost.provider },
|
||||||
);
|
);
|
||||||
|
|
||||||
const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
||||||
@@ -363,18 +369,18 @@ const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
|||||||
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
||||||
"ansible",
|
"ansible",
|
||||||
{
|
{
|
||||||
nodeName: ansibleHost.nodeName,
|
nodeName: proxmoHost.nodeName,
|
||||||
description: "Ansible control node — managed by Pulumi",
|
description: "Ansible control node — managed by Pulumi",
|
||||||
tags: ["ansible"],
|
tags: ["ansible"],
|
||||||
unprivileged: true,
|
unprivileged: true,
|
||||||
features: { nesting: true },
|
features: { nesting: true },
|
||||||
operatingSystem: {
|
operatingSystem: {
|
||||||
templateFileId: ansibleTemplate.id,
|
templateFileId: ubuntuTemplate.id,
|
||||||
type: "ubuntu",
|
type: "ubuntu",
|
||||||
},
|
},
|
||||||
cpu: { cores: 1 },
|
cpu: { cores: 1 },
|
||||||
memory: { dedicated: 1024, swap: 0 },
|
memory: { dedicated: 1024, swap: 0 },
|
||||||
disk: { datastoreId: ansibleHost.dataStore, size: 8 },
|
disk: { datastoreId: proxmoHost.dataStore, size: 8 },
|
||||||
networkInterfaces: [
|
networkInterfaces: [
|
||||||
{ name: "eth0", bridge: "vmbr0", macAddress: ansibleMac },
|
{ name: "eth0", bridge: "vmbr0", macAddress: ansibleMac },
|
||||||
],
|
],
|
||||||
@@ -394,13 +400,102 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
|||||||
protection: true,
|
protection: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provider: ansibleHost.provider,
|
provider: proxmoHost.provider,
|
||||||
dependsOn: ansibleDhcp,
|
dependsOn: ansibleDhcp,
|
||||||
retainOnDelete: true,
|
retainOnDelete: true,
|
||||||
protect: true,
|
protect: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Gitea Runner — VM with a pfSense DHCP reservation.
|
||||||
|
// A VM rather than an LXC: jobs run in Docker, and Docker in an LXC needs
|
||||||
|
// nesting + keyctl, which widens the shared-kernel attack surface towards the
|
||||||
|
// Proxmox host. The runner holds the most powerful credentials (Proxmox,
|
||||||
|
// pfSense, Pulumi), so it gets its own kernel. Fixed MAC for the same reason
|
||||||
|
// as the Ansible node: the reservation exists before the first boot.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const runnerMac = "02:A5:1B:00:01:55";
|
||||||
|
|
||||||
|
const runnerDhcp = new pfsense.Dhcpv4Staticmapping(
|
||||||
|
"runner-dhcp",
|
||||||
|
{
|
||||||
|
interface: "lan",
|
||||||
|
macAddress: runnerMac,
|
||||||
|
ipAddress: runnerIp,
|
||||||
|
hostname: "runner",
|
||||||
|
},
|
||||||
|
{ provider: pfSenseProvider, protect: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
new proxmox.VmLegacy( // NOSONAR typescript:S1848
|
||||||
|
"runner",
|
||||||
|
{
|
||||||
|
nodeName: proxmoHost.nodeName,
|
||||||
|
name: "runner",
|
||||||
|
description: "Gitea Runner — managed by Pulumi",
|
||||||
|
tags: ["runner"],
|
||||||
|
clone: {
|
||||||
|
vmId: proxmoHost.pveTemplate.vmId,
|
||||||
|
full: true,
|
||||||
|
datastoreId: proxmoHost.dataStore,
|
||||||
|
},
|
||||||
|
cpu: {
|
||||||
|
cores: 2,
|
||||||
|
sockets: 1,
|
||||||
|
type: "host",
|
||||||
|
numa: true,
|
||||||
|
},
|
||||||
|
memory: {
|
||||||
|
dedicated: 4096,
|
||||||
|
floating: 0,
|
||||||
|
},
|
||||||
|
disks: [
|
||||||
|
{
|
||||||
|
interface: "scsi0",
|
||||||
|
datastoreId: proxmoHost.dataStore,
|
||||||
|
size: 20,
|
||||||
|
ssd: true,
|
||||||
|
discard: "on",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
initialization: {
|
||||||
|
datastoreId: proxmoHost.dataStore,
|
||||||
|
ipConfigs: [{ ipv4: { address: "dhcp" } }],
|
||||||
|
// Key-only login: no password, unlike the k3s nodes.
|
||||||
|
userAccount: {
|
||||||
|
username: "ubuntu",
|
||||||
|
keys: [
|
||||||
|
pve1SshPublicKey.apply((k) => k.trim()),
|
||||||
|
pve2SshPublicKey.apply((k) => k.trim()),
|
||||||
|
pve3SshPublicKey.apply((k) => k.trim()),
|
||||||
|
runnerAnsibleSshPublicKey.apply((k) => k.trim()),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
networkDevices: [
|
||||||
|
{ bridge: "vmbr0", model: "virtio", macAddress: runnerMac },
|
||||||
|
],
|
||||||
|
scsiHardware: "virtio-scsi-pci",
|
||||||
|
serialDevices: [{}],
|
||||||
|
vga: { type: "serial0" },
|
||||||
|
agent: { enabled: true, timeout: "30s" },
|
||||||
|
cdrom: { fileId: "none" },
|
||||||
|
started: true,
|
||||||
|
onBoot: true,
|
||||||
|
protection: true,
|
||||||
|
rebootAfterUpdate: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provider: proxmoHost.provider,
|
||||||
|
dependsOn: runnerDhcp,
|
||||||
|
retainOnDelete: true,
|
||||||
|
protect: true,
|
||||||
|
ignoreChanges: ["clone", "disks[0].speed"],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export const vmIds = {
|
export const vmIds = {
|
||||||
master1: k3sVms[0].vmId,
|
master1: k3sVms[0].vmId,
|
||||||
master2: k3sVms[1].vmId,
|
master2: k3sVms[1].vmId,
|
||||||
|
|||||||
Reference in new issue
Block a user