From e3fab0e1516ee6dc70fc45ebb5012b27960a7957 Mon Sep 17 00:00:00 2001 From: kasun Date: Sun, 22 Nov 2026 02:58:30 +0100 Subject: [PATCH] bug(k8s-bootstrap): stop re-running install commands on live nodes Bootstrap commands used VM IDs as triggers, so renumbering VMs would re-run the unpinned k3s installer on every node and append duplicate fstab entries. Treat them as run-once and re-run them explicitly after recreating a VM. Also start master-2 through pve-esprimo, where it now lives. --- 02-k8s-bootstrap/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/02-k8s-bootstrap/index.ts b/02-k8s-bootstrap/index.ts index da96eda..b628f25 100644 --- a/02-k8s-bootstrap/index.ts +++ b/02-k8s-bootstrap/index.ts @@ -3,6 +3,20 @@ import * as command from "@pulumi/command"; const config = new pulumi.Config(); +// Bootstrap commands run once, on a fresh install. Without this, a changed VM +// ID or command would re-run the k3s installer on the live cluster. After +// recreating a VM, re-run its commands explicitly with --target-replace. +pulumi.runtime.registerResourceTransform((args) => + args.type.startsWith("command:") + ? { + props: args.props, + opts: pulumi.mergeOptions(args.opts, { + ignoreChanges: ["create", "triggers"], + }), + } + : undefined, +); + const infraRef = new pulumi.StackReference( `${pulumi.getOrganization()}/proxmox-infra/dev`, ); @@ -77,7 +91,7 @@ const startMaster1 = new command.local.Command("start-master-1", { interpreter: ["/bin/bash", "-c"], }); const startMaster2 = new command.local.Command("start-master-2", { - create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve1ApiToken}" "${pve1Endpoint}/api2/json/nodes/pve/qemu/${master2VmId}/status/start" 2>/dev/null || true`, + create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve3ApiToken}" "${pve3Endpoint}/api2/json/nodes/pve/qemu/${master2VmId}/status/start" 2>/dev/null || true`, triggers: [master2VmId], interpreter: ["/bin/bash", "-c"], }); -- 2.54.1