Compare commits

..
9 Commits
Author SHA1 Message Date
claude-bot Bot 9023308da7 Merge pull request 'Enhancement: Fail CI key removal when the key is not found' (#96) from enhancement/stricter-ci-key-check into main
Secret Scan / Betterleaks (push) Successful in 5s
2026-12-06 02:54:04 +01:00
kasun 3b37e3451b enhancement(k8s-bootstrap): fail CI key removal when the key is not found
Deploy k8s Bootstrap / Bootstrap k3s Cluster (pull_request) Skipped
Deploy k8s Bootstrap / Pulumi Preview (pull_request) Successful in 33s
Secret Scan / Betterleaks (pull_request) Successful in 5s
The final check only verified that the key was absent afterwards, which
also passes when the key was never matched, e.g. a hand-added key with a
comment. Requiring the key beforehand makes that case fail visibly.
2026-12-06 02:52:11 +01:00
kasun f9b577b726 Merge pull request 'Docs: Document RustFS backup cleanup and user policy checks' (#81) from docs/rustfs-attach-user-policy into main
Secret Scan / Betterleaks (push) Successful in 6s
Reviewed-on: #81
2026-12-06 02:42:52 +01:00
claude-bot Bot 3c07c5d3b3 Merge pull request 'Feature: Remove the CI SSH key from k3s nodes after bootstrap' (#95) from feature/revoke-ci-ssh-key into main
Secret Scan / Betterleaks (push) Successful in 6s
2026-12-06 02:39:50 +01:00
claude-bot Bot 73a03134d3 Merge pull request 'Enhancement: Simplify proxmox-infra and export the CI public key' (#94) from enhancement/refactor-proxmox-infra into main
Deploy Proxmox Infra / Pulumi Preview (push) Skipped
Deploy Proxmox Infra / Pulumi Deploy (push) Successful in 50s
Secret Scan / Betterleaks (push) Successful in 6s
2026-12-06 02:37:14 +01:00
kasun 2327e42cdd feature(k8s-bootstrap): remove the CI SSH key from nodes after bootstrap
Deploy k8s Bootstrap / Bootstrap k3s Cluster (pull_request) Skipped
Deploy k8s Bootstrap / Pulumi Preview (pull_request) Successful in 31s
Secret Scan / Betterleaks (pull_request) Successful in 5s
The key is only needed during bootstrap, but it stayed on every node with
passwordless sudo. A final step now removes it once all SSH steps are done.
Needs the ciRunnerPublicKey output from proxmox-infra, so deploy that first.

Also moves the repeated start, SSH-wait and join commands into helpers.
Resource names are unchanged, so nothing re-runs on the live cluster.
2026-12-06 02:33:21 +01:00
kasun 031ab44f71 enhancement(proxmox-infra): share SSH keys and DHCP setup, export CI public key
Deploy Proxmox Infra / Pulumi Deploy (pull_request) Skipped
Deploy Proxmox Infra / Pulumi Preview (pull_request) Successful in 54s
Secret Scan / Betterleaks (pull_request) Successful in 5s
The CI public key is exported so k8s-bootstrap can remove it from the
nodes after bootstrap. Deploy this stack before k8s-bootstrap reads it.
2026-12-06 02:33:18 +01:00
claude-bot Bot f6c71c3a3a Merge pull request 'Feature: Add a dedicated VM for the CI runner' (#93) from feature/ci-runner-vm into main
Deploy Proxmox Infra / Pulumi Preview (push) Skipped
Deploy Proxmox Infra / Pulumi Deploy (push) Successful in 1m31s
Secret Scan / Betterleaks (push) Successful in 7s
2026-12-04 18:48:04 +01:00
kasun e416e6a555 docs: add RustFS backup cleanup and policy checks to runbooks
Secret Scan / Betterleaks (pull_request) Successful in 7s
Object lock only blocks deletion; it never removes old backups, and the
RustFS console has no lifecycle screen, so the rule is set with the AWS
CLI. Also note that a new policy must be attached to the user, which
caused the first backup job's AccessDenied.
2026-12-03 03:34:53 +01:00
4 changed files with 271 additions and 236 deletions

No files matched your search

+70 -92
View File
@@ -27,42 +27,21 @@ const worker3Ip = config.requireSecret("worker3Ip");
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 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(
"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
// ---------------------------------------------------------------------------
@@ -133,7 +112,27 @@ const pveNodes = pveNodeSeeds
pveTemplate: new proxmox.VmLegacy(
`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,
name: "k3s-ubuntu-noble-template",
disks: [
@@ -176,10 +175,6 @@ const ciRunnerKey = new tls.PrivateKey("ci-runner-key", {
// ---------------------------------------------------------------------------
const k3sVmPassword = config.requireSecret("k3sVmPassword");
const pve1SshPublicKey = config.requireSecret("pve1SshPublicKey");
const pve2SshPublicKey = config.requireSecret("pve2SshPublicKey");
const pve3SshPublicKey = config.requireSecret("pve3SshPublicKey");
interface NodeConfig {
name: string;
role: "master" | "worker";
@@ -283,9 +278,7 @@ const k3sVms = nodeConfigs.map(
username: "ubuntu",
password: k3sVmPassword,
keys: [
pve1SshPublicKey.apply((k) => k.trim()),
pve2SshPublicKey.apply((k) => k.trim()),
pve3SshPublicKey.apply((k) => k.trim()),
...pvePublicKeys,
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) => {
const assignedMac = vmResource.networkDevices.apply(
(nic) => nic[0].macAddress,
);
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 },
);
staticDhcp("lan", nodeConfigs[i].name, assignedMac, nodeConfigs[i].ip, vmResource);
});
// ---------------------------------------------------------------------------
@@ -338,38 +335,29 @@ k3sVms.forEach((vmResource, i) => {
// 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 ubuntuTemplate = new proxmox.download.File(
"ubuntu-resolute-lxc-pve-b550",
{
nodeName: proxmoHost.nodeName,
datastoreId: proxmoHost.isoStore,
nodeName: proxmoxHost.nodeName,
datastoreId: proxmoxHost.isoStore,
contentType: "vztmpl",
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",
overwrite: false,
overwriteUnmanaged: true,
},
{ provider: proxmoHost.provider },
{ provider: proxmoxHost.provider },
);
const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
"ansible-dhcp",
{
interface: "lan",
macAddress: ansibleMac,
ipAddress: ansibleIp,
hostname: "ansible",
},
{ provider: pfSenseProvider, protect: true },
);
const ansibleDhcp = staticDhcp("lan", "ansible", ansibleMac, ansibleIp);
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
"ansible",
{
nodeName: proxmoHost.nodeName,
nodeName: proxmoxHost.nodeName,
description: "Ansible control node — managed by Pulumi",
tags: ["ansible"],
unprivileged: true,
@@ -380,7 +368,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
},
cpu: { cores: 1 },
memory: { dedicated: 1024, swap: 0 },
disk: { datastoreId: proxmoHost.dataStore, size: 8 },
disk: { datastoreId: proxmoxHost.dataStore, size: 8 },
networkInterfaces: [
{ name: "eth0", bridge: "vmbr0", macAddress: ansibleMac },
],
@@ -388,11 +376,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
hostname: "ansible",
ipConfigs: [{ ipv4: { address: "dhcp" } }],
userAccount: {
keys: [
pve1SshPublicKey.apply((k) => k.trim()),
pve2SshPublicKey.apply((k) => k.trim()),
pve3SshPublicKey.apply((k) => k.trim()),
],
keys: [...pvePublicKeys],
},
},
started: true,
@@ -400,7 +384,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
protection: true,
},
{
provider: proxmoHost.provider,
provider: proxmoxHost.provider,
dependsOn: ansibleDhcp,
retainOnDelete: true,
protect: true,
@@ -418,28 +402,19 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
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 },
);
const runnerDhcp = staticDhcp("lan", "runner", runnerMac, runnerIp);
new proxmox.VmLegacy( // NOSONAR typescript:S1848
"runner",
{
nodeName: proxmoHost.nodeName,
nodeName: proxmoxHost.nodeName,
name: "runner",
description: "Gitea Runner — managed by Pulumi",
tags: ["runner"],
clone: {
vmId: proxmoHost.pveTemplate.vmId,
vmId: proxmoxHost.pveTemplate.vmId,
full: true,
datastoreId: proxmoHost.dataStore,
datastoreId: proxmoxHost.dataStore,
},
cpu: {
cores: 2,
@@ -454,22 +429,20 @@ new proxmox.VmLegacy( // NOSONAR typescript:S1848
disks: [
{
interface: "scsi0",
datastoreId: proxmoHost.dataStore,
datastoreId: proxmoxHost.dataStore,
size: 20,
ssd: true,
discard: "on",
},
],
initialization: {
datastoreId: proxmoHost.dataStore,
datastoreId: proxmoxHost.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()),
...pvePublicKeys,
runnerAnsibleSshPublicKey.apply((k) => k.trim()),
],
},
@@ -488,7 +461,7 @@ new proxmox.VmLegacy( // NOSONAR typescript:S1848
rebootAfterUpdate: false,
},
{
provider: proxmoHost.provider,
provider: proxmoxHost.provider,
dependsOn: runnerDhcp,
retainOnDelete: true,
protect: true,
@@ -508,6 +481,11 @@ export const vmIds = {
// CI runner SSH private key — consumed by k8s-bootstrap via StackReference.
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 {
pve1Endpoint,
pve1ApiToken,
+175 -142
View File
@@ -87,6 +87,9 @@ const vmIdsOutput = infraRef.requireOutput("vmIds") as pulumi.Output<
const ciRunnerPrivateKey = infraRef.requireOutput(
"ciRunnerPrivateKey",
) as pulumi.Output<string>;
const ciRunnerPublicKey = infraRef.requireOutput(
"ciRunnerPublicKey",
) as pulumi.Output<string>;
const master1VmId = vmIdsOutput.apply((ids) => String(ids.master1));
const master2VmId = vmIdsOutput.apply((ids) => String(ids.master2));
@@ -120,42 +123,56 @@ function startVmScript(
' "$PVE_API_TOKEN"; }; is_running() { auth | curl -sf -K - --cacert "$ca" "$base/current" | grep -Eq '"status" *: *"running"'; }; is_running && exit 0; auth | curl -sf -K - --cacert "$ca" -X POST "$base/start" >/dev/null || exit 1; for i in $(seq 1 30); do is_running && exit 0; sleep 2; done; exit 1`;
}
const startMaster1 = new command.local.Command("start-master-1", {
create: startVmScript(pve1Endpoint, "pve1", "pve", master1VmId),
environment: { PVE_API_TOKEN: pve1ApiToken },
triggers: [master1VmId],
function startVm(
name: string,
create: pulumi.Input<string>,
apiToken: pulumi.Input<string>,
vmId: pulumi.Input<string>,
): command.local.Command {
return new command.local.Command(name, {
create,
environment: { PVE_API_TOKEN: apiToken },
triggers: [vmId],
interpreter: ["/bin/bash", "-c"],
});
const startMaster2 = new command.local.Command("start-master-2", {
create: startVmScript(pve3Endpoint, "pve3", "pve", master2VmId),
environment: { PVE_API_TOKEN: pve3ApiToken },
triggers: [master2VmId],
interpreter: ["/bin/bash", "-c"],
});
const startWorker1 = new command.local.Command("start-worker-1", {
create: startVmScript(pve1Endpoint, "pve1", "pve", worker1VmId),
environment: { PVE_API_TOKEN: pve1ApiToken },
triggers: [worker1VmId],
interpreter: ["/bin/bash", "-c"],
});
const startMaster3 = new command.local.Command("start-master-3", {
create: startVmScript(pve2Endpoint, "pve2", "pve-bckp", master3VmId),
environment: { PVE_API_TOKEN: pve2ApiToken },
triggers: [master3VmId],
interpreter: ["/bin/bash", "-c"],
});
const startWorker2 = new command.local.Command("start-worker-2", {
create: startVmScript(pve2Endpoint, "pve2", "pve-bckp", worker2VmId),
environment: { PVE_API_TOKEN: pve2ApiToken },
triggers: [worker2VmId],
interpreter: ["/bin/bash", "-c"],
});
const startWorker3 = new command.local.Command("start-worker-3", {
create: startVmScript(pve3Endpoint, "pve3", "pve", worker3VmId),
environment: { PVE_API_TOKEN: pve3ApiToken },
triggers: [worker3VmId],
interpreter: ["/bin/bash", "-c"],
});
});
}
const startMaster1 = startVm(
"start-master-1",
startVmScript(pve1Endpoint, "pve1", "pve", master1VmId),
pve1ApiToken,
master1VmId,
);
const startMaster2 = startVm(
"start-master-2",
startVmScript(pve3Endpoint, "pve3", "pve", master2VmId),
pve3ApiToken,
master2VmId,
);
const startWorker1 = startVm(
"start-worker-1",
startVmScript(pve1Endpoint, "pve1", "pve", worker1VmId),
pve1ApiToken,
worker1VmId,
);
const startMaster3 = startVm(
"start-master-3",
startVmScript(pve2Endpoint, "pve2", "pve-bckp", master3VmId),
pve2ApiToken,
master3VmId,
);
const startWorker2 = startVm(
"start-worker-2",
startVmScript(pve2Endpoint, "pve2", "pve-bckp", worker2VmId),
pve2ApiToken,
worker2VmId,
);
const startWorker3 = startVm(
"start-worker-3",
startVmScript(pve3Endpoint, "pve3", "pve", worker3VmId),
pve3ApiToken,
worker3VmId,
);
const allStarts = [
startMaster1,
@@ -170,14 +187,29 @@ const allStarts = [
// Step 2: Wait for SSH on master-1, install k3s
// ---------------------------------------------------------------------------
const waitMaster1Ssh = new command.local.Command(
"wait-ssh-master-1",
// Succeeds once port 22 answers, polling every 5 s for up to 5 min.
function waitSsh(
name: string,
ip: pulumi.Input<string>,
vmId: pulumi.Input<string>,
dependsOn: pulumi.ResourceOptions["dependsOn"],
): command.local.Command {
return new command.local.Command(
name,
{
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${master1Ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [master1VmId],
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [vmId],
interpreter: ["/bin/bash", "-c"],
},
{ dependsOn: allStarts },
{ dependsOn },
);
}
const waitMaster1Ssh = waitSsh(
"wait-ssh-master-1",
master1Ip,
master1VmId,
allStarts,
);
const installMaster1 = new command.remote.Command(
@@ -233,138 +265,105 @@ const waitControlPlaneVipReady = new command.remote.Command(
// Step 4: Wait for SSH on remaining masters, join cluster via the VIP
// ---------------------------------------------------------------------------
const waitMaster2Ssh = new command.local.Command(
"wait-ssh-master-2",
{
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${master2Ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [master2VmId],
interpreter: ["/bin/bash", "-c"],
},
{ dependsOn: [waitK3sMaster1Ready] },
);
const waitMaster2Ssh = waitSsh("wait-ssh-master-2", master2Ip, master2VmId, [
waitK3sMaster1Ready,
]);
const waitMaster3Ssh = new command.local.Command(
"wait-ssh-master-3",
{
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${master3Ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [master3VmId],
interpreter: ["/bin/bash", "-c"],
},
{ dependsOn: [waitK3sMaster1Ready] },
);
const waitMaster3Ssh = waitSsh("wait-ssh-master-3", master3Ip, master3VmId, [
waitK3sMaster1Ready,
]);
const joinMaster2 = new command.remote.Command(
"join-k3s-master-2",
// Joins an extra control-plane node through the VIP. Every master must get the
// same server flags, so they live here, not at the call site.
function joinMaster(
nodeName: string,
ip: pulumi.Input<string>,
vmId: pulumi.Input<string>,
dependsOn: pulumi.ResourceOptions["dependsOn"],
): command.remote.Command {
return new command.remote.Command(
`join-${nodeName}`,
{
connection: conn(master2Ip),
connection: conn(ip),
create: k3sInstallScript(
"",
pulumi.interpolate`server --server https://${controlPlaneVipAddress}:6443 --disable servicelb ${secretsEncryptionArgs} --node-name k3s-master-2`,
pulumi.interpolate`server --server https://${controlPlaneVipAddress}:6443 --disable servicelb ${secretsEncryptionArgs} --node-name ${nodeName}`,
),
stdin: k3sToken,
triggers: [master2VmId],
triggers: [vmId],
},
{ dependsOn: [waitMaster2Ssh, waitControlPlaneVipReady] },
);
{ dependsOn },
);
}
const joinMaster3 = new command.remote.Command(
"join-k3s-master-3",
{
connection: conn(master3Ip),
create: k3sInstallScript(
"",
pulumi.interpolate`server --server https://${controlPlaneVipAddress}:6443 --disable servicelb ${secretsEncryptionArgs} --node-name k3s-master-3`,
),
stdin: k3sToken,
triggers: [master3VmId],
},
{ dependsOn: [waitMaster3Ssh, waitControlPlaneVipReady, joinMaster2] },
);
const joinMaster2 = joinMaster("k3s-master-2", master2Ip, master2VmId, [
waitMaster2Ssh,
waitControlPlaneVipReady,
]);
const joinMaster3 = joinMaster("k3s-master-3", master3Ip, master3VmId, [
waitMaster3Ssh,
waitControlPlaneVipReady,
joinMaster2,
]);
// ---------------------------------------------------------------------------
// Step 5: Join worker nodes via the VIP
// ---------------------------------------------------------------------------
const waitWorker1Ssh = new command.local.Command(
"wait-ssh-worker-1",
{
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${worker1Ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [worker1VmId],
interpreter: ["/bin/bash", "-c"],
},
{ dependsOn: [joinMaster3] },
);
const waitWorker1Ssh = waitSsh("wait-ssh-worker-1", worker1Ip, worker1VmId, [
joinMaster3,
]);
const waitWorker2Ssh = new command.local.Command(
"wait-ssh-worker-2",
{
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${worker2Ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [worker2VmId],
interpreter: ["/bin/bash", "-c"],
},
{ dependsOn: [joinMaster3] },
);
const waitWorker2Ssh = waitSsh("wait-ssh-worker-2", worker2Ip, worker2VmId, [
joinMaster3,
]);
const waitWorker3Ssh = new command.local.Command(
"wait-ssh-worker-3",
{
create: pulumi.interpolate`for i in $(seq 1 60); do (timeout 5 bash -c "echo > /dev/tcp/${worker3Ip}/22") 2>/dev/null && exit 0; sleep 5; done; exit 1`,
triggers: [worker3VmId],
interpreter: ["/bin/bash", "-c"],
},
{ dependsOn: [joinMaster3] },
);
const waitWorker3Ssh = waitSsh("wait-ssh-worker-3", worker3Ip, worker3VmId, [
joinMaster3,
]);
const joinWorker1 = new command.remote.Command(
"join-k3s-worker-1",
function joinWorker(
nodeName: string,
ip: pulumi.Input<string>,
vmId: pulumi.Input<string>,
dependsOn: pulumi.ResourceOptions["dependsOn"],
): command.remote.Command {
return new command.remote.Command(
`join-${nodeName}`,
{
connection: conn(worker1Ip),
connection: conn(ip),
create: k3sInstallScript(
pulumi.interpolate`K3S_URL=https://${controlPlaneVipAddress}:6443`,
"--node-name k3s-worker-1",
`--node-name ${nodeName}`,
),
stdin: k3sToken,
triggers: [worker1VmId],
triggers: [vmId],
},
{ dependsOn: [waitWorker1Ssh] },
);
{ dependsOn },
);
}
const joinWorker2 = new command.remote.Command(
"join-k3s-worker-2",
{
connection: conn(worker2Ip),
create: k3sInstallScript(
pulumi.interpolate`K3S_URL=https://${controlPlaneVipAddress}:6443`,
"--node-name k3s-worker-2",
),
stdin: k3sToken,
triggers: [worker2VmId],
},
{ dependsOn: [waitWorker2Ssh] },
);
const joinWorker1 = joinWorker("k3s-worker-1", worker1Ip, worker1VmId, [
waitWorker1Ssh,
]);
const joinWorker3 = new command.remote.Command(
"join-k3s-worker-3",
{
connection: conn(worker3Ip),
create: k3sInstallScript(
pulumi.interpolate`K3S_URL=https://${controlPlaneVipAddress}:6443`,
"--node-name k3s-worker-3",
),
stdin: k3sToken,
triggers: [worker3VmId],
},
{ dependsOn: [waitWorker3Ssh] },
);
const joinWorker2 = joinWorker("k3s-worker-2", worker2Ip, worker2VmId, [
waitWorker2Ssh,
]);
const joinWorker3 = joinWorker("k3s-worker-3", worker3Ip, worker3VmId, [
waitWorker3Ssh,
]);
// ---------------------------------------------------------------------------
// Step 6: Format and mount Longhorn disks
// ---------------------------------------------------------------------------
const workers = [worker1Ip, worker2Ip, worker3Ip];
const workerSshReader = [waitWorker1Ssh, waitWorker2Ssh, waitWorker3Ssh];
const workerSshReady = [waitWorker1Ssh, waitWorker2Ssh, waitWorker3Ssh];
workers.forEach((worker, i) => {
const longhornMounts = workers.map((worker, i) => {
return new command.remote.Command(
`mount-longhorn-disk-${i}`,
{
@@ -382,7 +381,7 @@ workers.forEach((worker, i) => {
mountpoint -q /mnt/longhorn-extra;
df -h /mnt/longhorn-extra`,
},
{ dependsOn: workerSshReader[i] },
{ dependsOn: workerSshReady[i] },
);
});
@@ -446,7 +445,8 @@ const allVms = [
},
];
allVms.forEach(({ id, ip, name, readiness }) => {
const packageInstalls = allVms.map(
({ id, ip, name, readiness }) =>
new command.remote.Command(
`install-packages-${name}`,
{
@@ -456,6 +456,39 @@ allVms.forEach(({ id, ip, name, readiness }) => {
triggers: [id],
},
{ dependsOn: readiness },
),
);
// ---------------------------------------------------------------------------
// Step 9: Remove the CI runner's SSH key from every node
// ---------------------------------------------------------------------------
// The key is only needed for the steps above, so it shouldn't stay valid on
// the nodes afterwards. A rebuilt VM gets it again from cloud-init, so a fresh
// bootstrap still works.
const sshSteps = [getKubeconfig, ...longhornMounts, ...packageInstalls];
const revokeCiKeyScript = `set -euo pipefail
IFS= read -r KEY || true
[ -n "$KEY" ]
f="$HOME/.ssh/authorized_keys"
grep -qxF -- "$KEY" "$f"
grep -vxF -- "$KEY" "$f" > "$f.new" || [ $? -eq 1 ]
[ -s "$f.new" ]
chmod 600 "$f.new"
mv "$f.new" "$f"
if grep -qxF -- "$KEY" "$f"; then exit 1; fi`;
allVms.forEach(({ id, ip, name }) => {
new command.remote.Command(
`revoke-ci-key-${name}`,
{
connection: conn(ip),
create: revokeCiKeyScript,
stdin: ciRunnerPublicKey,
triggers: [id],
},
{ dependsOn: sshSteps },
);
});
+1 -1
View File
@@ -148,7 +148,7 @@ Only do this once steps 5 and 6 have worked. Check that Bitwarden has the admin
## Automatic backups
A CronJob from the OpenBao Helm chart saves a Raft snapshot every hour and uploads it to the `openbao-backups` bucket in RustFS on TrueNAS. Object lock keeps each backup for 30 days. The job logs in with Kubernetes auth and can only read snapshots. Its RustFS key can only upload.
A CronJob from the OpenBao Helm chart saves a Raft snapshot every hour and uploads it to the `openbao-backups` bucket in RustFS on TrueNAS. Object lock keeps each backup for 30 days, and a lifecycle rule deletes it after about 32 days. The job logs in with Kubernetes auth and can only read snapshots. Its RustFS key can only upload.
> Missed or failed backups don't trigger alerts yet. Check the job now and then, and still [save a snapshot](#save-a-snapshot) before upgrades.
+25 -1
View File
@@ -262,7 +262,31 @@ Object lock can only be turned on when a bucket is created. OpenBao's backup job
6. Protect the RustFS data with ZFS snapshots. Go to **Data Protection > Periodic Snapshot Tasks** and check that a task covers `<pool>/rustfs`, either directly or through a recursive task on its parent. Keep snapshots for at least 30 days. They protect backups if someone misuses the RustFS admin login. They don't protect against losing the pool.
Old backups aren't cleaned up automatically yet. The bucket keeps growing until a cleanup rule has been tested and added.
7. Delete old backups automatically. The lock from step 2 only stops deletion for 30 days; it doesn't delete anything. Old snapshots also contain old secrets, so don't keep them forever. The RustFS console has no lifecycle screen, so set the rule with the AWS CLI:
```bash
cat > lifecycle.json <<'EOF'
{"Rules":[
{"ID":"expire-after-31-days","Status":"Enabled","Filter":{"Prefix":""},
"Expiration":{"Days":31},
"NoncurrentVersionExpiration":{"NoncurrentDays":1}},
{"ID":"remove-delete-markers","Status":"Enabled","Filter":{"Prefix":""},
"Expiration":{"ExpiredObjectDeleteMarker":true}}
]}
EOF
admin s3api put-bucket-lifecycle-configuration --bucket openbao-backups --lifecycle-configuration file://lifecycle.json
admin s3api get-bucket-lifecycle-configuration --bucket openbao-backups
```
**Checkpoint:** both rules show `"Status": "Enabled"`.
The bucket is versioned, so the rule needs three parts. After 31 days, when the lock has ended, a backup gets a delete marker. One day later, its data is deleted. Then the leftover delete marker is removed. Each backup is kept for about 32 days. Lifecycle rules respect the lock, so a backup can't be deleted early even if the rule is wrong.
About 32 days after the first backup, check that cleanup works. The oldest date shown should be at most about 32 days ago:
```bash
admin s3api list-object-versions --bucket openbao-backups --query 'Versions[].LastModified' --output text | tr '\t' '\n' | sort | head -3
```
## Troubleshooting