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"], });