Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13330ef3fb | ||
|
|
855d1cce85 | ||
|
|
9b388ff8e2 | ||
|
|
0d5f49591a | ||
|
|
12400b4c83 | ||
|
|
05bec1a5ff | ||
|
|
f6f74d9977 | ||
|
|
f2b8704914 | ||
|
|
be09d7592f | ||
|
|
abac1bf532 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Old Gitea token in deleted .env.local. Confirmed revoked (API returned 401) on 2026-11-22.
|
||||
8c69ec772ab5f0df73fa2614e5b8b22adb9bbd15:.env.local:gitea-access-token:2
|
||||
@@ -89,8 +89,8 @@ Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergea
|
||||
Keep it short:
|
||||
|
||||
- PR link and commits.
|
||||
- What the merge deploys, from the `on.push.paths` in `.gitea/workflows/`. `03`, `04` and `05` deploy on merge, and a change under `.gitea/workflows/` can deploy all three.
|
||||
- For `01` or `02` changes, say that they are not live until someone runs the manual workflow.
|
||||
- What the merge deploys, from the `on.push.paths` in `.gitea/workflows/`. `01`, `03`, `04` and `05` deploy on merge. A change under `.gitea/workflows/` can deploy `03`, `04` and `05`, and a change to `01`'s own workflow deploys `01`.
|
||||
- For `02` changes, say that they are not live until someone runs the manual workflow.
|
||||
- Anything left uncommitted, and a reminder to update `<STACK>_PULUMI_DEV_YAML` if local Pulumi config changed.
|
||||
|
||||
Do not delete the branch, dispatch a workflow, or change a live system.
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "03-k8s-infra/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/03-deploy-k8s-infra.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "04-k8s-apps/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/04-deploy-k8s-apps.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "05-monitoring/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/05-deploy-monitoring.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Secret Scan
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
BETTERLEAKS_VERSION: "1.10.1"
|
||||
BETTERLEAKS_SHA256: c174b42d7aa60caf58c0c3e555c0e4bed01fe6b0d99a412bce777b5af4ce913e
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
name: Betterleaks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Full History
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Betterleaks
|
||||
run: |
|
||||
curl -fsSL -o /tmp/betterleaks.tar.gz \
|
||||
"https://github.com/betterleaks/betterleaks/releases/download/v${BETTERLEAKS_VERSION}/betterleaks_${BETTERLEAKS_VERSION}_linux_x64.tar.gz"
|
||||
echo "${BETTERLEAKS_SHA256} /tmp/betterleaks.tar.gz" | sha256sum -c -
|
||||
tar -xzf /tmp/betterleaks.tar.gz -C /tmp betterleaks
|
||||
|
||||
- name: Scan Git History
|
||||
run: /tmp/betterleaks git . --redact --verbose --no-banner --no-color --log-opts="--all -m -p -U0"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git pre-commit hook: blocks a commit if its staged changes contain a secret.
|
||||
#
|
||||
# Activate once per clone: git config core.hooksPath .githooks
|
||||
# Skip in an emergency: git commit --no-verify
|
||||
if ! command -v betterleaks >/dev/null 2>&1; then
|
||||
echo "pre-commit: betterleaks is not installed, so staged changes can't be scanned" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec betterleaks git --pre-commit --staged --redact --no-banner --no-color .
|
||||
+3
-1
@@ -5,4 +5,6 @@ node_modules/
|
||||
bin/
|
||||
Pulumi.dev.yaml
|
||||
sdks/
|
||||
.env
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
@@ -11,6 +11,7 @@ config:
|
||||
packages:
|
||||
pfsense:
|
||||
source: terraform-provider
|
||||
version: 1.1.3
|
||||
version: 1.5.1
|
||||
parameters:
|
||||
- marshallford/pfsense
|
||||
- 0.22.0
|
||||
Generated
+365
-1691
File diff suppressed because it is too large.
Load diff
+45
-22
@@ -4,14 +4,15 @@ 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.
|
||||
// ID, node IP, SSH key 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"],
|
||||
ignoreChanges: ["create", "triggers", "connection"],
|
||||
}),
|
||||
}
|
||||
: undefined,
|
||||
@@ -51,6 +52,9 @@ const worker3Ip = infraRef.requireOutput("worker3Ip");
|
||||
// Pre-shared k3s cluster token
|
||||
const k3sToken = config.requireSecret("k3sToken");
|
||||
|
||||
// Version for fresh installs. Changing it does not upgrade the live cluster.
|
||||
const k3sVersion = "v1.36.2+k3s1";
|
||||
|
||||
// Control-plane VIP — floating IP for API server access, ARP-announced by
|
||||
// kube-vip on whichever master is alive. Added as a TLS SAN on master-1's
|
||||
// cert below, then used (instead of master1Ip) for every other node's join
|
||||
@@ -81,37 +85,46 @@ function conn(
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Step 1: Start all VMs (fire-and-forget — VMs are owned by proxmox-infra)
|
||||
// triggers: vmId — forces re-run when VMs are deleted and recreated
|
||||
// Step 1: Start all VMs (VMs are owned by proxmox-infra)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Succeeds if the VM is already running, or reaches running after a start.
|
||||
function startVmScript(
|
||||
endpoint: pulumi.Input<string>,
|
||||
apiToken: pulumi.Input<string>,
|
||||
nodeName: string,
|
||||
vmId: pulumi.Input<string>,
|
||||
): pulumi.Output<string> {
|
||||
return pulumi.interpolate`base="${endpoint}/api2/json/nodes/${nodeName}/qemu/${vmId}/status"; auth="Authorization: PVEAPIToken=${apiToken}"; is_running() { curl -sfk -H "$auth" "$base/current" | grep -Eq '"status" *: *"running"'; }; is_running && exit 0; curl -sfk -X POST -H "$auth" "$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: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve1ApiToken}" "${pve1Endpoint}/api2/json/nodes/pve/qemu/${master1VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve1Endpoint, pve1ApiToken, "pve", master1VmId),
|
||||
triggers: [master1VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startMaster2 = new command.local.Command("start-master-2", {
|
||||
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`,
|
||||
create: startVmScript(pve3Endpoint, pve3ApiToken, "pve", master2VmId),
|
||||
triggers: [master2VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startWorker1 = new command.local.Command("start-worker-1", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve1ApiToken}" "${pve1Endpoint}/api2/json/nodes/pve/qemu/${worker1VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve1Endpoint, pve1ApiToken, "pve", worker1VmId),
|
||||
triggers: [worker1VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startMaster3 = new command.local.Command("start-master-3", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve2ApiToken}" "${pve2Endpoint}/api2/json/nodes/pve-bckp/qemu/${master3VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve2Endpoint, pve2ApiToken, "pve-bckp", master3VmId),
|
||||
triggers: [master3VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startWorker2 = new command.local.Command("start-worker-2", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve2ApiToken}" "${pve2Endpoint}/api2/json/nodes/pve-bckp/qemu/${worker2VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve2Endpoint, pve2ApiToken, "pve-bckp", worker2VmId),
|
||||
triggers: [worker2VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startWorker3 = new command.local.Command("start-worker-3", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve3ApiToken}" "${pve3Endpoint}/api2/json/nodes/pve/qemu/${worker3VmId}/status/start" 2>/dev/null || true`,
|
||||
create: startVmScript(pve3Endpoint, pve3ApiToken, "pve", worker3VmId),
|
||||
triggers: [worker3VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
@@ -143,7 +156,7 @@ const installMaster1 = new command.remote.Command(
|
||||
"install-k3s-master-1",
|
||||
{
|
||||
connection: conn(master1Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_TOKEN='${k3sToken}' sh -s - server --cluster-init --tls-san ${master1Ip} --tls-san ${controlPlaneVipAddress} --disable servicelb --node-name k3s-master-1`,
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='${k3sVersion}' K3S_TOKEN='${k3sToken}' sh -s - server --cluster-init --tls-san ${master1Ip} --tls-san ${controlPlaneVipAddress} --disable servicelb --node-name k3s-master-1`,
|
||||
triggers: [master1VmId],
|
||||
},
|
||||
{ dependsOn: [waitMaster1Ssh] },
|
||||
@@ -176,7 +189,9 @@ const waitControlPlaneVipReady = new command.remote.Command(
|
||||
"wait-control-plane-vip-ready",
|
||||
{
|
||||
connection: conn(master1Ip),
|
||||
create: pulumi.interpolate`for i in $(seq 1 60); do curl -sk --max-time 3 https://${controlPlaneVipAddress}:6443/healthz && exit 0; sleep 5; done; exit 1`,
|
||||
// 401/403 still prove the API server answered through the VIP: the request
|
||||
// is anonymous, and some clusters reject anonymous health checks.
|
||||
create: pulumi.interpolate`for i in $(seq 1 60); do code=$(curl -sk --max-time 3 -o /dev/null -w '%{http_code}' https://${controlPlaneVipAddress}:6443/healthz); case "$code" in 200|401|403) exit 0;; esac; sleep 5; done; exit 1`,
|
||||
triggers: [master1VmId],
|
||||
},
|
||||
{ dependsOn: [waitK3sMaster1Ready] },
|
||||
@@ -210,7 +225,7 @@ const joinMaster2 = new command.remote.Command(
|
||||
"join-k3s-master-2",
|
||||
{
|
||||
connection: conn(master2Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_TOKEN='${k3sToken}' sh -s - server --server https://${controlPlaneVipAddress}:6443 --disable servicelb --node-name k3s-master-2`,
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='${k3sVersion}' K3S_TOKEN='${k3sToken}' sh -s - server --server https://${controlPlaneVipAddress}:6443 --disable servicelb --node-name k3s-master-2`,
|
||||
triggers: [master2VmId],
|
||||
},
|
||||
{ dependsOn: [waitMaster2Ssh, waitControlPlaneVipReady] },
|
||||
@@ -220,7 +235,7 @@ const joinMaster3 = new command.remote.Command(
|
||||
"join-k3s-master-3",
|
||||
{
|
||||
connection: conn(master3Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_TOKEN='${k3sToken}' sh -s - server --server https://${controlPlaneVipAddress}:6443 --disable servicelb --node-name k3s-master-3`,
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='${k3sVersion}' K3S_TOKEN='${k3sToken}' sh -s - server --server https://${controlPlaneVipAddress}:6443 --disable servicelb --node-name k3s-master-3`,
|
||||
triggers: [master3VmId],
|
||||
},
|
||||
{ dependsOn: [waitMaster3Ssh, waitControlPlaneVipReady, joinMaster2] },
|
||||
@@ -264,7 +279,7 @@ const joinWorker1 = new command.remote.Command(
|
||||
"join-k3s-worker-1",
|
||||
{
|
||||
connection: conn(worker1Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-1`,
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='${k3sVersion}' K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-1`,
|
||||
triggers: [worker1VmId],
|
||||
},
|
||||
{ dependsOn: [waitWorker1Ssh] },
|
||||
@@ -274,7 +289,7 @@ const joinWorker2 = new command.remote.Command(
|
||||
"join-k3s-worker-2",
|
||||
{
|
||||
connection: conn(worker2Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-2`,
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='${k3sVersion}' K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-2`,
|
||||
triggers: [worker2VmId],
|
||||
},
|
||||
{ dependsOn: [waitWorker2Ssh] },
|
||||
@@ -284,7 +299,7 @@ const joinWorker3 = new command.remote.Command(
|
||||
"join-k3s-worker-3",
|
||||
{
|
||||
connection: conn(worker3Ip),
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-3`,
|
||||
create: pulumi.interpolate`curl -sfL https://get.k3s.io | sudo INSTALL_K3S_VERSION='${k3sVersion}' K3S_URL=https://${controlPlaneVipAddress}:6443 K3S_TOKEN='${k3sToken}' sh -s - --node-name k3s-worker-3`,
|
||||
triggers: [worker3VmId],
|
||||
},
|
||||
{ dependsOn: [waitWorker3Ssh] },
|
||||
@@ -304,11 +319,15 @@ workers.forEach((worker, i) => {
|
||||
connection: conn(worker),
|
||||
create: `set -euo pipefail;
|
||||
DISK_ID=$(ls /dev/disk/by-id/ | grep 'scsi1');
|
||||
[ "$(echo "$DISK_ID" | wc -l)" -eq 1 ];
|
||||
DISK_PATH="/dev/disk/by-id/$DISK_ID";
|
||||
sudo blkid "$DISK_PATH" >/dev/null 2>&1 || sudo mkfs.ext4 "$DISK_PATH";
|
||||
BLKID_RC=0;
|
||||
sudo blkid -p "$DISK_PATH" >/dev/null 2>&1 || BLKID_RC=$?;
|
||||
if [ "$BLKID_RC" -eq 2 ]; then sudo mkfs.ext4 "$DISK_PATH"; elif [ "$BLKID_RC" -ne 0 ]; then exit "$BLKID_RC"; fi;
|
||||
sudo mkdir -p /mnt/longhorn-extra;
|
||||
echo ""$DISK_PATH" /mnt/longhorn-extra ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab;
|
||||
grep -qs " /mnt/longhorn-extra " /etc/fstab || echo "$DISK_PATH /mnt/longhorn-extra ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab;
|
||||
sudo mount -a;
|
||||
mountpoint -q /mnt/longhorn-extra;
|
||||
df -h /mnt/longhorn-extra`,
|
||||
},
|
||||
{ dependsOn: workerSshReader[i] },
|
||||
@@ -326,7 +345,10 @@ const getKubeconfig = new command.remote.Command(
|
||||
create: `sudo cat /etc/rancher/k3s/k3s.yaml`,
|
||||
triggers: [master1VmId],
|
||||
},
|
||||
{ dependsOn: [joinWorker1, joinWorker2, joinWorker3] },
|
||||
{
|
||||
dependsOn: [joinWorker1, joinWorker2, joinWorker3],
|
||||
additionalSecretOutputs: ["stdout"],
|
||||
},
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -377,7 +399,8 @@ allVms.forEach(({ id, ip, name, readiness }) => {
|
||||
`install-packages-${name}`,
|
||||
{
|
||||
connection: conn(ip),
|
||||
create: pulumi.interpolate`sudo apt update && sudo apt install -y qemu-guest-agent && sudo systemctl enable --now qemu-guest-agent`,
|
||||
// cloud-init exit code 2 means it finished with recoverable errors.
|
||||
create: pulumi.interpolate`{ sudo cloud-init status --wait >/dev/null || [ $? -eq 2 ]; } && sudo apt-get -o DPkg::Lock::Timeout=300 update && sudo apt-get -o DPkg::Lock::Timeout=300 install -y qemu-guest-agent && sudo systemctl enable --now qemu-guest-agent`,
|
||||
triggers: [id],
|
||||
},
|
||||
{ dependsOn: readiness },
|
||||
|
||||
@@ -26,7 +26,7 @@ proxmox-infra → k8s-bootstrap → k8s-infra
|
||||
- **Secrets**: read via `config.requireSecret()`, never via environment variables or hardcoded values.
|
||||
- **`Pulumi.dev.yaml`**: gitignored (contains the encryption salt). Never delete it or secrets become unrecoverable. CI restores it from a base64 Gitea secret `<STACK>_PULUMI_DEV_YAML`; after changing local config, remind me to update that secret.
|
||||
- **Environment**: `PULUMI_BACKEND_URL` (self-hosted Postgres backend) and `PULUMI_CONFIG_PASSPHRASE` must be set.
|
||||
- **CI**: PRs run `pulumi preview`. `03`–`05` deploy on push to `main`; `01`/`02` deploy only via manual dispatch.
|
||||
- **CI**: PRs run `pulumi preview`. `01` and `03`–`05` deploy on push to `main`; `02` deploys only via manual dispatch. Automatic `01` deploys skip `pulumi refresh`, so run its workflow manually after changing VMs in the Proxmox GUI.
|
||||
|
||||
## Git conventions
|
||||
|
||||
|
||||
+1
-1
@@ -60,4 +60,4 @@ This repo uses Gitea Actions (see root `CLAUDE.md`); Gitea's merge commit reuses
|
||||
- `Enhancement: Refactor k8s-bootstrap for clearer deployment order`
|
||||
- `Chore: Upgrade Pulumi packages across all stacks`
|
||||
|
||||
Since `01`/`02` deploys are manual (`workflow_dispatch`) and `03`–`05` deploy on merge to `main`, a clear PR title also doubles as a quick changelog of what just went live.
|
||||
Since `02` deploys are manual (`workflow_dispatch`) and `01` and `03`–`05` deploy on merge to `main`, a clear PR title also doubles as a quick changelog of what just went live.
|
||||
@@ -120,10 +120,11 @@ One workflow per stack, `.gitea/workflows/0N-deploy-<stack>.yaml`, scoped to cha
|
||||
| Trigger | Stacks | Action |
|
||||
| --- | --- | --- |
|
||||
| PR → `main` | all | `pulumi preview` (read-only) |
|
||||
| Push to `main` | 01 | `pulumi up` (no refresh) |
|
||||
| Push to `main` | 03–05 | `pulumi refresh` + `pulumi up` |
|
||||
| Manual dispatch | all | `pulumi refresh` + `pulumi up` |
|
||||
|
||||
Stacks 01/02 (VM provisioning, cluster bootstrap) deploy **only** via manual dispatch — they're riskier to automate.
|
||||
Stack 02 (cluster bootstrap) deploys **only** via manual dispatch, because re-running it restarts the bootstrap sequence. Stack 01 (VM provisioning) skips the refresh on automatic deploys so a VM missing from Proxmox can't be recreated blank. After changing VMs in the Proxmox GUI, run its workflow manually to sync state.
|
||||
|
||||
### Required secrets
|
||||
|
||||
|
||||
Reference in new issue
Block a user