Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
031ab44f71 |
+70
-92
@@ -27,42 +27,21 @@ const worker3Ip = config.requireSecret("worker3Ip");
|
|||||||
|
|
||||||
const ansibleIp = config.requireSecret("ansibleIp");
|
const ansibleIp = config.requireSecret("ansibleIp");
|
||||||
const runnerIp = config.requireSecret("runnerIp");
|
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 pve1SshPublicKey = config.requireSecret("pve1SshPublicKey");
|
||||||
|
const pve2SshPublicKey = config.requireSecret("pve2SshPublicKey");
|
||||||
|
const pve3SshPublicKey = config.requireSecret("pve3SshPublicKey");
|
||||||
|
|
||||||
|
const pvePublicKeys: pulumi.Output<string>[] = [
|
||||||
|
pve1SshPublicKey.apply((k) => k.trim()),
|
||||||
|
pve2SshPublicKey.apply((k) => k.trim()),
|
||||||
|
pve3SshPublicKey.apply((k) => k.trim()),
|
||||||
|
];
|
||||||
|
|
||||||
const runnerAnsibleSshPublicKey = config.requireSecret(
|
const runnerAnsibleSshPublicKey = config.requireSecret(
|
||||||
"runnerAnsibleSshPublicKey",
|
"runnerAnsibleSshPublicKey",
|
||||||
);
|
);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// VM templates — one per node, cloned from the downloaded cloud image.
|
|
||||||
// Templates are not started and have no cloud-init config; that is applied
|
|
||||||
// per-clone so each node gets its own hostname (derived from VM name).
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const templateSettings = {
|
|
||||||
template: true,
|
|
||||||
protection: true,
|
|
||||||
started: false,
|
|
||||||
operatingSystem: { type: "l26" },
|
|
||||||
stopOnDestroy: true,
|
|
||||||
scsiHardware: "virtio-scsi-pci",
|
|
||||||
cdrom: { fileId: "none" },
|
|
||||||
cpu: {
|
|
||||||
cores: 2,
|
|
||||||
sockets: 1,
|
|
||||||
type: "host",
|
|
||||||
numa: true,
|
|
||||||
},
|
|
||||||
memory: {
|
|
||||||
dedicated: 2048,
|
|
||||||
floating: 0,
|
|
||||||
},
|
|
||||||
networkDevices: [{ bridge: "vmbr0", model: "virtio" }],
|
|
||||||
serialDevices: [{}],
|
|
||||||
vga: { type: "serial0" },
|
|
||||||
agent: { enabled: true, timeout: "30s" },
|
|
||||||
};
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Providers — one per standalone Proxmox machine
|
// Providers — one per standalone Proxmox machine
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -133,7 +112,27 @@ const pveNodes = pveNodeSeeds
|
|||||||
pveTemplate: new proxmox.VmLegacy(
|
pveTemplate: new proxmox.VmLegacy(
|
||||||
`k3s-template-${n.hostLabel}`,
|
`k3s-template-${n.hostLabel}`,
|
||||||
{
|
{
|
||||||
...templateSettings,
|
template: true,
|
||||||
|
protection: true,
|
||||||
|
started: false,
|
||||||
|
operatingSystem: { type: "l26" },
|
||||||
|
stopOnDestroy: true,
|
||||||
|
scsiHardware: "virtio-scsi-pci",
|
||||||
|
cdrom: { fileId: "none" },
|
||||||
|
cpu: {
|
||||||
|
cores: 2,
|
||||||
|
sockets: 1,
|
||||||
|
type: "host",
|
||||||
|
numa: true,
|
||||||
|
},
|
||||||
|
memory: {
|
||||||
|
dedicated: 2048,
|
||||||
|
floating: 0,
|
||||||
|
},
|
||||||
|
networkDevices: [{ bridge: "vmbr0", model: "virtio" }],
|
||||||
|
serialDevices: [{}],
|
||||||
|
vga: { type: "serial0" },
|
||||||
|
agent: { enabled: true, timeout: "30s" },
|
||||||
nodeName: n.nodeName,
|
nodeName: n.nodeName,
|
||||||
name: "k3s-ubuntu-noble-template",
|
name: "k3s-ubuntu-noble-template",
|
||||||
disks: [
|
disks: [
|
||||||
@@ -176,10 +175,6 @@ const ciRunnerKey = new tls.PrivateKey("ci-runner-key", {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
const k3sVmPassword = config.requireSecret("k3sVmPassword");
|
const k3sVmPassword = config.requireSecret("k3sVmPassword");
|
||||||
const pve1SshPublicKey = config.requireSecret("pve1SshPublicKey");
|
|
||||||
const pve2SshPublicKey = config.requireSecret("pve2SshPublicKey");
|
|
||||||
const pve3SshPublicKey = config.requireSecret("pve3SshPublicKey");
|
|
||||||
|
|
||||||
interface NodeConfig {
|
interface NodeConfig {
|
||||||
name: string;
|
name: string;
|
||||||
role: "master" | "worker";
|
role: "master" | "worker";
|
||||||
@@ -283,9 +278,7 @@ const k3sVms = nodeConfigs.map(
|
|||||||
username: "ubuntu",
|
username: "ubuntu",
|
||||||
password: k3sVmPassword,
|
password: k3sVmPassword,
|
||||||
keys: [
|
keys: [
|
||||||
pve1SshPublicKey.apply((k) => k.trim()),
|
...pvePublicKeys,
|
||||||
pve2SshPublicKey.apply((k) => k.trim()),
|
|
||||||
pve3SshPublicKey.apply((k) => k.trim()),
|
|
||||||
ciRunnerKey.publicKeyOpenssh.apply((k) => k.trim()),
|
ciRunnerKey.publicKeyOpenssh.apply((k) => k.trim()),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -315,21 +308,25 @@ const k3sVms = nodeConfigs.map(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function staticDhcp(
|
||||||
|
iface: pfsense.Dhcpv4StaticmappingArgs["interface"],
|
||||||
|
hostname: string,
|
||||||
|
macAddress: pfsense.Dhcpv4StaticmappingArgs["macAddress"],
|
||||||
|
ipAddress: pfsense.Dhcpv4StaticmappingArgs["ipAddress"],
|
||||||
|
dependsOn?: pulumi.Resource,
|
||||||
|
): pfsense.Dhcpv4Staticmapping {
|
||||||
|
return new pfsense.Dhcpv4Staticmapping(
|
||||||
|
`${hostname}-dhcp`,
|
||||||
|
{ interface: iface, macAddress, ipAddress, hostname },
|
||||||
|
{ dependsOn, provider: pfSenseProvider, protect: true },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
k3sVms.forEach((vmResource, i) => {
|
k3sVms.forEach((vmResource, i) => {
|
||||||
const assignedMac = vmResource.networkDevices.apply(
|
const assignedMac = vmResource.networkDevices.apply(
|
||||||
(nic) => nic[0].macAddress,
|
(nic) => nic[0].macAddress,
|
||||||
);
|
);
|
||||||
|
staticDhcp("lan", nodeConfigs[i].name, assignedMac, nodeConfigs[i].ip, vmResource);
|
||||||
new pfsense.Dhcpv4Staticmapping(
|
|
||||||
`${nodeConfigs[i].name}-dhcp`,
|
|
||||||
{
|
|
||||||
interface: "lan",
|
|
||||||
macAddress: assignedMac,
|
|
||||||
ipAddress: nodeConfigs[i].ip,
|
|
||||||
hostname: nodeConfigs[i].name,
|
|
||||||
},
|
|
||||||
{ dependsOn: vmResource, provider: pfSenseProvider, protect: true },
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -338,38 +335,29 @@ 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 proxmoHost = hostFor("pve-b550");
|
const proxmoxHost = hostFor("pve-b550");
|
||||||
const ansibleMac = "02:A5:1B:00:01:54";
|
const ansibleMac = "02:A5:1B:00:01:54";
|
||||||
|
|
||||||
const ubuntuTemplate = new proxmox.download.File(
|
const ubuntuTemplate = new proxmox.download.File(
|
||||||
"ubuntu-resolute-lxc-pve-b550",
|
"ubuntu-resolute-lxc-pve-b550",
|
||||||
{
|
{
|
||||||
nodeName: proxmoHost.nodeName,
|
nodeName: proxmoxHost.nodeName,
|
||||||
datastoreId: proxmoHost.isoStore,
|
datastoreId: proxmoxHost.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: proxmoHost.provider },
|
{ provider: proxmoxHost.provider },
|
||||||
);
|
);
|
||||||
|
|
||||||
const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
const ansibleDhcp = staticDhcp("lan", "ansible", ansibleMac, ansibleIp);
|
||||||
"ansible-dhcp",
|
|
||||||
{
|
|
||||||
interface: "lan",
|
|
||||||
macAddress: ansibleMac,
|
|
||||||
ipAddress: ansibleIp,
|
|
||||||
hostname: "ansible",
|
|
||||||
},
|
|
||||||
{ provider: pfSenseProvider, protect: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
||||||
"ansible",
|
"ansible",
|
||||||
{
|
{
|
||||||
nodeName: proxmoHost.nodeName,
|
nodeName: proxmoxHost.nodeName,
|
||||||
description: "Ansible control node — managed by Pulumi",
|
description: "Ansible control node — managed by Pulumi",
|
||||||
tags: ["ansible"],
|
tags: ["ansible"],
|
||||||
unprivileged: true,
|
unprivileged: true,
|
||||||
@@ -380,7 +368,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
|||||||
},
|
},
|
||||||
cpu: { cores: 1 },
|
cpu: { cores: 1 },
|
||||||
memory: { dedicated: 1024, swap: 0 },
|
memory: { dedicated: 1024, swap: 0 },
|
||||||
disk: { datastoreId: proxmoHost.dataStore, size: 8 },
|
disk: { datastoreId: proxmoxHost.dataStore, size: 8 },
|
||||||
networkInterfaces: [
|
networkInterfaces: [
|
||||||
{ name: "eth0", bridge: "vmbr0", macAddress: ansibleMac },
|
{ name: "eth0", bridge: "vmbr0", macAddress: ansibleMac },
|
||||||
],
|
],
|
||||||
@@ -388,11 +376,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
|||||||
hostname: "ansible",
|
hostname: "ansible",
|
||||||
ipConfigs: [{ ipv4: { address: "dhcp" } }],
|
ipConfigs: [{ ipv4: { address: "dhcp" } }],
|
||||||
userAccount: {
|
userAccount: {
|
||||||
keys: [
|
keys: [...pvePublicKeys],
|
||||||
pve1SshPublicKey.apply((k) => k.trim()),
|
|
||||||
pve2SshPublicKey.apply((k) => k.trim()),
|
|
||||||
pve3SshPublicKey.apply((k) => k.trim()),
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
started: true,
|
started: true,
|
||||||
@@ -400,7 +384,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
|||||||
protection: true,
|
protection: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provider: proxmoHost.provider,
|
provider: proxmoxHost.provider,
|
||||||
dependsOn: ansibleDhcp,
|
dependsOn: ansibleDhcp,
|
||||||
retainOnDelete: true,
|
retainOnDelete: true,
|
||||||
protect: true,
|
protect: true,
|
||||||
@@ -418,28 +402,19 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
|||||||
|
|
||||||
const runnerMac = "02:A5:1B:00:01:55";
|
const runnerMac = "02:A5:1B:00:01:55";
|
||||||
|
|
||||||
const runnerDhcp = new pfsense.Dhcpv4Staticmapping(
|
const runnerDhcp = staticDhcp("lan", "runner", runnerMac, runnerIp);
|
||||||
"runner-dhcp",
|
|
||||||
{
|
|
||||||
interface: "lan",
|
|
||||||
macAddress: runnerMac,
|
|
||||||
ipAddress: runnerIp,
|
|
||||||
hostname: "runner",
|
|
||||||
},
|
|
||||||
{ provider: pfSenseProvider, protect: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
new proxmox.VmLegacy( // NOSONAR typescript:S1848
|
new proxmox.VmLegacy( // NOSONAR typescript:S1848
|
||||||
"runner",
|
"runner",
|
||||||
{
|
{
|
||||||
nodeName: proxmoHost.nodeName,
|
nodeName: proxmoxHost.nodeName,
|
||||||
name: "runner",
|
name: "runner",
|
||||||
description: "Gitea Runner — managed by Pulumi",
|
description: "Gitea Runner — managed by Pulumi",
|
||||||
tags: ["runner"],
|
tags: ["runner"],
|
||||||
clone: {
|
clone: {
|
||||||
vmId: proxmoHost.pveTemplate.vmId,
|
vmId: proxmoxHost.pveTemplate.vmId,
|
||||||
full: true,
|
full: true,
|
||||||
datastoreId: proxmoHost.dataStore,
|
datastoreId: proxmoxHost.dataStore,
|
||||||
},
|
},
|
||||||
cpu: {
|
cpu: {
|
||||||
cores: 2,
|
cores: 2,
|
||||||
@@ -454,22 +429,20 @@ new proxmox.VmLegacy( // NOSONAR typescript:S1848
|
|||||||
disks: [
|
disks: [
|
||||||
{
|
{
|
||||||
interface: "scsi0",
|
interface: "scsi0",
|
||||||
datastoreId: proxmoHost.dataStore,
|
datastoreId: proxmoxHost.dataStore,
|
||||||
size: 20,
|
size: 20,
|
||||||
ssd: true,
|
ssd: true,
|
||||||
discard: "on",
|
discard: "on",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
initialization: {
|
initialization: {
|
||||||
datastoreId: proxmoHost.dataStore,
|
datastoreId: proxmoxHost.dataStore,
|
||||||
ipConfigs: [{ ipv4: { address: "dhcp" } }],
|
ipConfigs: [{ ipv4: { address: "dhcp" } }],
|
||||||
// Key-only login: no password, unlike the k3s nodes.
|
// Key-only login: no password, unlike the k3s nodes.
|
||||||
userAccount: {
|
userAccount: {
|
||||||
username: "ubuntu",
|
username: "ubuntu",
|
||||||
keys: [
|
keys: [
|
||||||
pve1SshPublicKey.apply((k) => k.trim()),
|
...pvePublicKeys,
|
||||||
pve2SshPublicKey.apply((k) => k.trim()),
|
|
||||||
pve3SshPublicKey.apply((k) => k.trim()),
|
|
||||||
runnerAnsibleSshPublicKey.apply((k) => k.trim()),
|
runnerAnsibleSshPublicKey.apply((k) => k.trim()),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -488,7 +461,7 @@ new proxmox.VmLegacy( // NOSONAR typescript:S1848
|
|||||||
rebootAfterUpdate: false,
|
rebootAfterUpdate: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provider: proxmoHost.provider,
|
provider: proxmoxHost.provider,
|
||||||
dependsOn: runnerDhcp,
|
dependsOn: runnerDhcp,
|
||||||
retainOnDelete: true,
|
retainOnDelete: true,
|
||||||
protect: true,
|
protect: true,
|
||||||
@@ -508,6 +481,11 @@ export const vmIds = {
|
|||||||
// CI runner SSH private key — consumed by k8s-bootstrap via StackReference.
|
// CI runner SSH private key — consumed by k8s-bootstrap via StackReference.
|
||||||
export const ciRunnerPrivateKey = pulumi.secret(ciRunnerKey.privateKeyOpenssh);
|
export const ciRunnerPrivateKey = pulumi.secret(ciRunnerKey.privateKeyOpenssh);
|
||||||
|
|
||||||
|
// Public half, so k8s-bootstrap can remove it from the nodes after bootstrap.
|
||||||
|
export const ciRunnerPublicKey = ciRunnerKey.publicKeyOpenssh.apply((k) =>
|
||||||
|
k.trim(),
|
||||||
|
);
|
||||||
|
|
||||||
export {
|
export {
|
||||||
pve1Endpoint,
|
pve1Endpoint,
|
||||||
pve1ApiToken,
|
pve1ApiToken,
|
||||||
|
|||||||
Reference in new issue
Block a user